Lines Matching refs:led_cdev
31 trigger_relevant(struct led_classdev *led_cdev, struct led_trigger *trig) in trigger_relevant() argument
33 return !trig->trigger_type || trig->trigger_type == led_cdev->trigger_type; in trigger_relevant()
41 struct led_classdev *led_cdev = dev_get_drvdata(dev); in led_trigger_write() local
45 mutex_lock(&led_cdev->led_access); in led_trigger_write()
47 if (led_sysfs_is_disabled(led_cdev)) { in led_trigger_write()
53 led_trigger_remove(led_cdev); in led_trigger_write()
59 if (sysfs_streq(buf, trig->name) && trigger_relevant(led_cdev, trig)) { in led_trigger_write()
60 down_write(&led_cdev->trigger_lock); in led_trigger_write()
61 led_trigger_set(led_cdev, trig); in led_trigger_write()
62 up_write(&led_cdev->trigger_lock); in led_trigger_write()
73 mutex_unlock(&led_cdev->led_access); in led_trigger_write()
95 struct led_classdev *led_cdev) in led_trigger_format() argument
99 led_cdev->trigger ? "none" : "[none]"); in led_trigger_format()
104 if (!trigger_relevant(led_cdev, trig)) in led_trigger_format()
107 hit = led_cdev->trigger && !strcmp(led_cdev->trigger->name, trig->name); in led_trigger_format()
130 struct led_classdev *led_cdev = dev_get_drvdata(dev); in led_trigger_read() local
135 down_read(&led_cdev->trigger_lock); in led_trigger_read()
137 len = led_trigger_format(NULL, 0, led_cdev); in led_trigger_read()
140 up_read(&led_cdev->trigger_lock); in led_trigger_read()
144 len = led_trigger_format(data, len + 1, led_cdev); in led_trigger_read()
146 up_read(&led_cdev->trigger_lock); in led_trigger_read()
158 int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) in led_trigger_set() argument
165 if (!led_cdev->trigger && !trig) in led_trigger_set()
172 if (led_cdev->trigger) { in led_trigger_set()
173 spin_lock(&led_cdev->trigger->leddev_list_lock); in led_trigger_set()
174 list_del_rcu(&led_cdev->trig_list); in led_trigger_set()
175 spin_unlock(&led_cdev->trigger->leddev_list_lock); in led_trigger_set()
180 cancel_work_sync(&led_cdev->set_brightness_work); in led_trigger_set()
181 led_stop_software_blink(led_cdev); in led_trigger_set()
182 device_remove_groups(led_cdev->dev, led_cdev->trigger->groups); in led_trigger_set()
183 if (led_cdev->trigger->deactivate) in led_trigger_set()
184 led_cdev->trigger->deactivate(led_cdev); in led_trigger_set()
185 led_cdev->trigger = NULL; in led_trigger_set()
186 led_cdev->trigger_data = NULL; in led_trigger_set()
187 led_cdev->activated = false; in led_trigger_set()
188 led_cdev->flags &= ~LED_INIT_DEFAULT_TRIGGER; in led_trigger_set()
189 led_set_brightness(led_cdev, LED_OFF); in led_trigger_set()
193 list_add_tail_rcu(&led_cdev->trig_list, &trig->led_cdevs); in led_trigger_set()
195 led_cdev->trigger = trig; in led_trigger_set()
208 flush_work(&led_cdev->set_brightness_work); in led_trigger_set()
212 ret = trig->activate(led_cdev); in led_trigger_set()
214 led_set_brightness(led_cdev, trig->brightness); in led_trigger_set()
218 ret = device_add_groups(led_cdev->dev, trig->groups); in led_trigger_set()
220 dev_err(led_cdev->dev, "Failed to add trigger attributes\n"); in led_trigger_set()
228 if (kobject_uevent_env(&led_cdev->dev->kobj, KOBJ_CHANGE, envp)) in led_trigger_set()
229 dev_err(led_cdev->dev, in led_trigger_set()
239 trig->deactivate(led_cdev); in led_trigger_set()
242 spin_lock(&led_cdev->trigger->leddev_list_lock); in led_trigger_set()
243 list_del_rcu(&led_cdev->trig_list); in led_trigger_set()
244 spin_unlock(&led_cdev->trigger->leddev_list_lock); in led_trigger_set()
246 led_cdev->trigger = NULL; in led_trigger_set()
247 led_cdev->trigger_data = NULL; in led_trigger_set()
248 led_set_brightness(led_cdev, LED_OFF); in led_trigger_set()
255 void led_trigger_remove(struct led_classdev *led_cdev) in led_trigger_remove() argument
257 down_write(&led_cdev->trigger_lock); in led_trigger_remove()
258 led_trigger_set(led_cdev, NULL); in led_trigger_remove()
259 up_write(&led_cdev->trigger_lock); in led_trigger_remove()
263 static bool led_match_default_trigger(struct led_classdev *led_cdev, in led_match_default_trigger() argument
266 if (!strcmp(led_cdev->default_trigger, trig->name) && in led_match_default_trigger()
267 trigger_relevant(led_cdev, trig)) { in led_match_default_trigger()
268 led_cdev->flags |= LED_INIT_DEFAULT_TRIGGER; in led_match_default_trigger()
269 led_trigger_set(led_cdev, trig); in led_match_default_trigger()
276 void led_trigger_set_default(struct led_classdev *led_cdev) in led_trigger_set_default() argument
281 if (!led_cdev->default_trigger) in led_trigger_set_default()
285 down_write(&led_cdev->trigger_lock); in led_trigger_set_default()
287 found = led_match_default_trigger(led_cdev, trig); in led_trigger_set_default()
291 up_write(&led_cdev->trigger_lock); in led_trigger_set_default()
299 request_module_nowait("ledtrig:%s", led_cdev->default_trigger); in led_trigger_set_default()
307 struct led_classdev *led_cdev; in led_trigger_register() local
329 list_for_each_entry(led_cdev, &leds_list, node) { in led_trigger_register()
330 down_write(&led_cdev->trigger_lock); in led_trigger_register()
331 if (!led_cdev->trigger && led_cdev->default_trigger) in led_trigger_register()
332 led_match_default_trigger(led_cdev, trig); in led_trigger_register()
333 up_write(&led_cdev->trigger_lock); in led_trigger_register()
343 struct led_classdev *led_cdev; in led_trigger_unregister() local
355 list_for_each_entry(led_cdev, &leds_list, node) { in led_trigger_unregister()
356 down_write(&led_cdev->trigger_lock); in led_trigger_unregister()
357 if (led_cdev->trigger == trig) in led_trigger_unregister()
358 led_trigger_set(led_cdev, NULL); in led_trigger_unregister()
359 up_write(&led_cdev->trigger_lock); in led_trigger_unregister()
398 struct led_classdev *led_cdev; in led_trigger_event() local
406 list_for_each_entry_rcu(led_cdev, &trig->led_cdevs, trig_list) in led_trigger_event()
407 led_set_brightness(led_cdev, brightness); in led_trigger_event()
416 struct led_classdev *led_cdev; in led_mc_trigger_event() local
422 list_for_each_entry_rcu(led_cdev, &trig->led_cdevs, trig_list) { in led_mc_trigger_event()
423 if (!(led_cdev->flags & LED_MULTI_COLOR)) in led_mc_trigger_event()
426 led_mc_set_brightness(led_cdev, intensity_value, num_colors, brightness); in led_mc_trigger_event()
438 struct led_classdev *led_cdev; in led_trigger_blink_setup() local
444 list_for_each_entry_rcu(led_cdev, &trig->led_cdevs, trig_list) { in led_trigger_blink_setup()
446 led_blink_set_oneshot(led_cdev, &delay_on, &delay_off, in led_trigger_blink_setup()
449 led_blink_set_nosleep(led_cdev, delay_on, delay_off); in led_trigger_blink_setup()