diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2018-07-02 16:05:22 -0400 |
---|---|---|
committer | Jacek Anaszewski <jacek.anaszewski@gmail.com> | 2018-07-05 17:21:10 -0400 |
commit | a7e7a3156300a7e1982b03cc9cb8fb0c86434c49 (patch) | |
tree | f3354f80cf210ac750589fecb7a838fc5803d0ec /drivers/leds | |
parent | 2282e125a406e09331c5a785e3df29035c99a607 (diff) |
leds: triggers: add device attribute support
As many triggers use device attributes, add support for these in
led_trigger_set which allows simplifying the drivers accordingly.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/led-triggers.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index a8786f4b3453..3f3e8728d82c 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c | |||
@@ -127,6 +127,7 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) | |||
127 | led_stop_software_blink(led_cdev); | 127 | led_stop_software_blink(led_cdev); |
128 | if (led_cdev->trigger->deactivate) | 128 | if (led_cdev->trigger->deactivate) |
129 | led_cdev->trigger->deactivate(led_cdev); | 129 | led_cdev->trigger->deactivate(led_cdev); |
130 | device_remove_groups(led_cdev->dev, led_cdev->trigger->groups); | ||
130 | led_cdev->trigger = NULL; | 131 | led_cdev->trigger = NULL; |
131 | led_set_brightness(led_cdev, LED_OFF); | 132 | led_set_brightness(led_cdev, LED_OFF); |
132 | } | 133 | } |
@@ -143,6 +144,12 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) | |||
143 | 144 | ||
144 | if (ret) | 145 | if (ret) |
145 | goto err_activate; | 146 | goto err_activate; |
147 | |||
148 | ret = device_add_groups(led_cdev->dev, trig->groups); | ||
149 | if (ret) { | ||
150 | dev_err(led_cdev->dev, "Failed to add trigger attributes\n"); | ||
151 | goto err_add_groups; | ||
152 | } | ||
146 | } | 153 | } |
147 | 154 | ||
148 | if (event) { | 155 | if (event) { |
@@ -156,7 +163,12 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) | |||
156 | 163 | ||
157 | return 0; | 164 | return 0; |
158 | 165 | ||
166 | err_add_groups: | ||
167 | |||
168 | if (trig->deactivate) | ||
169 | trig->deactivate(led_cdev); | ||
159 | err_activate: | 170 | err_activate: |
171 | |||
160 | led_cdev->trigger = NULL; | 172 | led_cdev->trigger = NULL; |
161 | write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags); | 173 | write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags); |
162 | list_del(&led_cdev->trig_list); | 174 | list_del(&led_cdev->trig_list); |