led: add initial support for bcm6858
[oweals/u-boot.git] / drivers / led / led_gpio.c
index 4106ecb6799b163bd8eec2b6dc560c1ebeb89cec..93f6b913c6477de33a82387f8c24c95bd2faa53f 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2015 Google, Inc
  * Written by Simon Glass <sjg@chromium.org>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -12,8 +11,6 @@
 #include <asm/gpio.h>
 #include <dm/lists.h>
 
-DECLARE_GLOBAL_DATA_PTR;
-
 struct led_gpio_priv {
        struct gpio_desc gpio;
 };
@@ -60,11 +57,17 @@ static int led_gpio_probe(struct udevice *dev)
 {
        struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
        struct led_gpio_priv *priv = dev_get_priv(dev);
+       int ret;
 
        /* Ignore the top-level LED node */
        if (!uc_plat->label)
                return 0;
-       return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
+
+       ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
+       if (ret)
+               return ret;
+
+       return 0;
 }
 
 static int led_gpio_remove(struct udevice *dev)
@@ -85,25 +88,22 @@ static int led_gpio_remove(struct udevice *dev)
 
 static int led_gpio_bind(struct udevice *parent)
 {
-       const void *blob = gd->fdt_blob;
        struct udevice *dev;
-       int node;
+       ofnode node;
        int ret;
 
-       for (node = fdt_first_subnode(blob, dev_of_offset(parent));
-            node > 0;
-            node = fdt_next_subnode(blob, node)) {
+       dev_for_each_subnode(node, parent) {
                struct led_uc_plat *uc_plat;
                const char *label;
 
-               label = fdt_getprop(blob, node, "label", NULL);
+               label = ofnode_read_string(node, "label");
                if (!label) {
                        debug("%s: node %s has no label\n", __func__,
-                             fdt_get_name(blob, node, NULL));
+                             ofnode_get_name(node));
                        return -EINVAL;
                }
                ret = device_bind_driver_to_node(parent, "gpio_led",
-                                                fdt_get_name(blob, node, NULL),
+                                                ofnode_get_name(node),
                                                 node, &dev);
                if (ret)
                        return ret;