From: Kay Sievers <[email protected]> This has been in the SuSE kernels for some time now. Signed-off-by: Kay Sievers <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> --- drivers/base/bus.c | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 0a8d075..6768a01 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -610,6 +610,17 @@ static inline int add_probe_files(struct bus_type *bus) { return 0; } static inline void remove_probe_files(struct bus_type *bus) {} #endif +static ssize_t driver_uevent_store(struct device_driver *drv, + const char *buf, size_t count) +{ + enum kobject_action action; + + if (kobject_action_type(buf, count, &action) == 0) + kobject_uevent(&drv->kobj, action); + return count; +} +static DRIVER_ATTR(uevent, S_IWUSR, NULL, driver_uevent_store); + /** * bus_add_driver - Add a driver to the bus. * @drv: driver. @@ -640,6 +651,11 @@ int bus_add_driver(struct device_driver *drv) klist_add_tail(&drv->knode_bus, &bus->klist_drivers); module_add_driver(drv->owner, drv); + error = driver_create_file(drv, &driver_attr_uevent); + if (error) { + printk(KERN_ERR "%s: uevent attr (%s) failed\n", + __FUNCTION__, drv->name); + } error = driver_add_attrs(bus, drv); if (error) { /* How the hell do we get out of this pickle? Give up */ @@ -677,6 +693,7 @@ void bus_remove_driver(struct device_driver * drv) remove_bind_files(drv); driver_remove_attrs(drv->bus, drv); + driver_remove_file(drv, &driver_attr_uevent); klist_remove(&drv->knode_bus); pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); driver_detach(drv); @@ -804,6 +821,17 @@ static void klist_devices_put(struct klist_node *n) put_device(dev); } +static ssize_t bus_uevent_store(struct bus_type *bus, + const char *buf, size_t count) +{ + enum kobject_action action; + + if (kobject_action_type(buf, count, &action) == 0) + kobject_uevent(&bus->subsys.kobj, action); + return count; +} +static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); + /** * bus_register - register a bus with the system. * @bus: bus. @@ -828,6 +856,10 @@ int bus_register(struct bus_type * bus) if (retval) goto out; + retval = bus_create_file(bus, &bus_attr_uevent); + if (retval) + goto bus_uevent_fail; + kobject_set_name(&bus->devices.kobj, "devices"); bus->devices.kobj.parent = &bus->subsys.kobj; retval = kset_register(&bus->devices); @@ -863,6 +895,8 @@ bus_probe_files_fail: bus_drivers_fail: kset_unregister(&bus->devices); bus_devices_fail: + bus_remove_file(bus, &bus_attr_uevent); +bus_uevent_fail: subsystem_unregister(&bus->subsys); out: return retval; @@ -882,6 +916,7 @@ void bus_unregister(struct bus_type * bus) remove_probe_files(bus); kset_unregister(&bus->drivers); kset_unregister(&bus->devices); + bus_remove_file(bus, &bus_attr_uevent); subsystem_unregister(&bus->subsys); } -- 1.5.3.4 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- [PATCH 32/75] Driver core: kerneldoc - kobject_uevent_env is not "usually KOBJ_MOVE"
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 32/75] Driver core: kerneldoc - kobject_uevent_env is not "usually KOBJ_MOVE"
- References:
- [PATCH 01/75] platform: prefix MODALIAS with "platform:"
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 02/75] HOWTO: update ja_JP/HOWTO with latest changes
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 03/75] Driver core: make sysfs uevent-attributes static
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 04/75] Driver core: change add_uevent_var to use a struct
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 05/75] Driver core: add CONFIG_UEVENT_HELPER_PATH
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 06/75] Driver core: remove subsys_set_kset
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 07/75] Driver core: remove kset_set_kset_s
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 08/75] Driver core: remove subsys_put()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 09/75] Driver core: remove subsys_get()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 10/75] Driver core: remove put_bus()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 11/75] Driver core: remove get_bus()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 12/75] kobjects: fix up improper use of the kobject name field
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 13/75] cdev: remove unneeded setting of cdev names
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 14/75] Drivers: clean up direct setting of the name of a kset
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 15/75] kobject: remove the static array for the name
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 16/75] Driver core: clean up removed functions from the documentation
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 17/75] debugfs: helper for decimal challenged
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 18/75] sysfs/file.c - use mutex instead of semaphore
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 19/75] sysfs: cleanup semaphore.h
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 20/75] sysfs: Remove first pass at shadow directory support
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 21/75] sysfs: cosmetic changes in sysfs_lookup()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 22/75] sysfs: simplify sysfs_rename_dir()
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 23/75] sysfs: make sysfs_add/remove_one() call link/unlink_sibling() implictly
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 24/75] sysfs: make sysfs_add_one() automatically check for duplicate entry
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 25/75] sysfs: make sysfs_addrm_finish() return void
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 26/75] dmi-id: Use dynamic sysfs attributes
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 27/75] dmi-id: Possible cleanup
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 28/75] Convert from class_device to device for drivers/video
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 29/75] Convert from class_device to device in drivers/char
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 30/75] Driver core: exclude kobject_uevent.c for !CONFIG_HOTPLUG
- From: Greg Kroah-Hartman <[email protected]>
- [PATCH 01/75] platform: prefix MODALIAS with "platform:"
- Prev by Date: [PATCH 30/75] Driver core: exclude kobject_uevent.c for !CONFIG_HOTPLUG
- Next by Date: [PATCH 32/75] Driver core: kerneldoc - kobject_uevent_env is not "usually KOBJ_MOVE"
- Previous by thread: [PATCH 30/75] Driver core: exclude kobject_uevent.c for !CONFIG_HOTPLUG
- Next by thread: [PATCH 32/75] Driver core: kerneldoc - kobject_uevent_env is not "usually KOBJ_MOVE"
- Index(es):