aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-10-01 08:49:43 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:51 -0400
commita7fd67062efc5b0fc9a61368c607fa92d1d57f9e (patch)
tree8b91f198640608bd99f4e4764394e5134220abcf /drivers/base/core.c
parentd8539d81aeee4dbdc0624a798321e822fb2df7ae (diff)
[PATCH] add sysfs attr to re-emit device hotplug event
A "coldplug + udevstart" can be simple like this: for i in /sys/block/*/*/uevent; do echo 1 > $i; done for i in /sys/class/*/*/uevent; do echo 1 > $i; done for i in /sys/bus/*/devices/*/uevent; do echo 1 > $i; done Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 31109193e2c4..ac4b5fdd95f5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -154,6 +154,13 @@ static struct kset_hotplug_ops device_hotplug_ops = {
154 .hotplug = dev_hotplug, 154 .hotplug = dev_hotplug,
155}; 155};
156 156
157static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
158 const char *buf, size_t count)
159{
160 kobject_hotplug(&dev->kobj, KOBJ_ADD);
161 return count;
162}
163
157/** 164/**
158 * device_subsys - structure to be registered with kobject core. 165 * device_subsys - structure to be registered with kobject core.
159 */ 166 */
@@ -259,6 +266,14 @@ int device_add(struct device *dev)
259 266
260 if ((error = kobject_add(&dev->kobj))) 267 if ((error = kobject_add(&dev->kobj)))
261 goto Error; 268 goto Error;
269
270 dev->uevent_attr.attr.name = "uevent";
271 dev->uevent_attr.attr.mode = S_IWUSR;
272 if (dev->driver)
273 dev->uevent_attr.attr.owner = dev->driver->owner;
274 dev->uevent_attr.store = store_uevent;
275 device_create_file(dev, &dev->uevent_attr);
276
262 kobject_hotplug(&dev->kobj, KOBJ_ADD); 277 kobject_hotplug(&dev->kobj, KOBJ_ADD);
263 if ((error = device_pm_add(dev))) 278 if ((error = device_pm_add(dev)))
264 goto PMError; 279 goto PMError;
@@ -350,6 +365,7 @@ void device_del(struct device * dev)
350 365
351 if (parent) 366 if (parent)
352 klist_del(&dev->knode_parent); 367 klist_del(&dev->knode_parent);
368 device_remove_file(dev, &dev->uevent_attr);
353 369
354 /* Notify the platform of the removal, in case they 370 /* Notify the platform of the removal, in case they
355 * need to do anything... 371 * need to do anything...