brcm2708: update 4.1 patches
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0123-leds-gpio-Implement-the-brightness_get-method.patch
1 From b0482b8fe870cfc43e4f9a00470b267f27900ce7 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Wed, 15 Jul 2015 13:46:08 +0100
4 Subject: [PATCH 123/148] leds-gpio: Implement the brightness_get method
5
6 The power LED uses some clever logic that means it is driven
7 by a voltage measuring circuit when configured as input, otherwise
8 it is driven by the GPIO output value. This patch wires up the
9 brightness_get method for leds-gpio so that user-space can monitor
10 the LED value via /sys/class/gpio/led1/brightness. Using the input
11 trigger this returns an indication of the system power health,
12 otherwise it is just whatever value the trigger has written most
13 recently.
14
15 See: https://github.com/raspberrypi/linux/issues/1064
16 ---
17 drivers/leds/leds-gpio.c | 8 ++++++++
18 1 file changed, 8 insertions(+)
19
20 --- a/drivers/leds/leds-gpio.c
21 +++ b/drivers/leds/leds-gpio.c
22 @@ -82,6 +82,13 @@ static void gpio_led_set(struct led_clas
23 }
24 }
25
26 +static enum led_brightness gpio_led_get(struct led_classdev *led_cdev)
27 +{
28 + struct gpio_led_data *led_dat =
29 + container_of(led_cdev, struct gpio_led_data, cdev);
30 + return gpiod_get_value_cansleep(led_dat->gpiod) ? LED_FULL : LED_OFF;
31 +}
32 +
33 static int gpio_blink_set(struct led_classdev *led_cdev,
34 unsigned long *delay_on, unsigned long *delay_off)
35 {
36 @@ -138,6 +145,7 @@ static int create_gpio_led(const struct
37 led_dat->cdev.blink_set = gpio_blink_set;
38 }
39 led_dat->cdev.brightness_set = gpio_led_set;
40 + led_dat->cdev.brightness_get = gpio_led_get;
41 if (template->default_state == LEDS_GPIO_DEFSTATE_KEEP)
42 state = !!gpiod_get_value_cansleep(led_dat->gpiod);
43 else