summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPhil Elwell <phil@raspberrypi.org>2015-02-12 11:17:53 +0000
committerpopcornmix <popcornmix@gmail.com>2015-05-18 14:11:50 +0100
commitb3b824bd1a1e0a9fd5ca834624a203391cbf7b4e (patch)
treef6c774cbd1e57d81488b3f910ed11895f935cdbe /drivers
parent0e2bf64dfa73e3b03f9600989024d7313d06912b (diff)
downloadlinux-b3b824bd1a1e0a9fd5ca834624a203391cbf7b4e.tar.gz
Fix LED "input" trigger implementation for 3.19
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/leds-gpio.c10
-rw-r--r--drivers/leds/trigger/ledtrig-input.c19
2 files changed, 13 insertions, 16 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index d26af0a79a90..9e49c72b243e 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -41,6 +41,13 @@ static void gpio_led_work(struct work_struct *work)
led_dat->platform_gpio_blink_set(led_dat->gpiod,
led_dat->new_level, NULL, NULL);
led_dat->blinking = 0;
+ } else if (led_dat->cdev.flags & SET_GPIO_INPUT) {
+ gpiod_direction_input(led_dat->gpiod);
+ led_dat->cdev.flags &= ~SET_GPIO_INPUT;
+ }
+ else if (led_dat->cdev.flags & SET_GPIO_OUTPUT) {
+ gpiod_direction_output(led_dat->gpiod, led_dat->new_level);
+ led_dat->cdev.flags &= ~SET_GPIO_OUTPUT;
} else
gpiod_set_value_cansleep(led_dat->gpiod, led_dat->new_level);
}
@@ -61,7 +68,8 @@ static void gpio_led_set(struct led_classdev *led_cdev,
* seem to have a reliable way to know if we're already in one; so
* let's just assume the worst.
*/
- if (led_dat->can_sleep) {
+ if (led_dat->can_sleep ||
+ (led_dat->cdev.flags & (SET_GPIO_INPUT | SET_GPIO_OUTPUT) )) {
led_dat->new_level = level;
schedule_work(&led_dat->work);
} else {
diff --git a/drivers/leds/trigger/ledtrig-input.c b/drivers/leds/trigger/ledtrig-input.c
index 2ca2b98bdc95..07d12197e340 100644
--- a/drivers/leds/trigger/ledtrig-input.c
+++ b/drivers/leds/trigger/ledtrig-input.c
@@ -18,27 +18,16 @@
#include <linux/gpio.h>
#include "../leds.h"
-/* This is a hack to get at the private 'gpio' member */
-
-struct gpio_led_data {
- struct led_classdev cdev;
- unsigned gpio;
-};
-
static void input_trig_activate(struct led_classdev *led_cdev)
{
- struct gpio_led_data *led_dat =
- container_of(led_cdev, struct gpio_led_data, cdev);
- if (gpio_is_valid(led_dat->gpio))
- gpio_direction_input(led_dat->gpio);
+ led_cdev->flags |= SET_GPIO_INPUT;
+ led_set_brightness_async(led_cdev, 0);
}
static void input_trig_deactivate(struct led_classdev *led_cdev)
{
- struct gpio_led_data *led_dat =
- container_of(led_cdev, struct gpio_led_data, cdev);
- if (gpio_is_valid(led_dat->gpio))
- gpio_direction_output(led_dat->gpio, 0);
+ led_cdev->flags |= SET_GPIO_OUTPUT;
+ led_set_brightness_async(led_cdev, 0);
}
static struct led_trigger input_led_trigger = {