aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/class.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/class.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/class.c')
-rw-r--r--drivers/base/class.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 73d44cf53db0..3cf6eb36f3d8 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -442,6 +442,13 @@ static ssize_t show_dev(struct class_device *class_dev, char *buf)
442 return print_dev_t(buf, class_dev->devt); 442 return print_dev_t(buf, class_dev->devt);
443} 443}
444 444
445static ssize_t store_uevent(struct class_device *class_dev,
446 const char *buf, size_t count)
447{
448 kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
449 return count;
450}
451
445void class_device_initialize(struct class_device *class_dev) 452void class_device_initialize(struct class_device *class_dev)
446{ 453{
447 kobj_set_kset_s(class_dev, class_obj_subsys); 454 kobj_set_kset_s(class_dev, class_obj_subsys);
@@ -497,6 +504,12 @@ int class_device_add(struct class_device *class_dev)
497 goto register_done; 504 goto register_done;
498 505
499 /* add the needed attributes to this device */ 506 /* add the needed attributes to this device */
507 class_dev->uevent_attr.attr.name = "uevent";
508 class_dev->uevent_attr.attr.mode = S_IWUSR;
509 class_dev->uevent_attr.attr.owner = parent->owner;
510 class_dev->uevent_attr.store = store_uevent;
511 class_device_create_file(class_dev, &class_dev->uevent_attr);
512
500 if (MAJOR(class_dev->devt)) { 513 if (MAJOR(class_dev->devt)) {
501 struct class_device_attribute *attr; 514 struct class_device_attribute *attr;
502 attr = kzalloc(sizeof(*attr), GFP_KERNEL); 515 attr = kzalloc(sizeof(*attr), GFP_KERNEL);
@@ -505,12 +518,10 @@ int class_device_add(struct class_device *class_dev)
505 kobject_del(&class_dev->kobj); 518 kobject_del(&class_dev->kobj);
506 goto register_done; 519 goto register_done;
507 } 520 }
508
509 attr->attr.name = "dev"; 521 attr->attr.name = "dev";
510 attr->attr.mode = S_IRUGO; 522 attr->attr.mode = S_IRUGO;
511 attr->attr.owner = parent->owner; 523 attr->attr.owner = parent->owner;
512 attr->show = show_dev; 524 attr->show = show_dev;
513 attr->store = NULL;
514 class_device_create_file(class_dev, attr); 525 class_device_create_file(class_dev, attr);
515 class_dev->devt_attr = attr; 526 class_dev->devt_attr = attr;
516 } 527 }
@@ -621,6 +632,7 @@ void class_device_del(struct class_device *class_dev)
621 sysfs_remove_link(&class_dev->kobj, "device"); 632 sysfs_remove_link(&class_dev->kobj, "device");
622 sysfs_remove_link(&class_dev->dev->kobj, class_name); 633 sysfs_remove_link(&class_dev->dev->kobj, class_name);
623 } 634 }
635 class_device_remove_file(class_dev, &class_dev->uevent_attr);
624 if (class_dev->devt_attr) 636 if (class_dev->devt_attr)
625 class_device_remove_file(class_dev, class_dev->devt_attr); 637 class_device_remove_file(class_dev, class_dev->devt_attr);
626 class_device_remove_attrs(class_dev); 638 class_device_remove_attrs(class_dev);