diff options
-rw-r--r-- | drivers/base/bus.c | 22 | ||||
-rw-r--r-- | include/linux/device.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index c3141565d59d..48718b7f4fa0 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -536,6 +536,28 @@ void bus_rescan_devices(struct bus_type * bus) | |||
536 | bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper); | 536 | bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper); |
537 | } | 537 | } |
538 | 538 | ||
539 | /** | ||
540 | * device_reprobe - remove driver for a device and probe for a new driver | ||
541 | * @dev: the device to reprobe | ||
542 | * | ||
543 | * This function detaches the attached driver (if any) for the given | ||
544 | * device and restarts the driver probing process. It is intended | ||
545 | * to use if probing criteria changed during a devices lifetime and | ||
546 | * driver attachment should change accordingly. | ||
547 | */ | ||
548 | void device_reprobe(struct device *dev) | ||
549 | { | ||
550 | if (dev->driver) { | ||
551 | if (dev->parent) /* Needed for USB */ | ||
552 | down(&dev->parent->sem); | ||
553 | device_release_driver(dev); | ||
554 | if (dev->parent) | ||
555 | up(&dev->parent->sem); | ||
556 | } | ||
557 | |||
558 | bus_rescan_devices_helper(dev, NULL); | ||
559 | } | ||
560 | EXPORT_SYMBOL_GPL(device_reprobe); | ||
539 | 561 | ||
540 | struct bus_type * get_bus(struct bus_type * bus) | 562 | struct bus_type * get_bus(struct bus_type * bus) |
541 | { | 563 | { |
diff --git a/include/linux/device.h b/include/linux/device.h index 58df18d9cd3e..e8ac5bcfbec7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -378,6 +378,7 @@ extern void device_bind_driver(struct device * dev); | |||
378 | extern void device_release_driver(struct device * dev); | 378 | extern void device_release_driver(struct device * dev); |
379 | extern int device_attach(struct device * dev); | 379 | extern int device_attach(struct device * dev); |
380 | extern void driver_attach(struct device_driver * drv); | 380 | extern void driver_attach(struct device_driver * drv); |
381 | extern void device_reprobe(struct device *dev); | ||
381 | 382 | ||
382 | 383 | ||
383 | /* | 384 | /* |