]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
leds: enable support for blink_set() platform hook in leds-gpio
authorHerbert Valerio Riedel <hvr@gnu.org>
Sun, 9 Mar 2008 23:48:25 +0000 (23:48 +0000)
committerRichard Purdie <rpurdie@rpsys.net>
Thu, 24 Apr 2008 22:37:42 +0000 (23:37 +0100)
Enhance leds-gpio to provide hardware-based led flashing by passing
through the blink_set() call to a optionally set platform-specific
function pointer.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
drivers/leds/leds-gpio.c
include/linux/leds.h

index 1aae8b3321349e53802a280d402a36ff1e82d2c3..b13bd2950e956347b98bac9ed76e18efcabed612 100644 (file)
@@ -24,6 +24,8 @@ struct gpio_led_data {
        u8 new_level;
        u8 can_sleep;
        u8 active_low;
+       int (*platform_gpio_blink_set)(unsigned gpio,
+                       unsigned long *delay_on, unsigned long *delay_off);
 };
 
 static void gpio_led_work(struct work_struct *work)
@@ -60,6 +62,15 @@ static void gpio_led_set(struct led_classdev *led_cdev,
                gpio_set_value(led_dat->gpio, level);
 }
 
+static int gpio_blink_set(struct led_classdev *led_cdev,
+       unsigned long *delay_on, unsigned long *delay_off)
+{
+       struct gpio_led_data *led_dat =
+               container_of(led_cdev, struct gpio_led_data, cdev);
+
+       return led_dat->platform_gpio_blink_set(led_dat->gpio, delay_on, delay_off);
+}
+
 static int gpio_led_probe(struct platform_device *pdev)
 {
        struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
@@ -88,6 +99,10 @@ static int gpio_led_probe(struct platform_device *pdev)
                led_dat->gpio = cur_led->gpio;
                led_dat->can_sleep = gpio_cansleep(cur_led->gpio);
                led_dat->active_low = cur_led->active_low;
+               if (pdata->gpio_blink_set) {
+                       led_dat->platform_gpio_blink_set = pdata->gpio_blink_set;
+                       led_dat->cdev.blink_set = gpio_blink_set;
+               }
                led_dat->cdev.brightness_set = gpio_led_set;
                led_dat->cdev.brightness = LED_OFF;
 
index b07e3d400bd6b6ad91d2465a76285fc80b6b444d..c195a674b6ca0b17a11a827a42d7788e34951879 100644 (file)
@@ -126,6 +126,9 @@ struct gpio_led {
 struct gpio_led_platform_data {
        int             num_leds;
        struct gpio_led *leds;
+       int             (*gpio_blink_set)(unsigned gpio,
+                                       unsigned long *delay_on,
+                                       unsigned long *delay_off);
 };