summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2009-11-15 16:44:43 +0000
committerattilio <attilio@FreeBSD.org>2009-11-15 16:44:43 +0000
commit9dd892aeae833cc67a6f5e8d602972bbedec5eb6 (patch)
treea803af1c94671a1fcfeeaba899652b29e87f3253
parentd1297db1aeb036a628e2f6fc5bd24e6f91cdb7b0 (diff)
downloadFreeBSD-src-9dd892aeae833cc67a6f5e8d602972bbedec5eb6.zip
FreeBSD-src-9dd892aeae833cc67a6f5e8d602972bbedec5eb6.tar.gz
Collapse devinfo_state_t with device_state_t in order to avoid a
structure replication and improve manteneability. Reviewed by: jhb, imp Tested by: Riccardo Torrini <riccardo at torrini dot org>
-rw-r--r--lib/libdevinfo/devinfo.h12
-rw-r--r--tools/tools/ncpus/acpi.c12
-rw-r--r--usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c8
-rw-r--r--usr.sbin/devinfo/devinfo.c2
4 files changed, 13 insertions, 21 deletions
diff --git a/lib/libdevinfo/devinfo.h b/lib/libdevinfo/devinfo.h
index 3e580f2..2b49743 100644
--- a/lib/libdevinfo/devinfo.h
+++ b/lib/libdevinfo/devinfo.h
@@ -32,20 +32,12 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
+#include <sys/bus.h>
typedef __uintptr_t devinfo_handle_t;
#define DEVINFO_ROOT_DEVICE ((devinfo_handle_t)0)
-/*
- * State of the device.
- */
-/* XXX not sure if I want a copy here, or expose sys/bus.h */
-typedef enum devinfo_state {
- DIS_NOTPRESENT = 10, /* not probed or probe failed */
- DIS_ALIVE = 20, /* probe succeeded */
- DIS_ATTACHED = 30, /* attach method called */
- DIS_BUSY = 40 /* device is open */
-} devinfo_state_t;
+typedef enum device_state devinfo_state_t;
struct devinfo_dev {
devinfo_handle_t dd_handle; /* device handle */
diff --git a/tools/tools/ncpus/acpi.c b/tools/tools/ncpus/acpi.c
index 88ec6fc..5366dc8 100644
--- a/tools/tools/ncpus/acpi.c
+++ b/tools/tools/ncpus/acpi.c
@@ -247,13 +247,13 @@ static const char *
devstate(devinfo_state_t state)
{
switch (state) {
- case DIS_NOTPRESENT:
+ case DS_NOTPRESENT:
return "not-present";
- case DIS_ALIVE:
+ case DS_ALIVE:
return "alive";
- case DIS_ATTACHED:
+ case DS_ATTACHED:
return "attached";
- case DIS_BUSY:
+ case DS_BUSY:
return "busy";
default:
return "unknown-state";
@@ -266,8 +266,8 @@ acpi0_check(struct devinfo_dev *dd, void *arg)
printf("%s: %s %s\n", __func__, dd->dd_name, devstate(dd->dd_state));
/* NB: device must be present AND attached */
if (strcmp(dd->dd_name, "acpi0") == 0)
- return (dd->dd_state == DIS_ATTACHED ||
- dd->dd_state == DIS_BUSY);
+ return (dd->dd_state == DS_ATTACHED ||
+ dd->dd_state == DS_BUSY);
return devinfo_foreach_device_child(dd, acpi0_check, arg);
}
diff --git a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
index 7e81436..cb38145 100644
--- a/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
+++ b/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c
@@ -352,11 +352,11 @@ device_get_status(struct devinfo_dev *dev)
assert(dev != NULL);
switch (dev->dd_state) {
- case DIS_ALIVE: /* probe succeeded */
- case DIS_NOTPRESENT: /* not probed or probe failed */
+ case DS_ALIVE: /* probe succeeded */
+ case DS_NOTPRESENT: /* not probed or probe failed */
return (DS_DOWN);
- case DIS_ATTACHED: /* attach method called */
- case DIS_BUSY: /* device is open */
+ case DS_ATTACHED: /* attach method called */
+ case DS_BUSY: /* device is open */
return (DS_RUNNING);
default:
return (DS_UNKNOWN);
diff --git a/usr.sbin/devinfo/devinfo.c b/usr.sbin/devinfo/devinfo.c
index c32e57b..73dcfd5 100644
--- a/usr.sbin/devinfo/devinfo.c
+++ b/usr.sbin/devinfo/devinfo.c
@@ -137,7 +137,7 @@ print_device(struct devinfo_dev *dev, void *arg)
struct indent_arg ia;
int i, indent;
- if (vflag || (dev->dd_name[0] != 0 && dev->dd_state >= DIS_ATTACHED)) {
+ if (vflag || (dev->dd_name[0] != 0 && dev->dd_state >= DS_ATTACHED)) {
indent = (int)(intptr_t)arg;
for (i = 0; i < indent; i++)
printf(" ");
OpenPOWER on IntegriCloud