Commit 5baa7503a7a0b8d65308ff3b2ab887bf343c65d3
1 parent
d98259cbf9
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
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>
Showing 1 changed file with 30 additions and 8 deletions Side-by-side Diff
drivers/leds/led-class.c
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | led_cdev->brightness = led_cdev->brightness_get(led_cdev); |
30 | 30 | } |
31 | 31 | |
32 | -static ssize_t led_brightness_show(struct device *dev, | |
32 | +static ssize_t brightness_show(struct device *dev, | |
33 | 33 | struct device_attribute *attr, char *buf) |
34 | 34 | { |
35 | 35 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | return sprintf(buf, "%u\n", led_cdev->brightness); |
41 | 41 | } |
42 | 42 | |
43 | -static ssize_t led_brightness_store(struct device *dev, | |
43 | +static ssize_t brightness_store(struct device *dev, | |
44 | 44 | struct device_attribute *attr, const char *buf, size_t size) |
45 | 45 | { |
46 | 46 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
... | ... | @@ -57,6 +57,7 @@ |
57 | 57 | |
58 | 58 | return size; |
59 | 59 | } |
60 | +static DEVICE_ATTR_RW(brightness); | |
60 | 61 | |
61 | 62 | static ssize_t led_max_brightness_show(struct device *dev, |
62 | 63 | struct device_attribute *attr, char *buf) |
63 | 64 | |
64 | 65 | |
65 | 66 | |
66 | 67 | |
... | ... | @@ -65,16 +66,37 @@ |
65 | 66 | |
66 | 67 | return sprintf(buf, "%u\n", led_cdev->max_brightness); |
67 | 68 | } |
69 | +static DEVICE_ATTR(max_brightness, 0444, led_max_brightness_show, NULL); | |
68 | 70 | |
69 | -static 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 | 71 | #ifdef CONFIG_LEDS_TRIGGERS |
73 | - __ATTR(trigger, 0644, led_trigger_show, led_trigger_store), | |
72 | +static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store); | |
73 | +static struct attribute *led_trigger_attrs[] = { | |
74 | + &dev_attr_trigger.attr, | |
75 | + NULL, | |
76 | +}; | |
77 | +static const struct attribute_group led_trigger_group = { | |
78 | + .attrs = led_trigger_attrs, | |
79 | +}; | |
74 | 80 | #endif |
75 | - __ATTR_NULL, | |
81 | + | |
82 | +static struct attribute *led_class_attrs[] = { | |
83 | + &dev_attr_brightness.attr, | |
84 | + &dev_attr_max_brightness.attr, | |
85 | + NULL, | |
76 | 86 | }; |
77 | 87 | |
88 | +static const struct attribute_group led_group = { | |
89 | + .attrs = led_class_attrs, | |
90 | +}; | |
91 | + | |
92 | +static const struct attribute_group *led_groups[] = { | |
93 | + &led_group, | |
94 | +#ifdef CONFIG_LEDS_TRIGGERS | |
95 | + &led_trigger_group, | |
96 | +#endif | |
97 | + NULL, | |
98 | +}; | |
99 | + | |
78 | 100 | static void led_timer_function(unsigned long data) |
79 | 101 | { |
80 | 102 | struct led_classdev *led_cdev = (void *)data; |
... | ... | @@ -258,7 +280,7 @@ |
258 | 280 | if (IS_ERR(leds_class)) |
259 | 281 | return PTR_ERR(leds_class); |
260 | 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 | 284 | return 0; |
263 | 285 | } |
264 | 286 |