Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux.git] / drivers / leds / leds-gpio.c
index e8b01e57348d675cae0821ddb9179b85d92a03f1..57ff20fecf57e16e9963db1692206b923593258f 100644 (file)
  *
  */
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/leds.h>
+#include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/slab.h>
@@ -170,11 +170,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);
 
@@ -183,7 +183,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;
@@ -203,6 +203,9 @@ static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
                                led.default_state = LEDS_GPIO_DEFSTATE_OFF;
                }
 
+               if (of_get_property(child, "retain-state-suspended", NULL))
+                       led.retain_state_suspended = 1;
+
                ret = create_gpio_led(&led, &priv->leds[priv->num_leds++],
                                      &pdev->dev, NULL);
                if (ret < 0) {
@@ -223,6 +226,8 @@ static const struct of_device_id of_gpio_leds_match[] = {
        { .compatible = "gpio-leds", },
        {},
 };
+
+MODULE_DEVICE_TABLE(of, of_gpio_leds_match);
 #else /* CONFIG_OF_GPIO */
 static struct gpio_leds_priv *gpio_leds_create_of(struct platform_device *pdev)
 {