Lines Matching refs:led_cdev
30 struct led_classdev *led_cdev = dev_get_drvdata(dev); in brightness_show() local
33 led_update_brightness(led_cdev); in brightness_show()
35 return sprintf(buf, "%u\n", led_cdev->brightness); in brightness_show()
41 struct led_classdev *led_cdev = dev_get_drvdata(dev); in brightness_store() local
45 mutex_lock(&led_cdev->led_access); in brightness_store()
47 if (led_sysfs_is_disabled(led_cdev)) { in brightness_store()
57 led_trigger_remove(led_cdev); in brightness_store()
58 led_set_brightness(led_cdev, state); in brightness_store()
59 flush_work(&led_cdev->set_brightness_work); in brightness_store()
63 mutex_unlock(&led_cdev->led_access); in brightness_store()
71 struct led_classdev *led_cdev = dev_get_drvdata(dev); in max_brightness_show() local
73 return sprintf(buf, "%u\n", led_cdev->max_brightness); in max_brightness_show()
110 struct led_classdev *led_cdev = dev_get_drvdata(dev); in brightness_hw_changed_show() local
112 if (led_cdev->brightness_hw_changed == -1) in brightness_hw_changed_show()
115 return sprintf(buf, "%u\n", led_cdev->brightness_hw_changed); in brightness_hw_changed_show()
120 static int led_add_brightness_hw_changed(struct led_classdev *led_cdev) in led_add_brightness_hw_changed() argument
122 struct device *dev = led_cdev->dev; in led_add_brightness_hw_changed()
131 led_cdev->brightness_hw_changed_kn = in led_add_brightness_hw_changed()
133 if (!led_cdev->brightness_hw_changed_kn) { in led_add_brightness_hw_changed()
142 static void led_remove_brightness_hw_changed(struct led_classdev *led_cdev) in led_remove_brightness_hw_changed() argument
144 sysfs_put(led_cdev->brightness_hw_changed_kn); in led_remove_brightness_hw_changed()
145 device_remove_file(led_cdev->dev, &dev_attr_brightness_hw_changed); in led_remove_brightness_hw_changed()
148 void led_classdev_notify_brightness_hw_changed(struct led_classdev *led_cdev, in led_classdev_notify_brightness_hw_changed() argument
151 if (WARN_ON(!led_cdev->brightness_hw_changed_kn)) in led_classdev_notify_brightness_hw_changed()
154 led_cdev->brightness_hw_changed = brightness; in led_classdev_notify_brightness_hw_changed()
155 sysfs_notify_dirent(led_cdev->brightness_hw_changed_kn); in led_classdev_notify_brightness_hw_changed()
159 static int led_add_brightness_hw_changed(struct led_classdev *led_cdev) in led_add_brightness_hw_changed() argument
163 static void led_remove_brightness_hw_changed(struct led_classdev *led_cdev) in led_remove_brightness_hw_changed() argument
172 void led_classdev_suspend(struct led_classdev *led_cdev) in led_classdev_suspend() argument
174 led_cdev->flags |= LED_SUSPENDED; in led_classdev_suspend()
175 led_set_brightness_nopm(led_cdev, 0); in led_classdev_suspend()
176 flush_work(&led_cdev->set_brightness_work); in led_classdev_suspend()
184 void led_classdev_resume(struct led_classdev *led_cdev) in led_classdev_resume() argument
186 led_set_brightness_nopm(led_cdev, led_cdev->brightness); in led_classdev_resume()
188 if (led_cdev->flash_resume) in led_classdev_resume()
189 led_cdev->flash_resume(led_cdev); in led_classdev_resume()
191 led_cdev->flags &= ~LED_SUSPENDED; in led_classdev_resume()
198 struct led_classdev *led_cdev = dev_get_drvdata(dev); in led_suspend() local
200 if (led_cdev->flags & LED_CORE_SUSPENDRESUME) in led_suspend()
201 led_classdev_suspend(led_cdev); in led_suspend()
208 struct led_classdev *led_cdev = dev_get_drvdata(dev); in led_resume() local
210 if (led_cdev->flags & LED_CORE_SUSPENDRESUME) in led_resume()
211 led_classdev_resume(led_cdev); in led_resume()
230 struct led_classdev *led_cdev; in of_led_get() local
243 led_cdev = dev_get_drvdata(led_dev); in of_led_get()
245 if (!try_module_get(led_cdev->dev->parent->driver->owner)) in of_led_get()
248 return led_cdev; in of_led_get()
256 void led_put(struct led_classdev *led_cdev) in led_put() argument
258 module_put(led_cdev->dev->parent->driver->owner); in led_put()
337 struct led_classdev *led_cdev, in led_classdev_register_ext() argument
357 &led_cdev->default_trigger); in led_classdev_register_ext()
359 proposed_name = led_cdev->name; in led_classdev_register_ext()
366 mutex_init(&led_cdev->led_access); in led_classdev_register_ext()
367 mutex_lock(&led_cdev->led_access); in led_classdev_register_ext()
368 led_cdev->dev = device_create_with_groups(leds_class, parent, 0, in led_classdev_register_ext()
369 led_cdev, led_cdev->groups, "%s", final_name); in led_classdev_register_ext()
370 if (IS_ERR(led_cdev->dev)) { in led_classdev_register_ext()
371 mutex_unlock(&led_cdev->led_access); in led_classdev_register_ext()
372 return PTR_ERR(led_cdev->dev); in led_classdev_register_ext()
375 led_cdev->dev->fwnode = init_data->fwnode; in led_classdev_register_ext()
376 led_cdev->dev->of_node = to_of_node(init_data->fwnode); in led_classdev_register_ext()
381 proposed_name, dev_name(led_cdev->dev)); in led_classdev_register_ext()
383 if (led_cdev->flags & LED_BRIGHT_HW_CHANGED) { in led_classdev_register_ext()
384 ret = led_add_brightness_hw_changed(led_cdev); in led_classdev_register_ext()
386 device_unregister(led_cdev->dev); in led_classdev_register_ext()
387 led_cdev->dev = NULL; in led_classdev_register_ext()
388 mutex_unlock(&led_cdev->led_access); in led_classdev_register_ext()
393 led_cdev->work_flags = 0; in led_classdev_register_ext()
395 init_rwsem(&led_cdev->trigger_lock); in led_classdev_register_ext()
398 led_cdev->brightness_hw_changed = -1; in led_classdev_register_ext()
402 list_add_tail(&led_cdev->node, &leds_list); in led_classdev_register_ext()
405 if (!led_cdev->max_brightness) in led_classdev_register_ext()
406 led_cdev->max_brightness = LED_FULL; in led_classdev_register_ext()
408 led_update_brightness(led_cdev); in led_classdev_register_ext()
410 led_init_core(led_cdev); in led_classdev_register_ext()
413 led_trigger_set_default(led_cdev); in led_classdev_register_ext()
416 mutex_unlock(&led_cdev->led_access); in led_classdev_register_ext()
419 led_cdev->name); in led_classdev_register_ext()
431 void led_classdev_unregister(struct led_classdev *led_cdev) in led_classdev_unregister() argument
433 if (IS_ERR_OR_NULL(led_cdev->dev)) in led_classdev_unregister()
437 down_write(&led_cdev->trigger_lock); in led_classdev_unregister()
438 if (led_cdev->trigger) in led_classdev_unregister()
439 led_trigger_set(led_cdev, NULL); in led_classdev_unregister()
440 up_write(&led_cdev->trigger_lock); in led_classdev_unregister()
443 led_cdev->flags |= LED_UNREGISTERING; in led_classdev_unregister()
446 led_stop_software_blink(led_cdev); in led_classdev_unregister()
448 led_set_brightness(led_cdev, LED_OFF); in led_classdev_unregister()
450 flush_work(&led_cdev->set_brightness_work); in led_classdev_unregister()
452 if (led_cdev->flags & LED_BRIGHT_HW_CHANGED) in led_classdev_unregister()
453 led_remove_brightness_hw_changed(led_cdev); in led_classdev_unregister()
455 device_unregister(led_cdev->dev); in led_classdev_unregister()
458 list_del(&led_cdev->node); in led_classdev_unregister()
461 mutex_destroy(&led_cdev->led_access); in led_classdev_unregister()
478 struct led_classdev *led_cdev, in devm_led_classdev_register_ext() argument
488 rc = led_classdev_register_ext(parent, led_cdev, init_data); in devm_led_classdev_register_ext()
494 *dr = led_cdev; in devm_led_classdev_register_ext()
517 struct led_classdev *led_cdev) in devm_led_classdev_unregister() argument
521 devm_led_classdev_match, led_cdev)); in devm_led_classdev_unregister()