* 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.
This commit is contained in:
Doug Rabson 1999-12-24 16:21:15 +00:00
parent 586453fee2
commit 54ac5b9b76
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55091

View File

@ -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;