Commit da409ccc4ae62a0bf7111e2f4419fdbfd1ba3d89

Authored by Simon Glass
1 parent a771a04f2e

dm: core: Replace of_offset with accessor (part 2)

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>

Showing 24 changed files with 37 additions and 35 deletions Side-by-side Diff

arch/arm/mach-rockchip/rk3188/sdram_rk3188.c
... ... @@ -852,7 +852,7 @@
852 852 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
853 853 struct rk3188_sdram_params *params = dev_get_platdata(dev);
854 854 const void *blob = gd->fdt_blob;
855   - int node = dev->of_offset;
  855 + int node = dev_of_offset(dev);
856 856 int ret;
857 857  
858 858 /* rk3188 supports only one-channel */
arch/arm/mach-rockchip/rk3399/sdram_rk3399.c
... ... @@ -1128,7 +1128,7 @@
1128 1128 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
1129 1129 struct rockchip_dmc_plat *plat = dev_get_platdata(dev);
1130 1130 const void *blob = gd->fdt_blob;
1131   - int node = dev->of_offset;
  1131 + int node = dev_of_offset(dev);
1132 1132 int ret;
1133 1133  
1134 1134 ret = fdtdec_get_int_array(blob, node, "rockchip,sdram-params",
drivers/block/dwc_ahci.c
... ... @@ -31,9 +31,9 @@
31 31 struct scsi_platdata *plat = dev_get_platdata(dev);
32 32 fdt_addr_t addr;
33 33  
34   - plat->max_id = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "max-id",
35   - CONFIG_SYS_SCSI_MAX_SCSI_ID);
36   - plat->max_lun = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
  34 + plat->max_id = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
  35 + "max-id", CONFIG_SYS_SCSI_MAX_SCSI_ID);
  36 + plat->max_lun = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
37 37 "max-lun", CONFIG_SYS_SCSI_MAX_LUN);
38 38  
39 39 priv->base = map_physmem(devfdt_get_addr(dev), sizeof(void *),
drivers/clk/clk_zynq.c
... ... @@ -466,7 +466,7 @@
466 466 }
467 467 #endif
468 468  
469   - priv->ps_clk_freq = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
  469 + priv->ps_clk_freq = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
470 470 "ps-clk-frequency", 33333333UL);
471 471  
472 472 return 0;
drivers/core/regmap.c
... ... @@ -90,8 +90,9 @@
90 90 for (range = map->range, index = 0; count > 0;
91 91 count--, cell += both_len, range++, index++) {
92 92 fdt_size_t sz;
93   - range->start = fdtdec_get_addr_size_fixed(blob, dev->of_offset,
94   - "reg", index, addr_len, size_len, &sz, true);
  93 + range->start = fdtdec_get_addr_size_fixed(blob,
  94 + dev_of_offset(dev), "reg", index, addr_len,
  95 + size_len, &sz, true);
95 96 range->size = sz;
96 97 }
97 98 map->base = map->range[0].start;
drivers/firmware/psci.c
... ... @@ -59,8 +59,8 @@
59 59 DECLARE_GLOBAL_DATA_PTR;
60 60 const char *method;
61 61  
62   - method = fdt_stringlist_get(gd->fdt_blob, dev->of_offset, "method", 0,
63   - NULL);
  62 + method = fdt_stringlist_get(gd->fdt_blob, dev_of_offset(dev), "method",
  63 + 0, NULL);
64 64 if (!method) {
65 65 printf("missing \"method\" property\n");
66 66 return -ENXIO;
drivers/gpio/intel_ich6_gpio.c
... ... @@ -129,7 +129,7 @@
129 129 bank->io_sel = plat->base_addr + 4;
130 130 bank->lvl = plat->base_addr + 8;
131 131  
132   - prop = fdt_getprop(gd->fdt_blob, dev->of_offset,
  132 + prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
133 133 "use-lvl-write-cache", NULL);
134 134 if (prop)
135 135 bank->use_lvl_write_cache = true;
drivers/mmc/mmc-uclass.c
... ... @@ -198,7 +198,7 @@
198 198  
199 199 #ifndef CONFIG_SPL_BUILD
200 200 /* Use the fixed index with aliase node's index */
201   - fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev->of_offset, &devnum);
  201 + fdtdec_get_alias_seq(gd->fdt_blob, "mmc", dev_of_offset(dev), &devnum);
202 202 #endif
203 203  
204 204 ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
drivers/mmc/sdhci-cadence.c
... ... @@ -139,7 +139,7 @@
139 139 host->ioaddr = plat->hrs_addr + SDHCI_CDNS_SRS_BASE;
140 140 host->quirks |= SDHCI_QUIRK_WAIT_SEND_CMD;
141 141  
142   - ret = sdhci_cdns_phy_init(plat, gd->fdt_blob, dev->of_offset);
  142 + ret = sdhci_cdns_phy_init(plat, gd->fdt_blob, dev_of_offset(dev));
143 143 if (ret)
144 144 return ret;
145 145  
drivers/mmc/zynq_sdhci.c
... ... @@ -83,7 +83,7 @@
83 83 host->name = dev->name;
84 84 host->ioaddr = (void *)devfdt_get_addr(dev);
85 85  
86   - plat->f_max = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
  86 + plat->f_max = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
87 87 "max-frequency", CONFIG_ZYNQ_SDHCI_MAX_FREQ);
88 88  
89 89 return 0;
drivers/net/phy/phy.c
... ... @@ -860,7 +860,7 @@
860 860 #ifdef CONFIG_PHY_FIXED
861 861 int sn;
862 862 const char *name;
863   - sn = fdt_first_subnode(gd->fdt_blob, dev->of_offset);
  863 + sn = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
864 864 while (sn > 0) {
865 865 name = fdt_get_name(gd->fdt_blob, sn, NULL);
866 866 if (name != NULL && strcmp(name, "fixed-link") == 0) {
drivers/net/phy/ti.c
... ... @@ -174,7 +174,7 @@
174 174 {
175 175 struct dp83867_private *dp83867 = phydev->priv;
176 176 struct udevice *dev = phydev->dev;
177   - int node = dev->of_offset;
  177 + int node = dev_of_offset(dev);
178 178 const void *fdt = gd->fdt_blob;
179 179  
180 180 if (fdtdec_get_bool(fdt, node, "ti,max-output-impedance"))
drivers/net/sun8i_emac.c
... ... @@ -820,7 +820,7 @@
820 820 parse_phy_pins(dev);
821 821  
822 822 #ifdef CONFIG_DM_GPIO
823   - if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
  823 + if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
824 824 "snps,reset-active-low"))
825 825 reset_flags |= GPIOD_ACTIVE_LOW;
826 826  
... ... @@ -828,7 +828,7 @@
828 828 &priv->reset_gpio, reset_flags);
829 829  
830 830 if (ret == 0) {
831   - ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
  831 + ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
832 832 "snps,reset-delays-us",
833 833 sun8i_pdata->reset_delays, 3);
834 834 } else if (ret == -ENOENT) {
drivers/phy/ti-pipe3-phy.c
... ... @@ -296,7 +296,7 @@
296 296 return NULL;
297 297 }
298 298  
299   - cell = fdt_getprop(gd->fdt_blob, dev->of_offset, name,
  299 + cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), name,
300 300 &len);
301 301 if (len < 2*sizeof(fdt32_t)) {
302 302 error("offset not available for %s\n", name);
drivers/pinctrl/pinctrl-at91.c
... ... @@ -364,7 +364,7 @@
364 364 {
365 365 struct at91_pinctrl_priv *priv = dev_get_priv(dev);
366 366 const void *blob = gd->fdt_blob;
367   - int node = config->of_offset;
  367 + int node = dev_of_offset(config);
368 368 u32 cells[MAX_PINMUX_ENTRIES];
369 369 const u32 *list = cells;
370 370 u32 bank, pin;
drivers/pinctrl/pinctrl-single.c
... ... @@ -79,7 +79,8 @@
79 79 const struct single_fdt_pin_cfg *prop;
80 80 int len;
81 81  
82   - prop = fdt_getprop(fdt, config->of_offset, "pinctrl-single,pins", &len);
  82 + prop = fdt_getprop(fdt, dev_of_offset(config), "pinctrl-single,pins",
  83 + &len);
83 84 if (prop) {
84 85 dev_dbg(dev, "configuring pins for %s\n", config->name);
85 86 if (len % sizeof(struct single_fdt_pin_cfg)) {
86 87  
... ... @@ -100,10 +101,10 @@
100 101 int res;
101 102 struct single_pdata *pdata = dev->platdata;
102 103  
103   - pdata->width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
  104 + pdata->width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
104 105 "pinctrl-single,register-width", 0);
105 106  
106   - res = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
  107 + res = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
107 108 "reg", of_reg, 2);
108 109 if (res)
109 110 return res;
... ... @@ -116,7 +117,7 @@
116 117 }
117 118 pdata->base = addr;
118 119  
119   - pdata->mask = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
  120 + pdata->mask = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
120 121 "pinctrl-single,function-mask",
121 122 0xffffffff);
122 123 return 0;
drivers/pinctrl/pinctrl_stm32.c
... ... @@ -101,7 +101,7 @@
101 101 int rv, len;
102 102  
103 103 /* Get node pinctrl-0 */
104   - rv = fdtdec_parse_phandle_with_args(gd->fdt_blob, periph->of_offset,
  104 + rv = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(periph),
105 105 "pinctrl-0", 0, 0, 0, &args);
106 106 if (rv)
107 107 return rv;
drivers/pinctrl/rockchip/pinctrl_rk3188.c
... ... @@ -370,7 +370,7 @@
370 370 u32 cell[3];
371 371 int ret;
372 372  
373   - ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
  373 + ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
374 374 "interrupts", cell, ARRAY_SIZE(cell));
375 375 if (ret < 0)
376 376 return -EINVAL;
... ... @@ -516,7 +516,7 @@
516 516 u32 cell[60], *ptr;
517 517  
518 518 debug("%s: %s %s\n", __func__, dev->name, config->name);
519   - ret = fdtdec_get_int_array_count(blob, config->of_offset,
  519 + ret = fdtdec_get_int_array_count(blob, dev_of_offset(config),
520 520 "rockchip,pins", cell,
521 521 ARRAY_SIZE(cell));
522 522 if (ret < 0) {
drivers/pinctrl/rockchip/pinctrl_rk3328.c
... ... @@ -347,7 +347,7 @@
347 347 u32 cell[3];
348 348 int ret;
349 349  
350   - ret = fdtdec_get_int_array(gd->fdt_blob, periph->of_offset,
  350 + ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(periph),
351 351 "interrupts", cell, ARRAY_SIZE(cell));
352 352 if (ret < 0)
353 353 return -EINVAL;
drivers/ram/stm32_sdram.c
... ... @@ -104,7 +104,7 @@
104 104 static int stm32_fmc_ofdata_to_platdata(struct udevice *dev)
105 105 {
106 106 int ret;
107   - int node = dev->of_offset;
  107 + int node = dev_of_offset(dev);
108 108 const void *blob = gd->fdt_blob;
109 109 struct stm32_sdram_params *params = dev_get_platdata(dev);
110 110  
drivers/serial/serial_lpuart.c
... ... @@ -416,7 +416,7 @@
416 416 {
417 417 struct lpuart_serial_platdata *plat = dev->platdata;
418 418 const void *blob = gd->fdt_blob;
419   - int node = dev->of_offset;
  419 + int node = dev_of_offset(dev);
420 420 fdt_addr_t addr;
421 421  
422 422 addr = devfdt_get_addr(dev);
drivers/spi/ti_qspi.c
... ... @@ -574,8 +574,8 @@
574 574 return NULL;
575 575 }
576 576  
577   - cell = fdt_getprop(gd->fdt_blob, bus->of_offset, "syscon-chipselects",
578   - &len);
  577 + cell = fdt_getprop(gd->fdt_blob, dev_of_offset(bus),
  578 + "syscon-chipselects", &len);
579 579 if (len < 2*sizeof(fdt32_t)) {
580 580 debug("%s: offset not available\n", __func__);
581 581 return NULL;
drivers/timer/arc_timer.c
... ... @@ -51,7 +51,7 @@
51 51 struct arc_timer_priv *priv = dev_get_priv(dev);
52 52  
53 53 /* Get registers offset and size */
54   - id = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
  54 + id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
55 55 if (id < 0)
56 56 return -EINVAL;
57 57  
drivers/video/atmel_hlcdfb.c
... ... @@ -497,7 +497,7 @@
497 497 {
498 498 struct atmel_hlcdc_priv *priv = dev_get_priv(dev);
499 499 const void *blob = gd->fdt_blob;
500   - int node = dev->of_offset;
  500 + int node = dev_of_offset(dev);
501 501  
502 502 priv->regs = (struct atmel_hlcd_regs *)devfdt_get_addr(dev);
503 503 if (!priv->regs) {
... ... @@ -505,7 +505,7 @@
505 505 return -EINVAL;
506 506 }
507 507  
508   - if (fdtdec_decode_display_timing(blob, dev->of_offset,
  508 + if (fdtdec_decode_display_timing(blob, dev_of_offset(dev),
509 509 0, &priv->timing)) {
510 510 debug("%s: Failed to decode display timing\n", __func__);
511 511 return -EINVAL;