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/sparc64 | |
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/sparc64')
-rw-r--r-- | sys/sparc64/sparc64/ofw_machdep.c | 2 | ||||
-rw-r--r-- | sys/sparc64/sparc64/vm_machdep.c | 2 |
2 files changed, 2 insertions, 2 deletions
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'; |