blob: dbb9a361072ea5c32b48107c471627a3c1739483 [file] [log] [blame]
Richard Purdiec72a1d62006-03-31 02:31:04 -08001/*
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 Purdie72f8da32007-12-31 23:09:44 +000016#include <linux/rwsem.h>
Richard Purdiec72a1d62006-03-31 02:31:04 -080017#include <linux/leds.h>
18
Németh Márton0013b232008-03-09 20:54:37 +000019static inline int led_get_brightness(struct led_classdev *led_cdev)
20{
21 return led_cdev->brightness;
22}
23
David Collins8885f792017-01-26 14:36:34 -080024static 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 Anaszewski757b06a2015-09-28 14:38:04 +020040void led_init_core(struct led_classdev *led_cdev);
Fabio Baltierid23a22a2012-08-15 21:44:34 +080041void led_stop_software_blink(struct led_classdev *led_cdev);
Jacek Anaszewski81fe8e52015-10-07 11:10:41 +020042void led_set_brightness_nopm(struct led_classdev *led_cdev,
43 enum led_brightness value);
44void led_set_brightness_nosleep(struct led_classdev *led_cdev,
45 enum led_brightness value);
Fabio Baltierid23a22a2012-08-15 21:44:34 +080046
Richard Purdie72f8da32007-12-31 23:09:44 +000047extern struct rw_semaphore leds_list_lock;
Richard Purdiec72a1d62006-03-31 02:31:04 -080048extern struct list_head leds_list;
Ezequiel Garciaba93cdc2016-04-28 19:03:38 -030049extern struct list_head trigger_list;
Richard Purdiec72a1d62006-03-31 02:31:04 -080050
Richard Purdiec72a1d62006-03-31 02:31:04 -080051#endif /* __LEDS_H_INCLUDED */