xref: /openbmc/linux/drivers/leds/leds.h (revision d23a22a74fded23a12434c9463fe66cec2b0afcd)
1c72a1d60SRichard Purdie /*
2c72a1d60SRichard Purdie  * LED Core
3c72a1d60SRichard Purdie  *
4c72a1d60SRichard Purdie  * Copyright 2005 Openedhand Ltd.
5c72a1d60SRichard Purdie  *
6c72a1d60SRichard Purdie  * Author: Richard Purdie <rpurdie@openedhand.com>
7c72a1d60SRichard Purdie  *
8c72a1d60SRichard Purdie  * This program is free software; you can redistribute it and/or modify
9c72a1d60SRichard Purdie  * it under the terms of the GNU General Public License version 2 as
10c72a1d60SRichard Purdie  * published by the Free Software Foundation.
11c72a1d60SRichard Purdie  *
12c72a1d60SRichard Purdie  */
13c72a1d60SRichard Purdie #ifndef __LEDS_H_INCLUDED
14c72a1d60SRichard Purdie #define __LEDS_H_INCLUDED
15c72a1d60SRichard Purdie 
16f8a7c6feSRichard Purdie #include <linux/device.h>
1772f8da32SRichard Purdie #include <linux/rwsem.h>
18c72a1d60SRichard Purdie #include <linux/leds.h>
19c72a1d60SRichard Purdie 
200da3e65bSShuah Khan static inline void __led_set_brightness(struct led_classdev *led_cdev,
21c72a1d60SRichard Purdie 					enum led_brightness value)
22c72a1d60SRichard Purdie {
231bd465e6SGuennadi Liakhovetski 	if (value > led_cdev->max_brightness)
241bd465e6SGuennadi Liakhovetski 		value = led_cdev->max_brightness;
25c72a1d60SRichard Purdie 	led_cdev->brightness = value;
26c72a1d60SRichard Purdie 	if (!(led_cdev->flags & LED_SUSPENDED))
27c72a1d60SRichard Purdie 		led_cdev->brightness_set(led_cdev, value);
28c72a1d60SRichard Purdie }
29c72a1d60SRichard Purdie 
300013b23dSNémeth Márton static inline int led_get_brightness(struct led_classdev *led_cdev)
310013b23dSNémeth Márton {
320013b23dSNémeth Márton 	return led_cdev->brightness;
330013b23dSNémeth Márton }
340013b23dSNémeth Márton 
35*d23a22a7SFabio Baltieri void led_stop_software_blink(struct led_classdev *led_cdev);
36*d23a22a7SFabio Baltieri 
3772f8da32SRichard Purdie extern struct rw_semaphore leds_list_lock;
38c72a1d60SRichard Purdie extern struct list_head leds_list;
39c72a1d60SRichard Purdie 
40c3bc9956SRichard Purdie #ifdef CONFIG_LEDS_TRIGGERS
41c3bc9956SRichard Purdie void led_trigger_set_default(struct led_classdev *led_cdev);
42c3bc9956SRichard Purdie void led_trigger_set(struct led_classdev *led_cdev,
43c3bc9956SRichard Purdie 			struct led_trigger *trigger);
440013b23dSNémeth Márton void led_trigger_remove(struct led_classdev *led_cdev);
45fff26f81SEsben Haabendal 
46fff26f81SEsben Haabendal static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
47fff26f81SEsben Haabendal {
48fff26f81SEsben Haabendal 	return led_cdev->trigger_data;
49fff26f81SEsben Haabendal }
50fff26f81SEsben Haabendal 
51c3bc9956SRichard Purdie #else
52c3bc9956SRichard Purdie #define led_trigger_set_default(x) do {} while (0)
53c3bc9956SRichard Purdie #define led_trigger_set(x, y) do {} while (0)
540013b23dSNémeth Márton #define led_trigger_remove(x) do {} while (0)
55fff26f81SEsben Haabendal #define led_get_trigger_data(x) (NULL)
56c3bc9956SRichard Purdie #endif
57c3bc9956SRichard Purdie 
58f8a7c6feSRichard Purdie ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
59f8a7c6feSRichard Purdie 			const char *buf, size_t count);
60f8a7c6feSRichard Purdie ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
61f8a7c6feSRichard Purdie 			char *buf);
62c3bc9956SRichard Purdie 
63c72a1d60SRichard Purdie #endif	/* __LEDS_H_INCLUDED */
64