Richard Purdie | c72a1d6 | 2006-03-31 02:31:04 -0800 | [diff] [blame] | 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 | |
Richard Purdie | 72f8da3 | 2007-12-31 23:09:44 +0000 | [diff] [blame] | 16 | #include <linux/rwsem.h> |
Richard Purdie | c72a1d6 | 2006-03-31 02:31:04 -0800 | [diff] [blame] | 17 | #include <linux/leds.h> |
| 18 | |
Németh Márton | 0013b23 | 2008-03-09 20:54:37 +0000 | [diff] [blame] | 19 | static inline int led_get_brightness(struct led_classdev *led_cdev) |
| 20 | { |
| 21 | return led_cdev->brightness; |
| 22 | } |
| 23 | |
David Collins | 8885f79 | 2017-01-26 14:36:34 -0800 | [diff] [blame] | 24 | static inline struct led_classdev *trigger_to_lcdev(struct led_trigger *trig) |
| 25 | { |
| 26 | struct led_classdev *led_cdev; |
| 27 | |
| 28 | read_lock(&trig->leddev_list_lock); |
| 29 | list_for_each_entry(led_cdev, &trig->led_cdevs, trig_list) { |
| 30 | if (!strcmp(led_cdev->default_trigger, trig->name)) { |
| 31 | read_unlock(&trig->leddev_list_lock); |
| 32 | return led_cdev; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | read_unlock(&trig->leddev_list_lock); |
| 37 | return NULL; |
| 38 | } |
| 39 | |
Jacek Anaszewski | 757b06a | 2015-09-28 14:38:04 +0200 | [diff] [blame] | 40 | void led_init_core(struct led_classdev *led_cdev); |
Fabio Baltieri | d23a22a | 2012-08-15 21:44:34 +0800 | [diff] [blame] | 41 | void led_stop_software_blink(struct led_classdev *led_cdev); |
Jacek Anaszewski | 81fe8e5 | 2015-10-07 11:10:41 +0200 | [diff] [blame] | 42 | void led_set_brightness_nopm(struct led_classdev *led_cdev, |
| 43 | enum led_brightness value); |
| 44 | void led_set_brightness_nosleep(struct led_classdev *led_cdev, |
| 45 | enum led_brightness value); |
Fabio Baltieri | d23a22a | 2012-08-15 21:44:34 +0800 | [diff] [blame] | 46 | |
Richard Purdie | 72f8da3 | 2007-12-31 23:09:44 +0000 | [diff] [blame] | 47 | extern struct rw_semaphore leds_list_lock; |
Richard Purdie | c72a1d6 | 2006-03-31 02:31:04 -0800 | [diff] [blame] | 48 | extern struct list_head leds_list; |
Ezequiel Garcia | ba93cdc | 2016-04-28 19:03:38 -0300 | [diff] [blame] | 49 | extern struct list_head trigger_list; |
Richard Purdie | c72a1d6 | 2006-03-31 02:31:04 -0800 | [diff] [blame] | 50 | |
Richard Purdie | c72a1d6 | 2006-03-31 02:31:04 -0800 | [diff] [blame] | 51 | #endif /* __LEDS_H_INCLUDED */ |