]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: gpio: sandbox: Use dev_read...() functions to access DT
authorSimon Glass <sjg@chromium.org>
Fri, 19 May 2017 02:09:20 +0000 (20:09 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 1 Jun 2017 13:03:10 +0000 (07:03 -0600)
Use the new dev_read...() functions to access the device tree, so that a
live tree can be used.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/gpio/sandbox.c

index 0f22acb0e677acfe209677bfe0d1aeed155bd0e9..4f7b62eba0ddc420acd0ea2e8903e6a58968ff37 100644 (file)
@@ -198,10 +198,8 @@ static int sandbox_gpio_ofdata_to_platdata(struct udevice *dev)
 {
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-       uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
-                                            "num-gpios", 0);
-       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
-                                        "gpio-bank-name", NULL);
+       uc_priv->gpio_count = dev_read_u32_default(dev, "num-gpios", 0);
+       uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name");
 
        return 0;
 }
@@ -210,10 +208,9 @@ static int gpio_sandbox_probe(struct udevice *dev)
 {
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-       if (dev_of_offset(dev) == -1) {
+       if (!dev_of_valid(dev))
                /* Tell the uclass how many GPIOs we have */
                uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT;
-       }
 
        dev->priv = calloc(sizeof(struct gpio_state), uc_priv->gpio_count);