diff options
author | jchandra <jchandra@FreeBSD.org> | 2011-12-02 15:24:39 +0000 |
---|---|---|
committer | jchandra <jchandra@FreeBSD.org> | 2011-12-02 15:24:39 +0000 |
commit | e5b89f2d70c0092ae178473393348aa3de7e2745 (patch) | |
tree | 282cdd7ec20de7056adfd64b8aed0bd16d32eb50 /sys/arm | |
parent | 9be1bfa322fff9a906d73bb1d09940d86d489415 (diff) | |
download | FreeBSD-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/arm')
-rw-r--r-- | sys/arm/mv/common.c | 8 | ||||
-rw-r--r-- | sys/arm/mv/mv_machdep.c | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/sys/arm/mv/common.c b/sys/arm/mv/common.c index 4596a20..c7beae8 100644 --- a/sys/arm/mv/common.c +++ b/sys/arm/mv/common.c @@ -1693,7 +1693,7 @@ fdt_get_ranges(const char *nodename, void *buf, int size, int *tuples, int len, tuple_size, tuples_count; node = OF_finddevice(nodename); - if (node <= 0) + if (node == -1) return (EINVAL); if ((fdt_addrsize_cells(node, &addr_cells, &size_cells)) != 0) @@ -1762,11 +1762,11 @@ win_cpu_from_dt(void) /* * Retrieve CESA SRAM data. */ - if ((node = OF_finddevice("sram")) != 0) + if ((node = OF_finddevice("sram")) != -1) if (fdt_is_compatible(node, "mrvl,cesa-sram")) goto moveon; - if ((node = OF_finddevice("/")) == 0) + if ((node = OF_finddevice("/")) != -1) return (ENXIO); if ((node = fdt_find_compatible(node, "mrvl,cesa-sram", 0)) == 0) @@ -1796,7 +1796,7 @@ fdt_win_setup(void) int err, i; node = OF_finddevice("/"); - if (node == 0) + if (node == -1) panic("fdt_win_setup: no root node"); node = fdt_find_compatible(node, "simple-bus", 1); diff --git a/sys/arm/mv/mv_machdep.c b/sys/arm/mv/mv_machdep.c index fd17692..8839740 100644 --- a/sys/arm/mv/mv_machdep.c +++ b/sys/arm/mv/mv_machdep.c @@ -617,13 +617,13 @@ platform_mpp_init(void) /* * Try to access the MPP node directly i.e. through /aliases/mpp. */ - if ((node = OF_finddevice("mpp")) != 0) + if ((node = OF_finddevice("mpp")) != -1) if (fdt_is_compatible(node, "mrvl,mpp")) 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", 0)) == 0) @@ -752,7 +752,7 @@ platform_devmap_init(void) /* * PCI range(s). */ - if ((root = OF_finddevice("/")) == 0) + if ((root = OF_finddevice("/")) == -1) return (ENXIO); for (child = OF_child(root); child != 0; child = OF_peer(child)) @@ -779,7 +779,7 @@ platform_devmap_init(void) /* * CESA SRAM range. */ - if ((child = OF_finddevice("sram")) != 0) + if ((child = OF_finddevice("sram")) != -1) if (fdt_is_compatible(child, "mrvl,cesa-sram")) goto moveon; |