]> git.sur5r.net Git - u-boot/commitdiff
dm: core: Replace of_offset with accessor (part 2)
authorSimon Glass <sjg@chromium.org>
Wed, 17 May 2017 23:18:09 +0000 (17:18 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 1 Jun 2017 13:03:04 +0000 (07:03 -0600)
At present devices use a simple integer offset to record the device tree
node associated with the device. In preparation for supporting a live
device tree, which uses a node pointer instead, refactor existing code to
access this field through an inline function.

Signed-off-by: Simon Glass <sjg@chromium.org>
24 files changed:
arch/arm/mach-rockchip/rk3188/sdram_rk3188.c
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c
drivers/block/dwc_ahci.c
drivers/clk/clk_zynq.c
drivers/core/regmap.c
drivers/firmware/psci.c
drivers/gpio/intel_ich6_gpio.c
drivers/mmc/mmc-uclass.c
drivers/mmc/sdhci-cadence.c
drivers/mmc/zynq_sdhci.c
drivers/net/phy/phy.c
drivers/net/phy/ti.c
drivers/net/sun8i_emac.c
drivers/phy/ti-pipe3-phy.c
drivers/pinctrl/pinctrl-at91.c
drivers/pinctrl/pinctrl-single.c
drivers/pinctrl/pinctrl_stm32.c
drivers/pinctrl/rockchip/pinctrl_rk3188.c
drivers/pinctrl/rockchip/pinctrl_rk3328.c
drivers/ram/stm32_sdram.c
drivers/serial/serial_lpuart.c
drivers/spi/ti_qspi.c
drivers/timer/arc_timer.c
drivers/video/atmel_hlcdfb.c

index fea8007265ce893fd16f0935ec32e9dd333e23b8..946a9f1653ad642629c9d4e0cfed9cb4c5c49496 100644 (file)
@@ -852,7 +852,7 @@ static int rk3188_dmc_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
        struct rk3188_sdram_params *params = dev_get_platdata(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        /* rk3188 supports only one-channel */
index 536879d65b5395ebd0070fece069e02e20f72061..a3ae8bd4f064d352fd1de6b6a2d1bd52b39ab81d 100644 (file)
@@ -1128,7 +1128,7 @@ static int rk3399_dmc_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
        struct rockchip_dmc_plat *plat = dev_get_platdata(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        ret = fdtdec_get_int_array(blob, node, "rockchip,sdram-params",
index b2e715023dd447144132f035f9a27f10aa857589..3f839bf9879e4ec6e7a2c7092fbb7a545f8aeb6f 100644 (file)
@@ -31,9 +31,9 @@ static int dwc_ahci_ofdata_to_platdata(struct udevice *dev)
        struct scsi_platdata *plat = dev_get_platdata(dev);
        fdt_addr_t addr;
 
-       plat->max_id = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "max-id",
-                                      CONFIG_SYS_SCSI_MAX_SCSI_ID);
-       plat->max_lun = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       plat->max_id = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
+                                      "max-id", CONFIG_SYS_SCSI_MAX_SCSI_ID);
+       plat->max_lun = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                        "max-lun", CONFIG_SYS_SCSI_MAX_LUN);
 
        priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
index 6edc4dc6cadfac3b71277a26e1c88b7dd3c9979f..b9975456faf97eb49dc8738ce73358c7aba46205 100644 (file)
@@ -466,7 +466,7 @@ static int zynq_clk_probe(struct udevice *dev)
        }
 #endif
 
-       priv->ps_clk_freq = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       priv->ps_clk_freq = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                            "ps-clk-frequency", 33333333UL);
 
        return 0;
index 3bec3df9b6e36dc7dac19c1ae414e2ac5094fca4..7f21dee7e476e749891891b4e6a8f8b8bef02567 100644 (file)
@@ -90,8 +90,9 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
        for (range = map->range, index = 0; count > 0;
             count--, cell += both_len, range++, index++) {
                fdt_size_t sz;
-               range->start = fdtdec_get_addr_size_fixed(blob, dev->of_offset,
-                               "reg", index, addr_len, size_len, &sz, true);
+               range->start = fdtdec_get_addr_size_fixed(blob,
+                               dev_of_offset(dev), "reg", index, addr_len,
+                               size_len, &sz, true);
                range->size = sz;
        }
        map->base = map->range[0].start;
index 3ae627ce5d8e072c7fbf5dd76ad76a8dc60cc37c..7652cc27aa9c44173c30a1f621d323bc1df6d2a4 100644 (file)
@@ -59,8 +59,8 @@ static int psci_probe(struct udevice *dev)
        DECLARE_GLOBAL_DATA_PTR;
        const char *method;
 
-       method = fdt_stringlist_get(gd->fdt_blob, dev->of_offset, "method", 0,
-                                   NULL);
+       method = fdt_stringlist_get(gd->fdt_blob, dev_of_offset(dev), "method",
+                                   0, NULL);
        if (!method) {
                printf("missing \"method\" property\n");
                return -ENXIO;
index 0a9eb03fd0500c9cfc7d3a1605dbf46ff11c1da9..ffc3ccb2767596b230f838a06433715318784342 100644 (file)
@@ -129,7 +129,7 @@ static int ich6_gpio_probe(struct udevice *dev)
        bank->io_sel = plat->base_addr + 4;
        bank->lvl = plat->base_addr + 8;
 
-       prop = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                           "use-lvl-write-cache", NULL);
        if (prop)
                bank->use_lvl_write_cache = true;
index 9c07871d3a2c7751a17b834dc9da8692b9a23c0f..8d03ec67c1d5711cbf83aab7c7c26f17d5eb2a9c 100644 (file)
@@ -198,7 +198,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
 
 #ifndef CONFIG_SPL_BUILD
        /* Use the fixed index with aliase node's index */
-       fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev->of_offset, &devnum);
+       fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev_of_offset(dev), &devnum);
 #endif
 
        ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
index 4452be048c9907e39aac18826bf55660df2e2807..4bd2623eaef986a261701b9afd93c1ee579d63ab 100644 (file)
@@ -139,7 +139,7 @@ static int sdhci_cdns_probe(struct udevice *dev)
        host->ioaddr = plat->hrs_addr + SDHCI_CDNS_SRS_BASE;
        host->quirks |= SDHCI_QUIRK_WAIT_SEND_CMD;
 
-       ret = sdhci_cdns_phy_init(plat, gd->fdt_blob, dev->of_offset);
+       ret = sdhci_cdns_phy_init(plat, gd->fdt_blob, dev_of_offset(dev));
        if (ret)
                return ret;
 
index 70ad5734e1701642c13cca6571c20d6fdeebedf5..0fddb420dc0f55745d374ca8ae39d9c7b64907ee 100644 (file)
@@ -83,7 +83,7 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
        host->name = dev->name;
        host->ioaddr = (void *)devfdt_get_addr(dev);
 
-       plat->f_max = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->f_max = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                "max-frequency", CONFIG_ZYNQ_SDHCI_MAX_FREQ);
 
        return 0;
index 8bacd991ad570929b0c0869718306cc9691fece8..97e0bc022bdce0fd0b6479e1b166ebf836831f37 100644 (file)
@@ -860,7 +860,7 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr,
 #ifdef CONFIG_PHY_FIXED
        int sn;
        const char *name;
-       sn = fdt_first_subnode(gd->fdt_blob, dev->of_offset);
+       sn = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
        while (sn > 0) {
                name = fdt_get_name(gd->fdt_blob, sn, NULL);
                if (name != NULL && strcmp(name, "fixed-link") == 0) {
index 1d870806a3540453c972e0d59baf64742fe77a11..6ad31a0465863a215287d065a89104e0c221a469 100644 (file)
@@ -174,7 +174,7 @@ static int dp83867_of_init(struct phy_device *phydev)
 {
        struct dp83867_private *dp83867 = phydev->priv;
        struct udevice *dev = phydev->dev;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const void *fdt = gd->fdt_blob;
 
        if (fdtdec_get_bool(fdt, node, "ti,max-output-impedance"))
index d895d09a76a2277ac487a7e0225419603f3ede16..09bbb2cdb5cad47967ffb5ca4f9f9f871349fc54 100644 (file)
@@ -820,7 +820,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
                parse_phy_pins(dev);
 
 #ifdef CONFIG_DM_GPIO
-       if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+       if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
                            "snps,reset-active-low"))
                reset_flags |= GPIOD_ACTIVE_LOW;
 
@@ -828,7 +828,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
                                   &priv->reset_gpio, reset_flags);
 
        if (ret == 0) {
-               ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+               ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
                                           "snps,reset-delays-us",
                                           sun8i_pdata->reset_delays, 3);
        } else if (ret == -ENOENT) {
index 350dab72f8845cf69fd49849a2c5043ceecc3209..680e32f3ea6f46fa687ef2fd247af90fd4eae26f 100644 (file)
@@ -296,7 +296,7 @@ static void *get_reg(struct udevice *dev, const char *name)
                return NULL;
        }
 
-       cell = fdt_getprop(gd->fdt_blob, dev->of_offset, name,
+       cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), name,
                           &len);
        if (len < 2*sizeof(fdt32_t)) {
                error("offset not available for %s\n", name);
index 023cc010d3133f7c64aec8394d67ce6eb36a34e3..38c435e37ae821666da0dd6ec72271a175567b07 100644 (file)
@@ -364,7 +364,7 @@ static int at91_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
        struct at91_pinctrl_priv *priv = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
-       int node = config->of_offset;
+       int node = dev_of_offset(config);
        u32 cells[MAX_PINMUX_ENTRIES];
        const u32 *list = cells;
        u32 bank, pin;
index 1264b52a3b8f08eb3b942370154a30e2723e94e8..a38d774ddc9643597bf6ceb87548d35ff380cd31 100644 (file)
@@ -79,7 +79,8 @@ static int single_set_state(struct udevice *dev,
        const struct single_fdt_pin_cfg *prop;
        int len;
 
-       prop = fdt_getprop(fdt, config->of_offset, "pinctrl-single,pins", &len);
+       prop = fdt_getprop(fdt, dev_of_offset(config), "pinctrl-single,pins",
+                          &len);
        if (prop) {
                dev_dbg(dev, "configuring pins for %s\n", config->name);
                if (len % sizeof(struct single_fdt_pin_cfg)) {
@@ -100,10 +101,10 @@ static int single_ofdata_to_platdata(struct udevice *dev)
        int res;
        struct single_pdata *pdata = dev->platdata;
 
-       pdata->width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       pdata->width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                      "pinctrl-single,register-width", 0);
 
-       res = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+       res = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
                                   "reg", of_reg, 2);
        if (res)
                return res;
@@ -116,7 +117,7 @@ static int single_ofdata_to_platdata(struct udevice *dev)
        }
        pdata->base = addr;
 
-       pdata->mask = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       pdata->mask = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                     "pinctrl-single,function-mask",
                                     0xffffffff);
        return 0;
index d7b5ea3e1c001b5b840ff46f7a17ce09488b5e3f..5bee7fb12ad057b1bf303594c036793301643adc 100644 (file)
@@ -101,7 +101,7 @@ static int stm32_pinctrl_set_state_simple(struct udevice *dev,
        int rv, len;
 
        /* Get node pinctrl-0 */
-       rv = fdtdec_parse_phandle_with_args(gd->fdt_blob, periph->of_offset,
+       rv = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(periph),
                                           "pinctrl-0", 0, 0, 0, &args);
        if (rv)
                return rv;
index ef94dab210e460112c0cbb5a2bd72bb8a017f135..65c1f665ea9cd01a2f29d2540e99828437675cab 100644 (file)
@@ -370,7 +370,7 @@ static int rk3188_pinctrl_get_periph_id(struct udevice *dev,
        u32 cell[3];
        int ret;
 
-       ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
                                   "interrupts", cell, ARRAY_SIZE(cell));
        if (ret < 0)
                return -EINVAL;
@@ -516,7 +516,7 @@ static int rk3188_pinctrl_set_state(struct udevice *dev, struct udevice *config)
        u32 cell[60], *ptr;
 
        debug("%s: %s %s\n", __func__, dev->name, config->name);
-       ret = fdtdec_get_int_array_count(blob, config->of_offset,
+       ret = fdtdec_get_int_array_count(blob, dev_of_offset(config),
                                         "rockchip,pins", cell,
                                         ARRAY_SIZE(cell));
        if (ret < 0) {
index 5ca6782ccc1b28bd7f6f91385c178636a520a790..b6beec5ed095f42adba62f1cf951ae1e15187a1e 100644 (file)
@@ -347,7 +347,7 @@ static int rk3328_pinctrl_get_periph_id(struct udevice *dev,
        u32 cell[3];
        int ret;
 
-       ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
                                   "interrupts", cell, ARRAY_SIZE(cell));
        if (ret < 0)
                return -EINVAL;
index 48b4979e6248b2f23ced4994d0ff9af862feac3b..b640519555dc2a3088bc1aca6cfe4b0cc4527de8 100644 (file)
@@ -104,7 +104,7 @@ int stm32_sdram_init(struct udevice *dev)
 static int stm32_fmc_ofdata_to_platdata(struct udevice *dev)
 {
        int ret;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const void *blob = gd->fdt_blob;
        struct stm32_sdram_params *params = dev_get_platdata(dev);
 
index 47dd88b32c8de9259c5a84376eb372fc64040c92..382f8ba5b52d6279dfc214cdc73ef6a91fea6ddb 100644 (file)
@@ -416,7 +416,7 @@ static int lpuart_serial_ofdata_to_platdata(struct udevice *dev)
 {
        struct lpuart_serial_platdata *plat = dev->platdata;
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        fdt_addr_t addr;
 
        addr = devfdt_get_addr(dev);
index 0e8411b4afa320d992e3e161c288470cd9dc12aa..bea3aff943196bd3dd8415bd4addb3960534d617 100644 (file)
@@ -574,8 +574,8 @@ static void *map_syscon_chipselects(struct udevice *bus)
                return NULL;
        }
 
-       cell = fdt_getprop(gd->fdt_blob, bus->of_offset, "syscon-chipselects",
-                          &len);
+       cell = fdt_getprop(gd->fdt_blob, dev_of_offset(bus),
+                          "syscon-chipselects", &len);
        if (len < 2*sizeof(fdt32_t)) {
                debug("%s: offset not available\n", __func__);
                return NULL;
index e94e4a4bca7e606d6cac8e646ebe17dbfe428e21..a5f6b345c89d97558e4f3ed561b09abe098fccf7 100644 (file)
@@ -51,7 +51,7 @@ static int arc_timer_probe(struct udevice *dev)
        struct arc_timer_priv *priv = dev_get_priv(dev);
 
        /* Get registers offset and size */
-       id = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+       id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
        if (id < 0)
                return -EINVAL;
 
index 903653fdc4897d1f47093097e7129d1842bf949e..47078fdaaedc81c9ecb6c36cecf15d70c881dc6b 100644 (file)
@@ -497,7 +497,7 @@ static int atmel_hlcdc_ofdata_to_platdata(struct udevice *dev)
 {
        struct atmel_hlcdc_priv *priv = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        priv->regs = (struct atmel_hlcd_regs *)devfdt_get_addr(dev);
        if (!priv->regs) {
@@ -505,7 +505,7 @@ static int atmel_hlcdc_ofdata_to_platdata(struct udevice *dev)
                return -EINVAL;
        }
 
-       if (fdtdec_decode_display_timing(blob, dev->of_offset,
+       if (fdtdec_decode_display_timing(blob, dev_of_offset(dev),
                                         0, &priv->timing)) {
                debug("%s: Failed to decode display timing\n", __func__);
                return -EINVAL;