From 54ac5b9b76f046f87e01939ec3bd8e15884d8a72 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Fri, 24 Dec 1999 16:21:15 +0000 Subject: [PATCH] * 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. --- sys/kern/subr_bus.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 162c32b1eeed..d622ed96c3cc 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;