aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/bus.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index e3f915a24891..29f6af554e71 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -428,6 +428,26 @@ static void driver_remove_attrs(struct bus_type * bus, struct device_driver * dr
428 } 428 }
429} 429}
430 430
431#ifdef CONFIG_HOTPLUG
432/*
433 * Thanks to drivers making their tables __devinit, we can't allow manual
434 * bind and unbind from userspace unless CONFIG_HOTPLUG is enabled.
435 */
436static void add_bind_files(struct device_driver *drv)
437{
438 driver_create_file(drv, &driver_attr_unbind);
439 driver_create_file(drv, &driver_attr_bind);
440}
441
442static void remove_bind_files(struct device_driver *drv)
443{
444 driver_remove_file(drv, &driver_attr_bind);
445 driver_remove_file(drv, &driver_attr_unbind);
446}
447#else
448static inline void add_bind_files(struct device_driver *drv) {}
449static inline void remove_bind_files(struct device_driver *drv) {}
450#endif
431 451
432/** 452/**
433 * bus_add_driver - Add a driver to the bus. 453 * bus_add_driver - Add a driver to the bus.
@@ -457,8 +477,7 @@ int bus_add_driver(struct device_driver * drv)
457 module_add_driver(drv->owner, drv); 477 module_add_driver(drv->owner, drv);
458 478
459 driver_add_attrs(bus, drv); 479 driver_add_attrs(bus, drv);
460 driver_create_file(drv, &driver_attr_unbind); 480 add_bind_files(drv);
461 driver_create_file(drv, &driver_attr_bind);
462 } 481 }
463 return error; 482 return error;
464} 483}
@@ -476,8 +495,7 @@ int bus_add_driver(struct device_driver * drv)
476void bus_remove_driver(struct device_driver * drv) 495void bus_remove_driver(struct device_driver * drv)
477{ 496{
478 if (drv->bus) { 497 if (drv->bus) {
479 driver_remove_file(drv, &driver_attr_bind); 498 remove_bind_files(drv);
480 driver_remove_file(drv, &driver_attr_unbind);
481 driver_remove_attrs(drv->bus, drv); 499 driver_remove_attrs(drv->bus, drv);
482 klist_remove(&drv->knode_bus); 500 klist_remove(&drv->knode_bus);
483 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); 501 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);