aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds/led-class.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-24 18:05:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-26 21:05:17 -0400
commit5baa7503a7a0b8d65308ff3b2ab887bf343c65d3 (patch)
treed23eef70f70b34ffcb58b4c974618392fc27f7d0 /drivers/leds/led-class.c
parentd98259cbf9f1c86e921caa1241aa8d229249e0b8 (diff)
leds: convert class code to use dev_groups
The dev_attrs field of struct class is going away soon, dev_groups should be used instead. This converts the led class code to use the correct field. Acked-by: Bryan Wu <cooloney@gmail.com> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r--drivers/leds/led-class.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 4336e37a97f4..f37d63cf726b 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -29,7 +29,7 @@ static void led_update_brightness(struct led_classdev *led_cdev)
29 led_cdev->brightness = led_cdev->brightness_get(led_cdev); 29 led_cdev->brightness = led_cdev->brightness_get(led_cdev);
30} 30}
31 31
32static ssize_t led_brightness_show(struct device *dev, 32static ssize_t brightness_show(struct device *dev,
33 struct device_attribute *attr, char *buf) 33 struct device_attribute *attr, char *buf)
34{ 34{
35 struct led_classdev *led_cdev = dev_get_drvdata(dev); 35 struct led_classdev *led_cdev = dev_get_drvdata(dev);
@@ -40,7 +40,7 @@ static ssize_t led_brightness_show(struct device *dev,
40 return sprintf(buf, "%u\n", led_cdev->brightness); 40 return sprintf(buf, "%u\n", led_cdev->brightness);
41} 41}
42 42
43static ssize_t led_brightness_store(struct device *dev, 43static ssize_t brightness_store(struct device *dev,
44 struct device_attribute *attr, const char *buf, size_t size) 44 struct device_attribute *attr, const char *buf, size_t size)
45{ 45{
46 struct led_classdev *led_cdev = dev_get_drvdata(dev); 46 struct led_classdev *led_cdev = dev_get_drvdata(dev);
@@ -57,6 +57,7 @@ static ssize_t led_brightness_store(struct device *dev,
57 57
58 return size; 58 return size;
59} 59}
60static DEVICE_ATTR_RW(brightness);
60 61
61static ssize_t led_max_brightness_show(struct device *dev, 62static ssize_t led_max_brightness_show(struct device *dev,
62 struct device_attribute *attr, char *buf) 63 struct device_attribute *attr, char *buf)
@@ -65,14 +66,35 @@ static ssize_t led_max_brightness_show(struct device *dev,
65 66
66 return sprintf(buf, "%u\n", led_cdev->max_brightness); 67 return sprintf(buf, "%u\n", led_cdev->max_brightness);
67} 68}
69static DEVICE_ATTR(max_brightness, 0444, led_max_brightness_show, NULL);
68 70
69static struct device_attribute led_class_attrs[] = {
70 __ATTR(brightness, 0644, led_brightness_show, led_brightness_store),
71 __ATTR(max_brightness, 0444, led_max_brightness_show, NULL),
72#ifdef CONFIG_LEDS_TRIGGERS 71#ifdef CONFIG_LEDS_TRIGGERS
73 __ATTR(trigger, 0644, led_trigger_show, led_trigger_store), 72static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);
73static struct attribute *led_trigger_attrs[] = {
74 &dev_attr_trigger.attr,
75 NULL,
76};
77static const struct attribute_group led_trigger_group = {
78 .attrs = led_trigger_attrs,
79};
80#endif
81
82static struct attribute *led_class_attrs[] = {
83 &dev_attr_brightness.attr,
84 &dev_attr_max_brightness.attr,
85 NULL,
86};
87
88static const struct attribute_group led_group = {
89 .attrs = led_class_attrs,
90};
91
92static const struct attribute_group *led_groups[] = {
93 &led_group,
94#ifdef CONFIG_LEDS_TRIGGERS
95 &led_trigger_group,
74#endif 96#endif
75 __ATTR_NULL, 97 NULL,
76}; 98};
77 99
78static void led_timer_function(unsigned long data) 100static void led_timer_function(unsigned long data)
@@ -258,7 +280,7 @@ static int __init leds_init(void)
258 if (IS_ERR(leds_class)) 280 if (IS_ERR(leds_class))
259 return PTR_ERR(leds_class); 281 return PTR_ERR(leds_class);
260 leds_class->pm = &leds_class_dev_pm_ops; 282 leds_class->pm = &leds_class_dev_pm_ops;
261 leds_class->dev_attrs = led_class_attrs; 283 leds_class->dev_groups = led_groups;
262 return 0; 284 return 0;
263} 285}
264 286