leds: add led-class attribute-group support
authorJohan Hovold <johan@kernel.org>
Wed, 25 Jun 2014 17:08:44 +0000 (10:08 -0700)
committerBryan Wu <cooloney@gmail.com>
Wed, 25 Jun 2014 21:55:03 +0000 (14:55 -0700)
Allow led-class devices to be created with optional attribute groups.

This is needed in order to allow led drivers to create custom device
attributes in a race-free manner.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/led-class.c
include/linux/leds.h

index f37d63cf726bd52ed80db0c1effe1d9fc33db069..aa29198fca3e2b2c892268eb2549444b1beb499c 100644 (file)
@@ -210,8 +210,9 @@ static const struct dev_pm_ops leds_class_dev_pm_ops = {
  */
 int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
 {
-       led_cdev->dev = device_create(leds_class, parent, 0, led_cdev,
-                                     "%s", led_cdev->name);
+       led_cdev->dev = device_create_with_groups(leds_class, parent, 0,
+                                       led_cdev, led_cdev->groups,
+                                       "%s", led_cdev->name);
        if (IS_ERR(led_cdev->dev))
                return PTR_ERR(led_cdev->dev);
 
index 0287ab2966899ad1e65daa072629398d66b6e791..e436864721971c81383a323bf3951e19632475a0 100644 (file)
@@ -63,6 +63,8 @@ struct led_classdev {
                                     unsigned long *delay_off);
 
        struct device           *dev;
+       const struct attribute_group    **groups;
+
        struct list_head         node;                  /* LED Device list */
        const char              *default_trigger;       /* Trigger to use */