summaryrefslogtreecommitdiffstats
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authorjchandra <jchandra@FreeBSD.org>2011-12-02 15:24:39 +0000
committerjchandra <jchandra@FreeBSD.org>2011-12-02 15:24:39 +0000
commite5b89f2d70c0092ae178473393348aa3de7e2745 (patch)
tree282cdd7ec20de7056adfd64b8aed0bd16d32eb50 /sys/dev/fdt
parent9be1bfa322fff9a906d73bb1d09940d86d489415 (diff)
downloadFreeBSD-src-e5b89f2d70c0092ae178473393348aa3de7e2745.zip
FreeBSD-src-e5b89f2d70c0092ae178473393348aa3de7e2745.tar.gz
Fix OF_finddevice error return value in case of FDT.
According to the open firmware standard, finddevice call has to return a phandle with value of -1 in case of error. This commit is to: - Fix the FDT implementation of this interface (ofw_fdt_finddevice) to return (phandle_t)-1 in case of error, instead of 0 as it does now. - Fix up the callers of OF_finddevice() to compare the return value with -1 instead of 0 to check for errors. - Since phandle_t is unsigned, the return value of OF_finddevice should be checked with '== -1' rather than '<= 0' or '> 0', fix up these cases as well. Reported by: nwhitehorn Reviewed by: raj Approved by: raj, nwhitehorn
Diffstat (limited to 'sys/dev/fdt')
-rw-r--r--sys/dev/fdt/fdt_common.c6
-rw-r--r--sys/dev/fdt/fdt_powerpc.c2
-rw-r--r--sys/dev/fdt/fdtbus.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c
index d25715b..8702df2 100644
--- a/sys/dev/fdt/fdt_common.c
+++ b/sys/dev/fdt/fdt_common.c
@@ -74,13 +74,13 @@ fdt_immr_addr(vm_offset_t immr_va)
/*
* Try to access the SOC node directly i.e. through /aliases/.
*/
- if ((node = OF_finddevice("soc")) != 0)
+ if ((node = OF_finddevice("soc")) != -1)
if (fdt_is_compatible_strict(node, "simple-bus"))
goto moveon;
/*
* Find the node the long way.
*/
- if ((node = OF_finddevice("/")) == 0)
+ if ((node = OF_finddevice("/")) == -1)
return (ENXIO);
if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)
@@ -576,7 +576,7 @@ fdt_get_mem_regions(struct mem_region *mr, int *mrcnt, uint32_t *memsize)
max_size = sizeof(reg);
memory = OF_finddevice("/memory");
- if (memory <= 0) {
+ if (memory == -1) {
rv = ENXIO;
goto out;
}
diff --git a/sys/dev/fdt/fdt_powerpc.c b/sys/dev/fdt/fdt_powerpc.c
index ea614db..ac81c08 100644
--- a/sys/dev/fdt/fdt_powerpc.c
+++ b/sys/dev/fdt/fdt_powerpc.c
@@ -62,7 +62,7 @@ fdt_fixup_busfreq(phandle_t root)
* This fixup uses /cpus/ bus-frequency prop value to set simple-bus
* bus-frequency property.
*/
- if ((cpus = OF_finddevice("/cpus")) == 0)
+ if ((cpus = OF_finddevice("/cpus")) == -1)
return;
if ((child = OF_child(cpus)) == 0)
diff --git a/sys/dev/fdt/fdtbus.c b/sys/dev/fdt/fdtbus.c
index a2530cd..50db7cd 100644
--- a/sys/dev/fdt/fdtbus.c
+++ b/sys/dev/fdt/fdtbus.c
@@ -177,7 +177,7 @@ fdtbus_attach(device_t dev)
u_long start, end;
int error;
- if ((root = OF_peer(0)) == 0)
+ if ((root = OF_finddevice("/")) == -1)
panic("fdtbus_attach: no root node.");
sc = device_get_softc(dev);
OpenPOWER on IntegriCloud