diff --git a/drivers/base/driver.c b/drivers/base/driver.c index dc2df9152..1f4031ac9 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -75,6 +75,21 @@ int get_free_deviceid(const char *name_template) }; } +int device_probe(struct device_d *dev) +{ + int ret; + + ret = dev->bus->probe(dev); + if (ret) { + dev_err(dev, "probe failed: %s\n", strerror(-ret)); + return ret; + } + + list_add(&dev->active, &active); + + return 0; +} + static int match(struct driver_d *drv, struct device_d *dev) { int ret; @@ -86,13 +101,9 @@ static int match(struct driver_d *drv, struct device_d *dev) if (dev->bus->match(dev, drv)) goto err_out; - ret = dev->bus->probe(dev); - if (ret) { - dev_err(dev, "probe failed: %s\n", strerror(-ret)); + ret = device_probe(dev); + if (ret) goto err_out; - } - - list_add(&dev->active, &active); return 0; err_out: diff --git a/include/driver.h b/include/driver.h index f8d815c61..a08598174 100644 --- a/include/driver.h +++ b/include/driver.h @@ -148,6 +148,11 @@ struct driver_d { int register_driver(struct driver_d *); int register_device(struct device_d *); +/* manualy probe a device + * the driver need to be specified + */ +int device_probe(struct device_d *dev); + /* Unregister a device. This function can fail, e.g. when the device * has children. */