diff options
author | Nathan Whitehorn <nwhitehorn@FreeBSD.org> | 2014-02-02 16:41:54 +0000 |
---|---|---|
committer | Nathan Whitehorn <nwhitehorn@FreeBSD.org> | 2014-02-02 16:41:54 +0000 |
commit | e4be5a1636b9d781c543644c94bef319dd037a18 (patch) | |
tree | eb659e6572a225bfe96fcb67eb39770f8a304f99 /sys/dev/ofw | |
parent | c41b028cb6df2ab037d10bc558dc4686ab65cd0a (diff) | |
download | src-e4be5a1636b9d781c543644c94bef319dd037a18.tar.gz src-e4be5a1636b9d781c543644c94bef319dd037a18.zip |
Notes
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r-- | sys/dev/ofw/ofw_bus_if.m | 1 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_bus_subr.c | 27 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_bus_subr.h | 4 |
3 files changed, 32 insertions, 0 deletions
diff --git a/sys/dev/ofw/ofw_bus_if.m b/sys/dev/ofw/ofw_bus_if.m index a058f0a095d4..6486e966695f 100644 --- a/sys/dev/ofw/ofw_bus_if.m +++ b/sys/dev/ofw/ofw_bus_if.m @@ -46,6 +46,7 @@ HEADER { char *obd_model; char *obd_name; char *obd_type; + char *obd_status; }; }; diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c index bf552a8b2f5b..64ac11f33d1a 100644 --- a/sys/dev/ofw/ofw_bus_subr.c +++ b/sys/dev/ofw/ofw_bus_subr.c @@ -55,6 +55,7 @@ ofw_bus_gen_setup_devinfo(struct ofw_bus_devinfo *obd, phandle_t node) OF_getprop_alloc(node, "compatible", 1, (void **)&obd->obd_compat); OF_getprop_alloc(node, "device_type", 1, (void **)&obd->obd_type); OF_getprop_alloc(node, "model", 1, (void **)&obd->obd_model); + OF_getprop_alloc(node, "status", 1, (void **)&obd->obd_status); obd->obd_node = node; return (0); } @@ -73,6 +74,8 @@ ofw_bus_gen_destroy_devinfo(struct ofw_bus_devinfo *obd) free(obd->obd_name, M_OFWPROP); if (obd->obd_type != NULL) free(obd->obd_type, M_OFWPROP); + if (obd->obd_status != NULL) + free(obd->obd_status, M_OFWPROP); } int @@ -147,6 +150,30 @@ ofw_bus_gen_get_type(device_t bus, device_t dev) return (obd->obd_type); } +const char * +ofw_bus_get_status(device_t dev) +{ + const struct ofw_bus_devinfo *obd; + + obd = OFW_BUS_GET_DEVINFO(device_get_parent(dev), dev); + if (obd == NULL) + return (NULL); + + return (obd->obd_status); +} + +int +ofw_bus_status_okay(device_t dev) +{ + const char *status; + + status = ofw_bus_get_status(dev); + if (status == NULL || strcmp(status, "okay") == 0) + return (1); + + return (0); +} + int ofw_bus_is_compatible(device_t dev, const char *onecompat) { diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h index e9ef5e43128f..a4d8b920291f 100644 --- a/sys/dev/ofw/ofw_bus_subr.h +++ b/sys/dev/ofw/ofw_bus_subr.h @@ -72,6 +72,10 @@ int ofw_bus_lookup_imap(phandle_t, struct ofw_bus_iinfo *, void *, int, int ofw_bus_search_intrmap(void *, int, void *, int, void *, int, void *, void *, void *, int, phandle_t *); +/* Helper to get device status property */ +const char *ofw_bus_get_status(device_t dev); +int ofw_bus_status_okay(device_t dev); + /* Helper to get node's interrupt parent */ void ofw_bus_find_iparent(phandle_t); |