The leds-gpio driver initialises all LEDs in the OFF state, however it 
incorrectly sets the "brightness" value to 255 (LED_FULL) for LEDs which are 
".active_low". This results in the LED being off at initialisation, but the 
/sys/class/leds/xxxx/brightness value being 255 instead of 0.

The attached patch corrects this and also allows each LED to be initialised in 
the ON state via ".default_trigger". The patch has been developed against AR7 
but will work for any targets that use "leds-gpio", and should go in the 
relevant "patches" folder ("patches-2.6.23" for AR7).

Signed-off-by: Nick Forbes <[EMAIL PROTECTED]>

-------------------
150-leds-gpio.patch
-------------------
--- linux-2.6.23.1/drivers/leds/leds-gpio.c     2007-10-12 17:43:44.000000000 
+0100
+++ linux-2.6.23.1/drivers/leds/leds-gpio.c     2008-01-10 10:34:13.000000000 
+0000
@@ -65,7 +65,7 @@
        struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
        struct gpio_led *cur_led;
        struct gpio_led_data *leds_data, *led_dat;
-       int i, ret = 0;
+       int i, init_state, ret = 0;
 
        if (!pdata)
                return -EBUSY;
@@ -80,18 +80,21 @@
                led_dat = &leds_data[i];
 
                led_dat->cdev.name = cur_led->name;
+               /* Ugly hack but there is no existing trigger to support this 
at present */
+               init_state = (cur_led->default_trigger == "on") ? 1 : 0; 
                led_dat->cdev.default_trigger = cur_led->default_trigger;
                led_dat->gpio = cur_led->gpio;
                led_dat->can_sleep = gpio_cansleep(cur_led->gpio);
                led_dat->active_low = cur_led->active_low;
                led_dat->cdev.brightness_set = gpio_led_set;
-               led_dat->cdev.brightness = cur_led->active_low ? LED_FULL : 
LED_OFF;
+               led_dat->cdev.brightness = init_state ? LED_FULL : LED_OFF;
 
                ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
                if (ret < 0)
                        goto err;
 
-               gpio_direction_output(led_dat->gpio, led_dat->active_low);
+               init_state ^= led_dat->active_low;
+               gpio_direction_output(led_dat->gpio, init_state);
 
                ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
                if (ret < 0) {






_____________________________________________

Huntsworth is a world class communications group with public relations at its 
core, global in scale but rooted in domestic excellence.

We house some of the world's leading PR agencies and offer expertise across a 
number of sectors including: consumer, finance, public affairs and technology 
together with an integrated healthcare offer.

For more information visit our website www.huntsworth.com

Huntsworth plc is registered in England No 1729478. Registered office is 15-17 
Huntsworth Mews, London NW1 6DD

_____________________________________________________________________
Virus Checked for Huntsworth plc group of companies
_____________________________________________________________________

Attachment: 150-leds-gpio.patch
Description: 150-leds-gpio.patch

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to