summaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorJosh Wu <josh.wu@atmel.com>2013-09-26 07:27:56 -0400
committerBryan Wu <cooloney@gmail.com>2013-10-25 13:12:55 -0400
commitb0bb83df0a004ff6ef9b1a11784361c9eb63dbf9 (patch)
tree1562001a1f0f5c289b4e841330731f9583d62982 /drivers/leds
parent954e04b9491adea99e4590bc73937fdd8774ab3c (diff)
leds-gpio: of: led should not be created if its status is disabled
now the leds-gpio driver will create every child led node without checking the status is disabled or not. for example, if we have a led node like d3, and its status is disabled: leds { d3 { label = "d3"; gpios = <&pioE 24 0>; status = "disabled"; }; }; we except the d3 should not be created. And the gpios should not be request as well. But current driver will create d3 and request its gpio. This patch fix this by using for_each_available_child_of_node() and of_get_available_child_count() to enumerate all child nodes. So the disabled node will be inavailable. Signed-off-by: Josh Wu <josh.wu@atmel.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/leds-gpio.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 7ccafdeab9c1..78b0e273a903 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -171,11 +171,11 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
171 int count, ret; 171 int count, ret;
172 172
173 /* count LEDs in this device, so we know how much to allocate */ 173 /* count LEDs in this device, so we know how much to allocate */
174 count = of_get_child_count(np); 174 count = of_get_available_child_count(np);
175 if (!count) 175 if (!count)
176 return ERR_PTR(-ENODEV); 176 return ERR_PTR(-ENODEV);
177 177
178 for_each_child_of_node(np, child) 178 for_each_available_child_of_node(np, child)
179 if (of_get_gpio(child, 0) == -EPROBE_DEFER) 179 if (of_get_gpio(child, 0) == -EPROBE_DEFER)
180 return ERR_PTR(-EPROBE_DEFER); 180 return ERR_PTR(-EPROBE_DEFER);
181 181
@@ -184,7 +184,7 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
184 if (!priv) 184 if (!priv)
185 return ERR_PTR(-ENOMEM); 185 return ERR_PTR(-ENOMEM);
186 186
187 for_each_child_of_node(np, child) { 187 for_each_available_child_of_node(np, child) {
188 struct gpio_led led = {}; 188 struct gpio_led led = {};
189 enum of_gpio_flags flags; 189 enum of_gpio_flags flags;
190 const char *state; 190 const char *state;