aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/class.c
diff options
context:
space:
mode:
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);