Commit 0493a4ff authored by Anton Vorontsov's avatar Anton Vorontsov Committed by Richard Purdie

leds-gpio: fix default state handling on OF platforms

The driver wrongly sets default state for LEDs that don't specify
default-state property.

Currently the driver handles default state this way:

memset(&led, 0, sizeof(led));
for_each_child_of_node(np, child) {
	state = of_get_property(child, "default-state", NULL);
	if (state) {
		if (!strcmp(state, "keep"))
			led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
		...
	}
	ret = create_gpio_led(&led, ...);
}

Which means that all LEDs that do not specify default-state will inherit
the last value of the default-state property, which is wrong.

This patch fixes the issue by moving LED's template initialization into
the loop body.
Signed-off-by: default avatarAnton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarRichard Purdie <rpurdie@linux.intel.com>
parent 72dcd8d0
...@@ -211,7 +211,6 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev, ...@@ -211,7 +211,6 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev,
const struct of_device_id *match) const struct of_device_id *match)
{ {
struct device_node *np = ofdev->node, *child; struct device_node *np = ofdev->node, *child;
struct gpio_led led;
struct gpio_led_of_platform_data *pdata; struct gpio_led_of_platform_data *pdata;
int count = 0, ret; int count = 0, ret;
...@@ -226,8 +225,8 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev, ...@@ -226,8 +225,8 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev,
if (!pdata) if (!pdata)
return -ENOMEM; return -ENOMEM;
memset(&led, 0, sizeof(led));
for_each_child_of_node(np, child) { for_each_child_of_node(np, child) {
struct gpio_led led = {};
enum of_gpio_flags flags; enum of_gpio_flags flags;
const char *state; const char *state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment