summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/arm/mv/common.c8
-rw-r--r--sys/arm/mv/mv_machdep.c8
-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
-rw-r--r--sys/dev/ofw/ofw_fdt.c4
-rw-r--r--sys/dev/ofw/openfirm.c2
-rw-r--r--sys/dev/uart/uart_bus_fdt.c4
-rw-r--r--sys/powerpc/booke/platform_bare.c2
-rw-r--r--sys/powerpc/powermac/platform_powermac.c4
-rw-r--r--sys/sparc64/sparc64/ofw_machdep.c2
-rw-r--r--sys/sparc64/sparc64/vm_machdep.c2
12 files changed, 24 insertions, 22 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;
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);
diff --git a/sys/dev/ofw/ofw_fdt.c b/sys/dev/ofw/ofw_fdt.c
index 806f17c..7b3b0e9 100644
--- a/sys/dev/ofw/ofw_fdt.c
+++ b/sys/dev/ofw/ofw_fdt.c
@@ -392,6 +392,8 @@ ofw_fdt_finddevice(ofw_t ofw, const char *device)
int offset;
offset = fdt_path_offset(fdtp, device);
+ if (offset < 0)
+ return (-1);
return (fdt_offset_phandle(offset));
}
@@ -420,7 +422,7 @@ ofw_fdt_fixup(ofw_t ofw)
ssize_t len;
int i;
- if ((root = ofw_fdt_finddevice(ofw, "/")) == 0)
+ if ((root = ofw_fdt_finddevice(ofw, "/")) == -1)
return (ENODEV);
if ((len = ofw_fdt_getproplen(ofw, root, "model")) <= 0)
diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c
index 9ff72df..af6ee80 100644
--- a/sys/dev/ofw/openfirm.c
+++ b/sys/dev/ofw/openfirm.c
@@ -131,7 +131,7 @@ OF_init(void *cookie)
rv = OFW_INIT(ofw_obj, cookie);
- if ((chosen = OF_finddevice("/chosen")) > 0)
+ if ((chosen = OF_finddevice("/chosen")) != -1)
if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
stdout = -1;
diff --git a/sys/dev/uart/uart_bus_fdt.c b/sys/dev/uart/uart_bus_fdt.c
index f8204b1..8088db4 100644
--- a/sys/dev/uart/uart_bus_fdt.c
+++ b/sys/dev/uart/uart_bus_fdt.c
@@ -155,11 +155,11 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
/*
* Retrieve /chosen/std{in,out}.
*/
- if ((chosen = OF_finddevice("/chosen")) == 0)
+ if ((chosen = OF_finddevice("/chosen")) == -1)
return (ENXIO);
if (OF_getprop(chosen, "stdin", buf, sizeof(buf)) <= 0)
return (ENXIO);
- if ((node = OF_finddevice(buf)) == 0)
+ if ((node = OF_finddevice(buf)) == -1)
return (ENXIO);
if (OF_getprop(chosen, "stdout", buf, sizeof(buf)) <= 0)
return (ENXIO);
diff --git a/sys/powerpc/booke/platform_bare.c b/sys/powerpc/booke/platform_bare.c
index ca3cfa2..f04bf96 100644
--- a/sys/powerpc/booke/platform_bare.c
+++ b/sys/powerpc/booke/platform_bare.c
@@ -189,7 +189,7 @@ bare_timebase_freq(platform_t plat, struct cpuref *cpuref)
} else
ticks = 0;
- if ((cpus = OF_finddevice("/cpus")) == 0)
+ if ((cpus = OF_finddevice("/cpus")) == -1)
goto out;
if ((child = OF_child(cpus)) == 0)
diff --git a/sys/powerpc/powermac/platform_powermac.c b/sys/powerpc/powermac/platform_powermac.c
index d495065..978b33a 100644
--- a/sys/powerpc/powermac/platform_powermac.c
+++ b/sys/powerpc/powermac/platform_powermac.c
@@ -163,7 +163,7 @@ powermac_smp_first_cpu(platform_t plat, struct cpuref *cpuref)
* but it can be found directly
*/
dev = OF_finddevice("/cpus");
- if (dev == 0)
+ if (dev == -1)
return (ENOENT);
}
@@ -209,7 +209,7 @@ powermac_smp_get_bsp(platform_t plat, struct cpuref *cpuref)
int res;
chosen = OF_finddevice("/chosen");
- if (chosen == 0)
+ if (chosen == -1)
return (ENXIO);
res = OF_getprop(chosen, "cpu", &inst, sizeof(inst));
diff --git a/sys/sparc64/sparc64/ofw_machdep.c b/sys/sparc64/sparc64/ofw_machdep.c
index 88ee072..f1ce64b 100644
--- a/sys/sparc64/sparc64/ofw_machdep.c
+++ b/sys/sparc64/sparc64/ofw_machdep.c
@@ -52,7 +52,7 @@ OF_getetheraddr(device_t dev, u_char *addr)
phandle_t node;
struct idprom idp;
- if ((node = OF_finddevice("/options")) > 0 &&
+ if ((node = OF_finddevice("/options")) != -1 &&
OF_getprop(node, "local-mac-address?", buf, sizeof(buf)) > 0) {
buf[sizeof(buf) - 1] = '\0';
if (strcmp(buf, "true") == 0 &&
diff --git a/sys/sparc64/sparc64/vm_machdep.c b/sys/sparc64/sparc64/vm_machdep.c
index dae1989..36f1cc5 100644
--- a/sys/sparc64/sparc64/vm_machdep.c
+++ b/sys/sparc64/sparc64/vm_machdep.c
@@ -368,7 +368,7 @@ cpu_reset(void)
(cell_t)bspec
};
- if ((chosen = OF_finddevice("/chosen")) != 0) {
+ if ((chosen = OF_finddevice("/chosen")) != -1) {
if (OF_getprop(chosen, "bootpath", bspec, sizeof(bspec)) == -1)
bspec[0] = '\0';
bspec[sizeof(bspec) - 1] = '\0';
OpenPOWER on IntegriCloud