summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1999-12-24 16:21:15 +0000
committerdfr <dfr@FreeBSD.org>1999-12-24 16:21:15 +0000
commitc0ba4bf65f0d7cc0840da6ae15800b0025ac0ed5 (patch)
tree96cd96758224c53e68eddb076680641405307477 /sys/kern
parentd8ee3ca193b92be71a83f36703c80fcecad5c283 (diff)
downloadFreeBSD-src-c0ba4bf65f0d7cc0840da6ae15800b0025ac0ed5.zip
FreeBSD-src-c0ba4bf65f0d7cc0840da6ae15800b0025ac0ed5.tar.gz
* Set the devclass of a device before calling the probe method. This allows
device_printf() etc. to print something intelligible. * Allow device_set_devclass(dev, 0) for clearing the devclass.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_bus.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 162c32b..d622ed9 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -756,9 +756,10 @@ device_probe_child(device_t dev, device_t child)
driverlink_t best = 0;
driverlink_t dl;
int result, pri = 0;
+ int hasclass = (child->devclass != 0);
dc = dev->devclass;
- if (dc == NULL)
+ if (!dc)
panic("device_probe_child: parent device has no devclass");
if (child->state == DS_ALIVE)
@@ -769,7 +770,11 @@ device_probe_child(device_t dev, device_t child)
dl = next_matching_driver(dc, child, dl)) {
PDEBUG(("Trying %s", DRIVERNAME(dl->driver)));
device_set_driver(child, dl->driver);
+ if (!hasclass)
+ device_set_devclass(child, dl->driver->name);
result = DEVICE_PROBE(child);
+ if (!hasclass)
+ device_set_devclass(child, 0);
/*
* If the driver returns SUCCESS, there can be no higher match
@@ -1069,6 +1074,12 @@ device_set_devclass(device_t dev, const char *classname)
{
devclass_t dc;
+ if (!classname) {
+ if (dev->devclass)
+ devclass_delete_device(dev->devclass, dev);
+ return 0;
+ }
+
if (dev->devclass) {
printf("device_set_devclass: device class already set\n");
return EINVAL;
OpenPOWER on IntegriCloud