diff options
| author | jmcneill <jmcneill@NetBSD.org> | 2019-09-24 15:23:34 +0000 |
|---|---|---|
| committer | jmcneill <jmcneill@NetBSD.org> | 2019-09-24 15:23:34 +0000 |
| commit | 6607163ddbcd09dc901d06928b2fb953129707d2 (patch) | |
| tree | 3d3e373772cce6a02886eeb4b2de3a020bb981d1 /sys/dev | |
| parent | 8fddeb626b3ce80489d2c676b804e11c5f768ea9 (diff) | |
Use correct #cells for parent address when decoding ranges
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/fdt/fdt_subr.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/dev/fdt/fdt_subr.c b/sys/dev/fdt/fdt_subr.c index 8ca7c8f8184..d050f460f11 100644 --- a/sys/dev/fdt/fdt_subr.c +++ b/sys/dev/fdt/fdt_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_subr.c,v 1.30 2019/06/14 11:08:18 hkenken Exp $ */ +/* $NetBSD: fdt_subr.c,v 1.31 2019/09/24 15:23:34 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.30 2019/06/14 11:08:18 hkenken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.31 2019/09/24 15:23:34 jmcneill Exp $"); #include "opt_fdt.h" @@ -224,7 +224,7 @@ fdtbus_decode_range(int phandle, uint64_t paddr) const int addr_cells = fdtbus_get_addr_cells(phandle); const int size_cells = fdtbus_get_size_cells(phandle); - const int paddr_cells = fdtbus_get_addr_cells(OF_parent(parent)); + const int paddr_cells = fdtbus_get_addr_cells(parent); if (addr_cells == -1 || size_cells == -1 || paddr_cells == -1) return paddr; @@ -237,6 +237,10 @@ fdtbus_decode_range(int phandle, uint64_t paddr) cl = fdtbus_get_cells(buf, size_cells); buf += size_cells * 4; +#ifdef FDTBUS_DEBUG + printf("%s: %s: cba=0x%#" PRIx64 ", pba=0x%#" PRIx64 ", cl=0x%#" PRIx64 "\n", __func__, fdt_get_name(fdtbus_get_data(), fdtbus_phandle2offset(phandle), NULL), cba, pba, cl); +#endif + if (paddr >= cba && paddr < cba + cl) return fdtbus_decode_range(parent, pba) + (paddr - cba); |
