From: Josh Wu Date: Thu, 26 Sep 2013 11:27:56 +0000 (-0700) Subject: leds-gpio: of: led should not be created if its status is disabled X-Git-Tag: v4.14-rc1~8623^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0bb83df0a004ff6ef9b1a11784361c9eb63dbf9;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Bryan Wu --- diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 7ccafde..78b0e27 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) int count, ret; /* count LEDs in this device, so we know how much to allocate */ - count = of_get_child_count(np); + count = of_get_available_child_count(np); if (!count) return ERR_PTR(-ENODEV); - for_each_child_of_node(np, child) + for_each_available_child_of_node(np, child) if (of_get_gpio(child, 0) == -EPROBE_DEFER) return ERR_PTR(-EPROBE_DEFER); @@ -184,7 +184,7 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev) if (!priv) return ERR_PTR(-ENOMEM); - for_each_child_of_node(np, child) { + for_each_available_child_of_node(np, child) { struct gpio_led led = {}; enum of_gpio_flags flags; const char *state;