aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-12-13 18:17:34 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 19:18:09 -0500
commit874c6241b2e49e52680d32a50d4909c7768d5cb9 (patch)
tree815b08ab6793cd45346c3d5f6a3875f36c0bfc91 /drivers/base/bus.c
parenta96b204208443ab7e23c681f7ddabe807a741d0c (diff)
[PATCH] Driver core: only all userspace bind/unbind if CONFIG_HOTPLUG is enabled
Thanks to drivers making their id tables __devinit, we can't allow userspace to bind or unbind drivers from devices manually through sysfs. So we only allow this if CONFIG_HOTPLUG is enabled. Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/bus.c')
-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);