leds.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * LED Core
  3. *
  4. * Copyright 2005 Openedhand Ltd.
  5. *
  6. * Author: Richard Purdie <rpurdie@openedhand.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #ifndef __LEDS_H_INCLUDED
  14. #define __LEDS_H_INCLUDED
  15. #include <linux/rwsem.h>
  16. #include <linux/leds.h>
  17. static inline void led_set_brightness_async(struct led_classdev *led_cdev,
  18. enum led_brightness value)
  19. {
  20. value = min(value, led_cdev->max_brightness);
  21. led_cdev->brightness = value;
  22. if (!(led_cdev->flags & LED_SUSPENDED))
  23. led_cdev->brightness_set(led_cdev, value);
  24. }
  25. static inline int led_set_brightness_sync(struct led_classdev *led_cdev,
  26. enum led_brightness value)
  27. {
  28. int ret = 0;
  29. led_cdev->brightness = min(value, led_cdev->max_brightness);
  30. if (!(led_cdev->flags & LED_SUSPENDED))
  31. ret = led_cdev->brightness_set_sync(led_cdev,
  32. led_cdev->brightness);
  33. return ret;
  34. }
  35. static inline int led_get_brightness(struct led_classdev *led_cdev)
  36. {
  37. return led_cdev->brightness;
  38. }
  39. void led_init_core(struct led_classdev *led_cdev);
  40. void led_stop_software_blink(struct led_classdev *led_cdev);
  41. extern struct rw_semaphore leds_list_lock;
  42. extern struct list_head leds_list;
  43. #endif /* __LEDS_H_INCLUDED */