summaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2014-10-31 13:40:58 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-11-04 21:58:25 +0100
commitc673a2b4008103525a3cf21bedf15ffac37bfef0 (patch)
tree66ab68fab43ca9311a0eef5ddec307d332735510 /drivers/leds
parente36d453e98c57dda0f8ba68585676ac4ba36631e (diff)
downloadlinux-stable-c673a2b4008103525a3cf21bedf15ffac37bfef0.tar.gz
linux-stable-c673a2b4008103525a3cf21bedf15ffac37bfef0.tar.bz2
linux-stable-c673a2b4008103525a3cf21bedf15ffac37bfef0.zip
leds: leds-gpio: Convert gpio_blink_set() to use GPIO descriptors
Commit 21f2aae91e902aad ("leds: leds-gpio: Add support for GPIO descriptors") already converted most of the driver to use GPIO descriptors. What is still missing is the platform specific hook gpio_blink_set() and board files which pass legacy GPIO numbers to this driver in platform data. In this patch we handle the former and convert gpio_blink_set() to take GPIO descriptor instead. In order to do this we convert the existing four users to accept GPIO descriptor and translate it to legacy GPIO number in the platform code. This effectively "pushes" legacy GPIO number usage from the driver to platforms. Also add comment to the remaining block describing that it is legacy code path and we are getting rid of it eventually. Suggested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-gpio.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index edd370dbb22f..ba4698c32bb0 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -28,7 +28,7 @@ struct gpio_led_data {
u8 new_level;
u8 can_sleep;
u8 blinking;
- int (*platform_gpio_blink_set)(unsigned gpio, int state,
+ int (*platform_gpio_blink_set)(struct gpio_desc *desc, int state,
unsigned long *delay_on, unsigned long *delay_off);
};
@@ -38,13 +38,8 @@ static void gpio_led_work(struct work_struct *work)
container_of(work, struct gpio_led_data, work);
if (led_dat->blinking) {
- int gpio = desc_to_gpio(led_dat->gpiod);
- int level = led_dat->new_level;
-
- if (gpiod_is_active_low(led_dat->gpiod))
- level = !level;
-
- led_dat->platform_gpio_blink_set(gpio, level, NULL, NULL);
+ led_dat->platform_gpio_blink_set(led_dat->gpiod,
+ led_dat->new_level, NULL, NULL);
led_dat->blinking = 0;
} else
gpiod_set_value_cansleep(led_dat->gpiod, led_dat->new_level);
@@ -71,13 +66,8 @@ static void gpio_led_set(struct led_classdev *led_cdev,
schedule_work(&led_dat->work);
} else {
if (led_dat->blinking) {
- int gpio = desc_to_gpio(led_dat->gpiod);
-
- if (gpiod_is_active_low(led_dat->gpiod))
- level = !level;
-
- led_dat->platform_gpio_blink_set(gpio, level, NULL,
- NULL);
+ led_dat->platform_gpio_blink_set(led_dat->gpiod, level,
+ NULL, NULL);
led_dat->blinking = 0;
} else
gpiod_set_value(led_dat->gpiod, level);
@@ -89,20 +79,25 @@ static int gpio_blink_set(struct led_classdev *led_cdev,
{
struct gpio_led_data *led_dat =
container_of(led_cdev, struct gpio_led_data, cdev);
- int gpio = desc_to_gpio(led_dat->gpiod);
led_dat->blinking = 1;
- return led_dat->platform_gpio_blink_set(gpio, GPIO_LED_BLINK,
+ return led_dat->platform_gpio_blink_set(led_dat->gpiod, GPIO_LED_BLINK,
delay_on, delay_off);
}
static int create_gpio_led(const struct gpio_led *template,
struct gpio_led_data *led_dat, struct device *parent,
- int (*blink_set)(unsigned, int, unsigned long *, unsigned long *))
+ int (*blink_set)(struct gpio_desc *, int, unsigned long *,
+ unsigned long *))
{
int ret, state;
if (!template->gpiod) {
+ /*
+ * This is the legacy code path for platform code that
+ * still uses GPIO numbers. Ultimately we would like to get
+ * rid of this block completely.
+ */
unsigned long flags = 0;
/* skip leds that aren't available */