dm: core: Replace of_offset with accessor
authorSimon Glass <sjg@chromium.org>
Tue, 17 Jan 2017 23:52:55 +0000 (16:52 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 8 Feb 2017 13:12:14 +0000 (06:12 -0700)
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>
220 files changed:
arch/arm/mach-aspeed/ast2500/sdram_ast2500.c
arch/arm/mach-rockchip/rk3288/sdram_rk3288.c
arch/nios2/cpu/cpu.c
arch/x86/cpu/broadwell/cpu.c
arch/x86/cpu/broadwell/pch.c
arch/x86/cpu/broadwell/pinctrl_broadwell.c
arch/x86/cpu/broadwell/sata.c
arch/x86/cpu/cpu_x86.c
arch/x86/cpu/intel_common/lpc.c
arch/x86/cpu/intel_common/mrc.c
arch/x86/cpu/irq.c
arch/x86/cpu/ivybridge/lpc.c
arch/x86/cpu/ivybridge/model_206ax.c
arch/x86/cpu/ivybridge/sata.c
arch/x86/cpu/mp_init.c
arch/x86/lib/mpspec.c
arch/x86/lib/pinctrl_ich6.c
board/qualcomm/dragonboard410c/dragonboard410c.c
doc/driver-model/README.txt
doc/driver-model/of-plat.txt
doc/driver-model/spi-howto.txt
drivers/adc/adc-uclass.c
drivers/clk/at91/clk-generated.c
drivers/clk/at91/pmc.c
drivers/clk/clk-uclass.c
drivers/clk/clk_fixed_rate.c
drivers/clk/clk_pic32.c
drivers/core/device.c
drivers/core/regmap.c
drivers/core/root.c
drivers/core/simple-bus.c
drivers/core/uclass.c
drivers/demo/demo-shape.c
drivers/demo/demo-uclass.c
drivers/gpio/74x164_gpio.c
drivers/gpio/altera_pio.c
drivers/gpio/atmel_pio4.c
drivers/gpio/dwapb_gpio.c
drivers/gpio/gpio-uclass.c
drivers/gpio/intel_broadwell_gpio.c
drivers/gpio/intel_ich6_gpio.c
drivers/gpio/lpc32xx_gpio.c
drivers/gpio/mpc85xx_gpio.c
drivers/gpio/msm_gpio.c
drivers/gpio/omap_gpio.c
drivers/gpio/pca953x_gpio.c
drivers/gpio/pcf8575_gpio.c
drivers/gpio/pic32_gpio.c
drivers/gpio/pm8916_gpio.c
drivers/gpio/s5p_gpio.c
drivers/gpio/sandbox.c
drivers/gpio/sunxi_gpio.c
drivers/gpio/tegra186_gpio.c
drivers/gpio/tegra_gpio.c
drivers/gpio/vybrid_gpio.c
drivers/i2c/at91_i2c.c
drivers/i2c/cros_ec_tunnel.c
drivers/i2c/exynos_hs_i2c.c
drivers/i2c/fsl_i2c.c
drivers/i2c/i2c-gpio.c
drivers/i2c/i2c-uclass.c
drivers/i2c/muxes/i2c-arb-gpio-challenge.c
drivers/i2c/muxes/i2c-mux-uclass.c
drivers/i2c/muxes/pca954x.c
drivers/i2c/mvtwsi.c
drivers/i2c/mxc_i2c.c
drivers/i2c/s3c24x0_i2c.c
drivers/i2c/tegra186_bpmp_i2c.c
drivers/input/cros_ec_keyb.c
drivers/input/i8042.c
drivers/input/tegra-kbc.c
drivers/led/led_gpio.c
drivers/mailbox/mailbox-uclass.c
drivers/misc/cros_ec.c
drivers/misc/cros_ec_sandbox.c
drivers/misc/i2c_eeprom_emul.c
drivers/misc/tegra186_bpmp.c
drivers/misc/tegra_car.c
drivers/mmc/atmel_sdhci.c
drivers/mmc/exynos_dw_mmc.c
drivers/mmc/fsl_esdhc.c
drivers/mmc/msm_sdhci.c
drivers/mmc/omap_hsmmc.c
drivers/mmc/pic32_sdhci.c
drivers/mmc/rockchip_dw_mmc.c
drivers/mmc/rockchip_sdhci.c
drivers/mmc/s5p_sdhci.c
drivers/mmc/socfpga_dw_mmc.c
drivers/mmc/tegra_mmc.c
drivers/mmc/uniphier-sd.c
drivers/mmc/xenon_sdhci.c
drivers/mtd/altera_qspi.c
drivers/mtd/cfi_flash.c
drivers/mtd/pic32_flash.c
drivers/mtd/spi/sandbox.c
drivers/mtd/spi/spi_flash.c
drivers/net/ag7xxx.c
drivers/net/altera_tse.c
drivers/net/cpsw-common.c
drivers/net/cpsw.c
drivers/net/designware.c
drivers/net/fec_mxc.c
drivers/net/gmac_rockchip.c
drivers/net/keystone_net.c
drivers/net/macb.c
drivers/net/mvneta.c
drivers/net/mvpp2.c
drivers/net/phy/micrel.c
drivers/net/phy/ti.c
drivers/net/phy/xilinx_phy.c
drivers/net/pic32_eth.c
drivers/net/sandbox-raw.c
drivers/net/sandbox.c
drivers/net/sun8i_emac.c
drivers/net/tsec.c
drivers/net/xilinx_axi_emac.c
drivers/net/xilinx_emaclite.c
drivers/net/zynq_gem.c
drivers/pci/pci-uclass.c
drivers/pci/pci_tegra.c
drivers/pci/pcie_layerscape.c
drivers/pci/pcie_xilinx.c
drivers/phy/marvell/comphy_core.c
drivers/pinctrl/ath79/pinctrl_ar933x.c
drivers/pinctrl/ath79/pinctrl_qca953x.c
drivers/pinctrl/exynos/pinctrl-exynos.c
drivers/pinctrl/meson/pinctrl-meson.c
drivers/pinctrl/mvebu/pinctrl-mvebu.c
drivers/pinctrl/nxp/pinctrl-imx.c
drivers/pinctrl/pinctrl-at91-pio4.c
drivers/pinctrl/pinctrl-generic.c
drivers/pinctrl/pinctrl-uclass.c
drivers/pinctrl/pinctrl_pic32.c
drivers/pinctrl/rockchip/pinctrl_rk3036.c
drivers/pinctrl/rockchip/pinctrl_rk3288.c
drivers/pinctrl/rockchip/pinctrl_rk3399.c
drivers/power/domain/power-domain-uclass.c
drivers/power/pmic/act8846.c
drivers/power/pmic/i2c_pmic_emul.c
drivers/power/pmic/lp873x.c
drivers/power/pmic/max77686.c
drivers/power/pmic/palmas.c
drivers/power/pmic/pfuze100.c
drivers/power/pmic/pmic-uclass.c
drivers/power/pmic/rk808.c
drivers/power/pmic/s5m8767.c
drivers/power/pmic/sandbox.c
drivers/power/pmic/tps65090.c
drivers/power/regulator/fixed.c
drivers/power/regulator/gpio-regulator.c
drivers/power/regulator/pwm_regulator.c
drivers/power/regulator/regulator-uclass.c
drivers/remoteproc/rproc-uclass.c
drivers/remoteproc/ti_power_proc.c
drivers/reset/reset-uclass.c
drivers/serial/altera_uart.c
drivers/serial/ns16550.c
drivers/serial/sandbox.c
drivers/serial/serial_arc.c
drivers/serial/serial_bcm283x_mu.c
drivers/serial/serial_msm.c
drivers/serial/serial_mxc.c
drivers/serial/serial_pic32.c
drivers/serial/serial_pl01x.c
drivers/serial/serial_s5p.c
drivers/serial/serial_sh.c
drivers/serial/serial_uniphier.c
drivers/spi/cadence_qspi.c
drivers/spi/davinci_spi.c
drivers/spi/designware_spi.c
drivers/spi/exynos_spi.c
drivers/spi/fsl_dspi.c
drivers/spi/fsl_qspi.c
drivers/spi/ich.c
drivers/spi/mvebu_a3700_spi.c
drivers/spi/omap3_spi.c
drivers/spi/pic32_spi.c
drivers/spi/rk_spi.c
drivers/spi/soft_spi.c
drivers/spi/spi-uclass.c
drivers/spi/stm32_qspi.c
drivers/spi/tegra114_spi.c
drivers/spi/tegra20_sflash.c
drivers/spi/tegra20_slink.c
drivers/spi/tegra210_qspi.c
drivers/spi/ti_qspi.c
drivers/spi/zynq_qspi.c
drivers/spi/zynq_spi.c
drivers/spmi/spmi-msm.c
drivers/sysreset/sysreset_sandbox.c
drivers/timer/timer-uclass.c
drivers/usb/emul/sandbox_flash.c
drivers/usb/emul/sandbox_hub.c
drivers/usb/host/dwc2.c
drivers/usb/host/ehci-exynos.c
drivers/usb/host/ehci-fsl.c
drivers/usb/host/ehci-mx6.c
drivers/usb/host/ehci-tegra.c
drivers/usb/host/ehci-vf.c
drivers/usb/host/usb-uclass.c
drivers/usb/host/xhci-exynos5.c
drivers/usb/host/xhci-rockchip.c
drivers/usb/musb-new/pic32.c
drivers/usb/musb-new/ti-musb.c
drivers/video/atmel_lcdfb.c
drivers/video/bridge/ps862x.c
drivers/video/broadwell_igd.c
drivers/video/exynos/exynos_dp.c
drivers/video/exynos/exynos_fb.c
drivers/video/ivybridge_igd.c
drivers/video/pwm_backlight.c
drivers/video/rockchip/rk_lvds.c
drivers/video/rockchip/rk_vop.c
drivers/video/sandbox_sdl.c
drivers/video/tegra.c
drivers/video/tegra124/display.c
drivers/video/tegra124/sor.c
include/dm/device.h
test/dm/spi.c
test/dm/test-fdt.c

index ace1028..cb6e03f 100644 (file)
@@ -392,7 +392,7 @@ static int ast2500_sdrammc_ofdata_to_platdata(struct udevice *dev)
        priv->regs = regmap_get_range(map, 0);
        priv->phy = regmap_get_range(map, 1);
 
-       priv->clock_rate = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       priv->clock_rate = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                          "clock-frequency", 0);
 
        if (!priv->clock_rate) {
index be3d713..89fd8e6 100644 (file)
@@ -1016,7 +1016,7 @@ static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
        struct rk3288_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;
 
        /* Rk3288 supports dual-channel, set default channel num to 2 */
index 4f0f8fc..c1caa65 100644 (file)
@@ -103,7 +103,7 @@ static int altera_nios2_get_count(struct udevice *dev)
 static int altera_nios2_probe(struct udevice *dev)
 {
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        gd->cpu_clk = fdtdec_get_int(blob, node,
                "clock-frequency", 0);
index 6977e86..1b71d56 100644 (file)
@@ -256,8 +256,8 @@ static void initialize_vr_config(struct udevice *dev)
        /* Set the slow ramp rate */
        msr.hi &= ~(0x3 << (53 - 32));
        /* Configure the C-state exit ramp rate */
-       ramp = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "intel,slow-ramp",
-                             -1);
+       ramp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+                             "intel,slow-ramp", -1);
        if (ramp != -1) {
                /* Configured slow ramp rate */
                msr.hi |= ((ramp & 0x3) << (53 - 32));
@@ -271,8 +271,8 @@ static void initialize_vr_config(struct udevice *dev)
        }
        /* Set MIN_VID (31:24) to allow CPU to have full control */
        msr.lo &= ~0xff000000;
-       min_vid = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "intel,min-vid",
-                                0);
+       min_vid = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+                                "intel,min-vid", 0);
        msr.lo |= (min_vid & 0xff) << 24;
        msr_write(MSR_VR_MISC_CONFIG, msr);
 
@@ -562,7 +562,7 @@ static void configure_thermal_target(struct udevice *dev)
        int tcc_offset;
        msr_t msr;
 
-       tcc_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       tcc_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                    "intel,tcc-offset", 0);
 
        /* Set TCC activaiton offset if supported */
index 317f57d..16eac3d 100644 (file)
@@ -190,14 +190,14 @@ static int pch_power_options(struct udevice *dev)
        debug("Set power %s after power failure.\n", state);
 
        /* GPE setup based on device tree configuration */
-       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
                                   "intel,gpe0-en", enable, ARRAY_SIZE(enable));
        if (ret)
                return -EINVAL;
        enable_all_gpe(enable[0], enable[1], enable[2], enable[3]);
 
        /* SMI setup based on device tree configuration */
-       enable_alt_smi(dev, fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       enable_alt_smi(dev, fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                           "intel,alt-gp-smi-enable", 0));
 
        return 0;
index 2a3fced..881413f 100644 (file)
@@ -51,7 +51,7 @@ static int broadwell_pinctrl_read_configs(struct udevice *dev,
        int node;
 
        debug("%s: starting\n", __func__);
-       for (node = fdt_first_subnode(blob, dev->of_offset);
+       for (node = fdt_first_subnode(blob, dev_of_offset(dev));
             node > 0;
             node = fdt_next_subnode(blob, node)) {
                int phandle = fdt_get_phandle(blob, node);
@@ -115,7 +115,7 @@ static int broadwell_pinctrl_read_pins(struct udevice *dev,
        int count = 0;
        int node;
 
-       for (node = fdt_first_subnode(blob, dev->of_offset);
+       for (node = fdt_first_subnode(blob, dev_of_offset(dev));
             node > 0;
             node = fdt_next_subnode(blob, node)) {
                int len, i;
index 2e47082..10461d9 100644 (file)
@@ -235,7 +235,7 @@ static int broadwell_sata_ofdata_to_platdata(struct udevice *dev)
 {
        struct sata_platdata *plat = dev_get_platdata(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        plat->port_map = fdtdec_get_int(blob, node, "intel,sata-port-map", 0);
        plat->port0_gen3_tx = fdtdec_get_int(blob, node,
index 157f3de..8be14b5 100644 (file)
@@ -17,7 +17,7 @@ int cpu_x86_bind(struct udevice *dev)
        struct cpu_platdata *plat = dev_get_parent_platdata(dev);
        struct cpuid_result res;
 
-       plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                      "intel,apic-id", -1);
        plat->family = gd->arch.x86;
        res = cpuid(1);
index 03cb45b..696b630 100644 (file)
@@ -50,7 +50,7 @@ int lpc_common_early_init(struct udevice *dev)
        int count;
        int i;
 
-       count = fdtdec_get_int_array_count(gd->fdt_blob, dev->of_offset,
+       count = fdtdec_get_int_array_count(gd->fdt_blob, dev_of_offset(dev),
                        "intel,gen-dec", (u32 *)values,
                        sizeof(values) / sizeof(u32));
        if (count < 0)
index 01b6e86..f1a249a 100644 (file)
@@ -149,7 +149,7 @@ int mrc_locate_spd(struct udevice *dev, int size, const void **spd_datap)
        spd_index = dm_gpio_get_values_as_int(desc, ret);
        debug("spd index %d\n", spd_index);
 
-       node = fdt_first_subnode(blob, dev->of_offset);
+       node = fdt_first_subnode(blob, dev_of_offset(dev));
        if (node < 0)
                return -EINVAL;
        for (spd_node = fdt_first_subnode(blob, node);
index d2901de..f5654eb 100644 (file)
@@ -96,7 +96,7 @@ static int create_pirq_routing_table(struct udevice *dev)
        int i;
        int ret;
 
-       node = dev->of_offset;
+       node = dev_of_offset(dev);
 
        /* extract the bdf from fdt_pci_addr */
        priv->bdf = dm_pci_get_bdf(dev->parent);
index aef1206..4e254b3 100644 (file)
@@ -86,7 +86,7 @@ static int pch_pirq_init(struct udevice *pch)
 {
        uint8_t route[8], *ptr;
 
-       if (fdtdec_get_byte_array(gd->fdt_blob, pch->of_offset,
+       if (fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(pch),
                                  "intel,pirq-routing", route, sizeof(route)))
                return -EINVAL;
        ptr = route;
@@ -113,7 +113,7 @@ static int pch_gpi_routing(struct udevice *pch)
        u32 reg;
        int gpi;
 
-       if (fdtdec_get_byte_array(gd->fdt_blob, pch->of_offset,
+       if (fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(pch),
                                  "intel,gpi-routing", route, sizeof(route)))
                return -EINVAL;
 
@@ -128,7 +128,7 @@ static int pch_gpi_routing(struct udevice *pch)
 static int pch_power_options(struct udevice *pch)
 {
        const void *blob = gd->fdt_blob;
-       int node = pch->of_offset;
+       int node = dev_of_offset(pch);
        u8 reg8;
        u16 reg16, pmbase;
        u32 reg32;
index d5f3219..81dedee 100644 (file)
@@ -288,8 +288,8 @@ static int configure_thermal_target(struct udevice *dev)
        int tcc_offset;
        msr_t msr;
 
-       tcc_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "tcc-offset",
-                                   0);
+       tcc_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+                                   "tcc-offset", 0);
 
        /* Set TCC activaiton offset if supported */
        msr = msr_read(MSR_PLATFORM_INFO);
index c7ffbc1..0f5e190 100644 (file)
@@ -39,7 +39,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
 {
        unsigned int port_map, speed_support, port_tx;
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const char *mode;
        u32 reg32;
        u16 reg16;
@@ -190,7 +190,7 @@ static void bd82x6x_sata_init(struct udevice *dev, struct udevice *pch)
 static void bd82x6x_sata_enable(struct udevice *dev)
 {
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        unsigned port_map;
        const char *mode;
        u16 map = 0;
index 2b6b3bd..988073c 100644 (file)
@@ -568,7 +568,8 @@ int mp_init_cpu(struct udevice *cpu, void *unused)
         * seq num in the uclass_resolve_seq() during device_probe(). To avoid
         * this, set req_seq to the reg number in the device tree in advance.
         */
-       cpu->req_seq = fdtdec_get_int(gd->fdt_blob, cpu->of_offset, "reg", -1);
+       cpu->req_seq = fdtdec_get_int(gd->fdt_blob, dev_of_offset(cpu), "reg",
+                                     -1);
        plat->ucode_version = microcode_read_rev();
        plat->device_id = gd->arch.x86_device;
 
index 17e977c..a6e493d 100644 (file)
@@ -304,7 +304,8 @@ static int mptable_add_intsrc(struct mp_config_table *mc,
        }
 
        /* Get I/O interrupt information from device tree */
-       cell = fdt_getprop(blob, dev->of_offset, "intel,pirq-routing", &len);
+       cell = fdt_getprop(blob, dev_of_offset(dev), "intel,pirq-routing",
+                          &len);
        if (!cell)
                return -ENOENT;
 
index fb2d294..406852d 100644 (file)
@@ -187,7 +187,7 @@ static int ich6_pinctrl_probe(struct udevice *dev)
                return -EINVAL;
        }
 
-       for (pin_node = fdt_first_subnode(gd->fdt_blob, dev->of_offset);
+       for (pin_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
             pin_node > 0;
             pin_node = fdt_next_subnode(gd->fdt_blob, pin_node)) {
                /* Configure the pin */
index 1fa5664..818ae04 100644 (file)
@@ -44,7 +44,8 @@ int board_prepare_usb(enum usb_init_type type)
 
        /* Try to request gpios needed to start usb host on dragonboard */
        if (!dm_gpio_is_valid(&hub_reset)) {
-               node = fdt_subnode_offset(gd->fdt_blob, pmic_gpio->of_offset,
+               node = fdt_subnode_offset(gd->fdt_blob,
+                                         dev_of_offset(pmic_gpio),
                                          "usb_hub_reset_pm");
                if (node < 0) {
                        printf("Failed to find usb_hub_reset_pm dt node.\n");
@@ -59,7 +60,8 @@ int board_prepare_usb(enum usb_init_type type)
        }
 
        if (!dm_gpio_is_valid(&usb_sel)) {
-               node = fdt_subnode_offset(gd->fdt_blob, pmic_gpio->of_offset,
+               node = fdt_subnode_offset(gd->fdt_blob,
+                                         dev_of_offset(pmic_gpio),
                                          "usb_sw_sel_pm");
                if (node < 0) {
                        printf("Failed to find usb_sw_sel_pm dt node.\n");
@@ -110,7 +112,8 @@ int misc_init_r(void)
                return 0;
        }
 
-       node = fdt_subnode_offset(gd->fdt_blob, pon->of_offset, "key_vol_down");
+       node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
+                                 "key_vol_down");
        if (node < 0) {
                printf("Failed to find key_vol_down node. Check device tree\n");
                return 0;
index 1b5ccec..fea324e 100644 (file)
@@ -684,7 +684,7 @@ steps (see device_probe()):
 
    g. If the driver provides an ofdata_to_platdata() method, then this is
    called to convert the device tree data into platform data. This should
-   do various calls like fdtdec_get_int(gd->fdt_blob, dev->of_offset, ...)
+   do various calls like fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), ...)
    to access the node and store the resulting information into dev->platdata.
    After this point, the device works the same way whether it was bound
    using a device tree node or U_BOOT_DEVICE() structure. In either case,
index 86e5e25..0063bfe 100644 (file)
@@ -205,7 +205,7 @@ For example:
             /* Decode the device tree data */
             struct mmc_platdata *plat = dev_get_platdata(dev);
             const void *blob = gd->fdt_blob;
-            int node = dev->of_offset;
+            int node = dev_of_offset(dev);
 
             plat->fifo_depth = fdtdec_get_int(blob, node, "fifo-depth", 0);
     #endif
index ee4abf4..1955ffe 100644 (file)
@@ -223,7 +223,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus)
 {
        struct exynos_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, "reg");
        plat->periph_id = pinmux_decode_periph_id(blob, node);
index 9233fcd..3e28a56 100644 (file)
@@ -345,7 +345,7 @@ nodev:
 static int adc_vdd_platdata_set(struct udevice *dev)
 {
        struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev);
-       int ret, offset = dev->of_offset;
+       int ret, offset = dev_of_offset(dev);
        const void *fdt = gd->fdt_blob;
        char *prop;
 
@@ -366,7 +366,7 @@ static int adc_vdd_platdata_set(struct udevice *dev)
 static int adc_vss_platdata_set(struct udevice *dev)
 {
        struct adc_uclass_platdata *uc_pdata = dev_get_uclass_platdata(dev);
-       int ret, offset = dev->of_offset;
+       int ret, offset = dev_of_offset(dev);
        const void *fdt = gd->fdt_blob;
        char *prop;
 
index d36f64f..ac27d3e 100644 (file)
@@ -154,9 +154,8 @@ static int generic_clk_ofdata_to_platdata(struct udevice *dev)
        u32 num_parents;
 
        num_parents = fdtdec_get_int_array_count(gd->fdt_blob,
-                                                dev_get_parent(dev)->of_offset,
-                                                "clocks", cells,
-                                                GENERATED_SOURCE_MAX);
+                       dev_of_offset(dev_get_parent(dev)), "clocks", cells,
+                       GENERATED_SOURCE_MAX);
 
        if (!num_parents)
                return -1;
index 76ba91a..c73156a 100644 (file)
@@ -47,7 +47,7 @@ int at91_pmc_core_probe(struct udevice *dev)
 int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name)
 {
        const void *fdt = gd->fdt_blob;
-       int offset = dev->of_offset;
+       int offset = dev_of_offset(dev);
        bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);
        const char *name;
        int ret;
@@ -90,7 +90,8 @@ int at91_clk_of_xlate(struct clk *clk, struct fdtdec_phandle_args *args)
                return -EINVAL;
        }
 
-       periph = fdtdec_get_uint(gd->fdt_blob, clk->dev->of_offset, "reg", -1);
+       periph = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(clk->dev), "reg",
+                                -1);
        if (periph < 0)
                return -EINVAL;
 
index 153ceba..6fcfd69 100644 (file)
@@ -65,7 +65,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
        debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk);
 
        assert(clk);
-       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
                                             "clocks", "#clock-cells", 0, index,
                                             &args);
        if (ret) {
@@ -104,7 +104,7 @@ int clk_get_by_name(struct udevice *dev, const char *name, struct clk *clk)
 
        debug("%s(dev=%p, name=%s, clk=%p)\n", __func__, dev, name, clk);
 
-       index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset,
+       index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
                                      "clock-names", name);
        if (index < 0) {
                debug("fdt_stringlist_search() failed: %d\n", index);
index 9c4d2b3..3911bf6 100644 (file)
@@ -32,7 +32,7 @@ static int clk_fixed_rate_ofdata_to_platdata(struct udevice *dev)
 {
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
        to_clk_fixed_rate(dev)->fixed_rate =
-                               fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+                               fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                               "clock-frequency", 0);
 #endif
 
index 70ec354..f6eef31 100644 (file)
@@ -330,7 +330,7 @@ static void pic32_clk_init(struct udevice *dev)
        for (i = REF1CLK; i <= REF5CLK; i++) {
                snprintf(propname, sizeof(propname),
                         "microchip,refo%d-frequency", i - REF1CLK + 1);
-               rate = fdtdec_get_int(blob, dev->of_offset, propname, 0);
+               rate = fdtdec_get_int(blob, dev_of_offset(dev), propname, 0);
                if (rate)
                        pic32_set_refclk(priv, i, pll_hz, rate, ROCLK_SRC_SPLL);
        }
@@ -393,7 +393,8 @@ static int pic32_clk_probe(struct udevice *dev)
        fdt_addr_t addr;
        fdt_size_t size;
 
-       addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
+       addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg",
+                                   &size);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
index ed553d7..70fcfc2 100644 (file)
@@ -355,7 +355,7 @@ int device_probe(struct udevice *dev)
                        goto fail;
        }
 
-       if (drv->ofdata_to_platdata && dev->of_offset >= 0) {
+       if (drv->ofdata_to_platdata && dev_of_offset(dev) >= 0) {
                ret = drv->ofdata_to_platdata(dev);
                if (ret)
                        goto fail;
@@ -524,7 +524,7 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset,
        *devp = NULL;
 
        list_for_each_entry(dev, &parent->child_head, sibling_node) {
-               if (dev->of_offset == of_offset) {
+               if (dev_of_offset(dev) == of_offset) {
                        *devp = dev;
                        return 0;
                }
@@ -549,7 +549,7 @@ static struct udevice *_device_find_global_by_of_offset(struct udevice *parent,
 {
        struct udevice *dev, *found;
 
-       if (parent->of_offset == of_offset)
+       if (dev_of_offset(parent) == of_offset)
                return parent;
 
        list_for_each_entry(dev, &parent->child_head, sibling_node) {
@@ -637,19 +637,21 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
                int len = 0;
                int na, ns;
 
-               na = fdt_address_cells(gd->fdt_blob, dev->parent->of_offset);
+               na = fdt_address_cells(gd->fdt_blob,
+                                      dev_of_offset(dev->parent));
                if (na < 1) {
                        debug("bad #address-cells\n");
                        return FDT_ADDR_T_NONE;
                }
 
-               ns = fdt_size_cells(gd->fdt_blob, dev->parent->of_offset);
+               ns = fdt_size_cells(gd->fdt_blob, dev_of_offset(dev->parent));
                if (ns < 0) {
                        debug("bad #size-cells\n");
                        return FDT_ADDR_T_NONE;
                }
 
-               reg = fdt_getprop(gd->fdt_blob, dev->of_offset, "reg", &len);
+               reg = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "reg",
+                                 &len);
                if (!reg || (len <= (index * sizeof(fdt32_t) * (na + ns)))) {
                        debug("Req index out of range\n");
                        return FDT_ADDR_T_NONE;
@@ -662,16 +664,15 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
                 * bus setups.
                 */
                addr = fdt_translate_address((void *)gd->fdt_blob,
-                                            dev->of_offset, reg);
+                                            dev_of_offset(dev), reg);
        } else {
                /*
                 * Use the "simple" translate function for less complex
                 * bus setups.
                 */
                addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-                                                       dev->parent->of_offset,
-                                                       dev->of_offset, "reg",
-                                                       index, NULL, false);
+                               dev_of_offset(dev->parent), dev_of_offset(dev),
+                               "reg", index, NULL, false);
                if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
                        if (device_get_uclass_id(dev->parent) ==
                            UCLASS_SIMPLE_BUS)
@@ -702,7 +703,7 @@ fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index,
         * next call to the exisiting dev_get_xxx function which handles
         * all config options.
         */
-       fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset,
+       fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev_of_offset(dev),
                                           "reg", index, size, false);
 
        /*
@@ -720,7 +721,7 @@ fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name)
 #if CONFIG_IS_ENABLED(OF_CONTROL)
        int index;
 
-       index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset,
+       index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
                                      "reg-names", name);
        if (index < 0)
                return index;
@@ -799,7 +800,7 @@ bool of_device_is_compatible(struct udevice *dev, const char *compat)
 {
        const void *fdt = gd->fdt_blob;
 
-       return !fdt_node_check_compatible(fdt, dev->of_offset, compat);
+       return !fdt_node_check_compatible(fdt, dev_of_offset(dev), compat);
 }
 
 bool of_machine_is_compatible(const char *compat)
index c68bcba..833cd78 100644 (file)
@@ -71,12 +71,12 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
        int parent;
        int len;
 
-       parent = dev->parent->of_offset;
+       parent = dev_of_offset(dev->parent);
        addr_len = fdt_address_cells(blob, parent);
        size_len = fdt_size_cells(blob, parent);
        both_len = addr_len + size_len;
 
-       cell = fdt_getprop(blob, dev->of_offset, "reg", &len);
+       cell = fdt_getprop(blob, dev_of_offset(dev), "reg", &len);
        len /= sizeof(*cell);
        count = len / both_len;
        if (!cell || !count)
index 9edfc1e..175fd3f 100644 (file)
@@ -227,10 +227,10 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
 
 int dm_scan_fdt_dev(struct udevice *dev)
 {
-       if (dev->of_offset == -1)
+       if (dev_of_offset(dev) == -1)
                return 0;
 
-       return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset,
+       return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev),
                                gd->flags & GD_FLG_RELOC ? false : true);
 }
 
index 5c955da..6be269f 100644 (file)
@@ -30,7 +30,7 @@ static int simple_bus_post_bind(struct udevice *dev)
        u32 cell[3];
        int ret;
 
-       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "ranges",
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "ranges",
                                   cell, ARRAY_SIZE(cell));
        if (!ret) {
                struct simple_bus_plat *plat = dev_get_uclass_platdata(dev);
index 60610e5..7de3706 100644 (file)
@@ -278,7 +278,7 @@ int uclass_find_device_by_of_offset(enum uclass_id id, int node,
                return ret;
 
        list_for_each_entry(dev, &uc->dev_head, uclass_node) {
-               if (dev->of_offset == node) {
+               if (dev_of_offset(dev) == node) {
                        *devp = dev;
                        return 0;
                }
@@ -299,7 +299,7 @@ static int uclass_find_device_by_phandle(enum uclass_id id,
        int ret;
 
        *devp = NULL;
-       find_phandle = fdtdec_get_int(gd->fdt_blob, parent->of_offset, name,
+       find_phandle = fdtdec_get_int(gd->fdt_blob, dev_of_offset(parent), name,
                                      -1);
        if (find_phandle <= 0)
                return -ENOENT;
@@ -308,7 +308,9 @@ static int uclass_find_device_by_phandle(enum uclass_id id,
                return ret;
 
        list_for_each_entry(dev, &uc->dev_head, uclass_node) {
-               uint phandle = fdt_get_phandle(gd->fdt_blob, dev->of_offset);
+               uint phandle;
+
+               phandle = fdt_get_phandle(gd->fdt_blob, dev_of_offset(dev));
 
                if (phandle == find_phandle) {
                        *devp = dev;
index d908736..7e71f3b 100644 (file)
@@ -151,7 +151,7 @@ static int shape_ofdata_to_platdata(struct udevice *dev)
                return ret;
 
        /* Parse the data that only we need */
-       pdata->default_char = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       pdata->default_char = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                             "character", '@');
 
        return 0;
index 725f068..3341572 100644 (file)
@@ -66,7 +66,7 @@ int demo_set_light(struct udevice *dev, int light)
 int demo_parse_dt(struct udevice *dev)
 {
        struct dm_demo_pdata *pdata = dev_get_platdata(dev);
-       int dn = dev->of_offset;
+       int dn = dev_of_offset(dev);
 
        pdata->sides = fdtdec_get_int(gd->fdt_blob, dn, "sides", 0);
        pdata->colour = fdt_getprop(gd->fdt_blob, dn, "colour", NULL);
index 9ac10a7..750eedf 100644 (file)
@@ -130,7 +130,7 @@ static int gen_74x164_probe(struct udevice *dev)
        char *str, name[32];
        int ret;
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        snprintf(name, sizeof(name), "%s_", dev->name);
        str = strdup(name);
index 6f42bf8..92849c5 100644 (file)
@@ -92,9 +92,9 @@ static int altera_pio_ofdata_to_platdata(struct udevice *dev)
        plat->regs = map_physmem(dev_get_addr(dev),
                                 sizeof(struct altera_pio_regs),
                                 MAP_NOCACHE);
-       plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                "altr,gpio-bank-width", 32);
-       plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                "gpio-bank-name", NULL);
 
        return 0;
index cb90b02..81c3047 100644 (file)
@@ -276,7 +276,7 @@ static const struct dm_gpio_ops atmel_pio4_ops = {
 
 static int atmel_pio4_bind(struct udevice *dev)
 {
-       return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
+       return dm_scan_fdt_node(dev, gd->fdt_blob, dev_of_offset(dev), false);
 }
 
 static int atmel_pio4_probe(struct udevice *dev)
@@ -308,7 +308,8 @@ static int atmel_pio4_probe(struct udevice *dev)
        pioctrl_data = (struct atmel_pioctrl_data *)dev_get_driver_data(dev);
        nbanks = pioctrl_data->nbanks;
 
-       uc_priv->bank_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL);
+       uc_priv->bank_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev),
+                                         NULL);
        uc_priv->gpio_count = nbanks * ATMEL_PIO_NPINS_PER_BANK;
 
        return 0;
index 85e0a86..7d1904c 100644 (file)
@@ -112,13 +112,13 @@ static int gpio_dwapb_bind(struct udevice *dev)
        if (plat)
                return 0;
 
-       base = fdtdec_get_addr(blob, dev->of_offset, "reg");
+       base = fdtdec_get_addr(blob, dev_of_offset(dev), "reg");
        if (base == FDT_ADDR_T_NONE) {
                debug("Can't get the GPIO register base address\n");
                return -ENXIO;
        }
 
-       for (node = fdt_first_subnode(blob, dev->of_offset);
+       for (node = fdt_first_subnode(blob, dev_of_offset(dev));
             node > 0;
             node = fdt_next_subnode(blob, node)) {
                if (!fdtdec_get_bool(blob, node, "gpio-controller"))
@@ -142,7 +142,7 @@ static int gpio_dwapb_bind(struct udevice *dev)
                if (ret)
                        goto err;
 
-               subdev->of_offset = node;
+               dev_set_of_offset(subdev, node);
                bank++;
        }
 
index 4559739..9ab9df4 100644 (file)
@@ -707,7 +707,7 @@ int gpio_request_by_name(struct udevice *dev,  const char *list_name, int index,
         * calls in gpio_request_by_name(), but we can do this until
         * gpio_request_by_name_nodev() can be dropped.
         */
-       return gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset,
+       return gpio_request_by_name_nodev(gd->fdt_blob, dev_of_offset(dev),
                                          list_name, index, desc, flags);
 }
 
@@ -746,7 +746,7 @@ int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
         * calls in gpio_request_by_name(), but we can do this until
         * gpio_request_list_by_name_nodev() can be dropped.
         */
-       return gpio_request_list_by_name_nodev(gd->fdt_blob, dev->of_offset,
+       return gpio_request_list_by_name_nodev(gd->fdt_blob, dev_of_offset(dev),
                                               list_name, desc, max_count,
                                               flags);
 }
@@ -755,7 +755,7 @@ int gpio_get_list_count(struct udevice *dev, const char *list_name)
 {
        int ret;
 
-       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
                                             list_name, "#gpio-cells", 0, -1,
                                             NULL);
        if (ret) {
index 81ce446..790577a 100644 (file)
@@ -149,14 +149,14 @@ static int broadwell_gpio_ofdata_to_platdata(struct udevice *dev)
        if (ret)
                return ret;
 
-       bank = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+       bank = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
        if (bank == -1) {
                debug("%s: Invalid bank number %d\n", __func__, bank);
                return -EINVAL;
        }
        plat->bank = bank;
        plat->base_addr = gpiobase;
-       plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                                      "bank-name", NULL);
 
        return 0;
index fd6181f..8b78226 100644 (file)
@@ -94,14 +94,14 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)
        if (ret)
                return ret;
 
-       offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+       offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
        if (offset == -1) {
                debug("%s: Invalid register offset %d\n", __func__, offset);
                return -EINVAL;
        }
        plat->offset = offset;
        plat->base_addr = gpiobase + offset;
-       plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       plat->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                                      "bank-name", NULL);
 
        return 0;
index 9674ee7..1bf945a 100644 (file)
@@ -297,7 +297,7 @@ static int lpc32xx_gpio_probe(struct udevice *dev)
        struct lpc32xx_gpio_priv *gpio_priv = dev_get_priv(dev);
        struct gpio_dev_priv *uc_priv = dev->uclass_priv;
 
-       if (dev->of_offset == -1) {
+       if (dev_of_offset(dev) == -1) {
                /* Tell the uclass how many GPIOs we have */
                uc_priv->gpio_count = LPC32XX_GPIOS;
        }
index 168c696..cfeb6e7 100644 (file)
@@ -169,13 +169,13 @@ static int mpc85xx_gpio_ofdata_to_platdata(struct udevice *dev) {
        fdt_addr_t addr;
        fdt_size_t size;
 
-       addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset,
-                                                 "reg", 0, &size, false);
+       addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob,
+                       dev_of_offset(dev), "reg", 0, &size, false);
 
        plat->addr = addr;
        plat->size = size;
-       plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-                                                 "ngpios", 32);
+       plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+                                     "ngpios", 32);
 
        return 0;
 }
index 0302979..01ce1d6 100644 (file)
@@ -106,9 +106,9 @@ static int msm_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,
+       uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                             "gpio-count", 0);
-       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                                         "gpio-bank-name", NULL);
        if (uc_priv->bank_name == NULL)
                uc_priv->bank_name = "soc";
index f906b97..5338552 100644 (file)
@@ -320,7 +320,7 @@ static int omap_gpio_bind(struct udevice *dev)
                return -ENOMEM;
 
        plat->base = base_addr;
-       plat->port_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL);
+       plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
        dev->platdata = plat;
 
        return 0;
index 0410add..b81f0fa 100644 (file)
@@ -265,7 +265,7 @@ static int pca953x_probe(struct udevice *dev)
                return -ENODEV;
        }
 
-       addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", 0);
+       addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
        if (addr == 0)
                return -ENODEV;
 
index 2bda0ff..2cbb9e6 100644 (file)
@@ -131,15 +131,15 @@ static int pcf8575_ofdata_platdata(struct udevice *dev)
 
        int n_latch;
 
-       uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                             "gpio-count", 16);
-       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                                         "gpio-bank-name", NULL);
        if (!uc_priv->bank_name)
                uc_priv->bank_name = fdt_get_name(gd->fdt_blob,
-                                                 dev->of_offset, NULL);
+                                                 dev_of_offset(dev), NULL);
 
-       n_latch = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       n_latch = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                  "lines-initial-states", 0);
        plat->out = ~n_latch;
 
index 7a037f3..e838ad4 100644 (file)
@@ -133,7 +133,8 @@ static int pic32_gpio_probe(struct udevice *dev)
        char *end;
        int bank;
 
-       addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
+       addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg",
+                                   &size);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
index 0b61975..e38cee8 100644 (file)
@@ -193,9 +193,9 @@ static int pm8916_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,
+       uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                             "gpio-count", 0);
-       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                                         "gpio-bank-name", NULL);
        if (uc_priv->bank_name == NULL)
                uc_priv->bank_name = "pm8916";
index 377fed4..042996e 100644 (file)
@@ -317,7 +317,7 @@ static int gpio_exynos_bind(struct udevice *parent)
                return 0;
 
        base = (struct s5p_gpio_bank *)dev_get_addr(parent);
-       for (node = fdt_first_subnode(blob, parent->of_offset), bank = base;
+       for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base;
             node > 0;
             node = fdt_next_subnode(blob, node), bank++) {
                struct exynos_gpio_platdata *plat;
@@ -337,7 +337,7 @@ static int gpio_exynos_bind(struct udevice *parent)
                if (ret)
                        return ret;
 
-               dev->of_offset = node;
+               dev_set_of_offset(dev, node);
 
                reg = dev_get_addr(dev);
                if (reg != FDT_ADDR_T_NONE)
index f6435a0..ae6d930 100644 (file)
@@ -197,9 +197,9 @@ 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,
+       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,
+       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                                         "gpio-bank-name", NULL);
 
        return 0;
@@ -209,7 +209,7 @@ static int gpio_sandbox_probe(struct udevice *dev)
 {
        struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
-       if (dev->of_offset == -1) {
+       if (dev_of_offset(dev) == -1) {
                /* Tell the uclass how many GPIOs we have */
                uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT;
        }
index e8accaa..8d2bb18 100644 (file)
@@ -312,7 +312,7 @@ static int gpio_sunxi_bind(struct udevice *parent)
                                        plat->bank_name, plat, -1, &dev);
                if (ret)
                        return ret;
-               dev->of_offset = parent->of_offset;
+               dev_set_of_offset(dev, dev_of_offset(parent));
        }
 
        return 0;
index 1c68151..b0c22e5 100644 (file)
@@ -197,7 +197,7 @@ static int tegra186_gpio_bind(struct udevice *parent)
                                  -1, &dev);
                if (ret)
                        return ret;
-               dev->of_offset = parent->of_offset;
+               dev_set_of_offset(dev, dev_of_offset(parent));
        }
 
        return 0;
index 5a03115..b01968a 100644 (file)
@@ -337,7 +337,8 @@ static int gpio_tegra_bind(struct udevice *parent)
         * This driver does not make use of interrupts, other than to figure
         * out the number of GPIO banks
         */
-       if (!fdt_getprop(gd->fdt_blob, parent->of_offset, "interrupts", &len))
+       if (!fdt_getprop(gd->fdt_blob, dev_of_offset(parent), "interrupts",
+                        &len))
                return -EINVAL;
        bank_count = len / 3 / sizeof(u32);
        ctlr = (struct gpio_ctlr *)dev_get_addr(parent);
@@ -363,7 +364,7 @@ static int gpio_tegra_bind(struct udevice *parent)
                                          plat->port_name, plat, -1, &dev);
                        if (ret)
                                return ret;
-                       dev->of_offset = parent->of_offset;
+                       dev_set_of_offset(dev, dev_of_offset(parent));
                }
        }
 
index a30ba5d..458104e 100644 (file)
@@ -129,7 +129,7 @@ static int vybrid_gpio_bind(struct udevice *dev)
 
        plat->base = base_addr;
        plat->chip = dev->req_seq;
-       plat->port_name = fdt_get_name(gd->fdt_blob, dev->of_offset, NULL);
+       plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
        dev->platdata = plat;
 
        return 0;
index 4bc54ee..5a63669 100644 (file)
@@ -242,7 +242,7 @@ static int at91_i2c_ofdata_to_platdata(struct udevice *dev)
 {
        const void *blob = gd->fdt_blob;
        struct at91_i2c_bus *bus = dev_get_priv(dev);
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        bus->regs = (struct at91_i2c_regs *)dev_get_addr(dev);
        bus->pdata = (struct at91_i2c_pdata *)dev_get_driver_data(dev);
index 9cf8e7d..86fa684 100644 (file)
@@ -34,7 +34,7 @@ static int cros_ec_i2c_ofdata_to_platdata(struct udevice *dev)
 {
        struct cros_ec_i2c_bus *i2c_bus = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        i2c_bus->remote_bus = fdtdec_get_uint(blob, node, "google,remote-bus",
                                              0);
index 9521aeb..2dd75fd 100644 (file)
@@ -522,7 +522,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
        struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
        int node;
 
-       node = dev->of_offset;
+       node = dev_of_offset(dev);
 
        i2c_bus->hsregs = (struct exynos5_hsi2c *)dev_get_addr(dev);
 
index c3f826d..e9fbf82 100644 (file)
@@ -585,21 +585,21 @@ static int fsl_i2c_ofdata_to_platdata(struct udevice *bus)
        struct fsl_i2c_dev *dev = dev_get_priv(bus);
        fdt_addr_t addr;
        fdt_size_t size;
+       int node = dev_of_offset(bus);
 
-       addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, bus->of_offset,
-                                                 "reg", 0, &size, false);
+       addr = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, node, "reg", 0,
+                                                 &size, false);
 
        dev->base = map_sysmem(CONFIG_SYS_IMMR + addr, size);
 
        if (!dev->base)
                return -ENOMEM;
 
-       dev->index = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
-                                   "cell-index", -1);
-       dev->slaveadd = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+       dev->index = fdtdec_get_int(gd->fdt_blob, node, "cell-index", -1);
+       dev->slaveadd = fdtdec_get_int(gd->fdt_blob, node,
                                       "u-boot,i2c-slave-addr", 0x7f);
-       dev->speed = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
-                                   "clock-frequency", 400000);
+       dev->speed = fdtdec_get_int(gd->fdt_blob, node, "clock-frequency",
+                                   400000);
 
        dev->i2c_clk = dev->index ? gd->arch.i2c2_clk : gd->arch.i2c1_clk;
 
index a8b83c5..aeeb304 100644 (file)
@@ -309,7 +309,7 @@ static int i2c_gpio_ofdata_to_platdata(struct udevice *dev)
 {
        struct i2c_gpio_bus *bus = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        ret = gpio_request_list_by_name(dev, "gpios", bus->gpios,
index dbd3789..f3184c7 100644 (file)
@@ -489,7 +489,7 @@ static int i2c_post_probe(struct udevice *dev)
 #if CONFIG_IS_ENABLED(OF_CONTROL)
        struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
 
-       i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                     "clock-frequency", 100000);
 
        return dm_i2c_set_bus_speed(dev, i2c->speed_hz);
@@ -503,10 +503,11 @@ static int i2c_child_post_bind(struct udevice *dev)
 #if CONFIG_IS_ENABLED(OF_CONTROL)
        struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
 
-       if (dev->of_offset == -1)
+       if (dev_of_offset(dev) == -1)
                return 0;
 
-       return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat);
+       return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev),
+                                          plat);
 #else
        return 0;
 #endif
index 3f072c7..66ce7ec 100644 (file)
@@ -89,7 +89,7 @@ static int i2c_arbitrator_probe(struct udevice *dev)
 {
        struct i2c_arbitrator_priv *priv = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        debug("%s: %s\n", __func__, dev->name);
index db086ef..d243b8e 100644 (file)
@@ -40,7 +40,7 @@ static int i2c_mux_child_post_bind(struct udevice *dev)
        struct i2c_mux_bus *plat = dev_get_parent_platdata(dev);
        int channel;
 
-       channel = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+       channel = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", -1);
        if (channel < 0)
                return -EINVAL;
        plat->channel = channel;
@@ -60,7 +60,7 @@ static int i2c_mux_post_bind(struct udevice *mux)
         * There is no compatible string in the sub-nodes, so we must manually
         * bind these
         */
-       for (offset = fdt_first_subnode(blob, mux->of_offset);
+       for (offset = fdt_first_subnode(blob, dev_of_offset(mux));
             offset > 0;
             offset = fdt_next_subnode(blob, offset)) {
                struct udevice *dev;
index 7e0d2da..1a67618 100644 (file)
@@ -51,7 +51,7 @@ static int pca954x_ofdata_to_platdata(struct udevice *dev)
 {
        struct pca954x_priv *priv = dev_get_priv(dev);
 
-       priv->addr = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", 0);
+       priv->addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
        if (!priv->addr) {
                debug("MUX not found\n");
                return -ENODEV;
index cea3da0..648a96e 100644 (file)
@@ -775,11 +775,11 @@ static int mvtwsi_i2c_ofdata_to_platdata(struct udevice *bus)
        if (!dev->base)
                return -ENOMEM;
 
-       dev->index = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+       dev->index = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
                                    "cell-index", -1);
-       dev->slaveadd = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+       dev->slaveadd = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
                                       "u-boot,i2c-slave-addr", 0x0);
-       dev->speed = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+       dev->speed = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
                                    "clock-frequency", 100000);
        return 0;
 }
index 94d9027..eb789f5 100644 (file)
@@ -750,7 +750,7 @@ static int mxc_i2c_probe(struct udevice *bus)
 {
        struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus);
        const void *fdt = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
        fdt_addr_t addr;
        int ret, ret2;
 
index 363cd04..3c69dbf 100644 (file)
@@ -312,7 +312,7 @@ static int s3c_i2c_ofdata_to_platdata(struct udevice *dev)
        struct s3c24x0_i2c_bus *i2c_bus = dev_get_priv(dev);
        int node;
 
-       node = dev->of_offset;
+       node = dev_of_offset(dev);
 
        i2c_bus->regs = (struct s3c24x0_i2c *)dev_get_addr(dev);
 
index 513c414..931c6de 100644 (file)
@@ -90,7 +90,7 @@ static int tegra186_bpmp_i2c_probe(struct udevice *dev)
 {
        struct tegra186_bpmp_i2c *priv = dev_get_priv(dev);
 
-       priv->bpmp_bus_id = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       priv->bpmp_bus_id = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                            "nvidia,bpmp-bus-id", U32_MAX);
        if (priv->bpmp_bus_id == U32_MAX) {
                debug("%s: could not parse nvidia,bpmp-bus-id\n", __func__);
index 9bc4555..00381dc 100644 (file)
@@ -189,7 +189,7 @@ static int cros_ec_kbd_probe(struct udevice *dev)
        struct stdio_dev *sdev = &uc_priv->sdev;
        struct input_config *input = &uc_priv->input;
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        if (cros_ec_keyb_decode_fdt(blob, node, priv))
index 03d4840..0fd25b1 100644 (file)
@@ -315,7 +315,7 @@ static int i8042_kbd_probe(struct udevice *dev)
        struct input_config *input = &uc_priv->input;
        int ret;
 
-       if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+       if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
                            "intel,duplicate-por"))
                priv->quirks |= QUIRK_DUP_POR;
 
index c77f610..d36f1a1 100644 (file)
@@ -290,7 +290,7 @@ static int tegra_kbd_probe(struct udevice *dev)
        struct keyboard_priv *uc_priv = dev_get_uclass_priv(dev);
        struct stdio_dev *sdev = &uc_priv->sdev;
        struct input_config *input = &uc_priv->input;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        priv->kbc = (struct kbc_tegra *)dev_get_addr(dev);
index cb6e996..5b11990 100644 (file)
@@ -62,7 +62,7 @@ static int led_gpio_bind(struct udevice *parent)
        int node;
        int ret;
 
-       for (node = fdt_first_subnode(blob, parent->of_offset);
+       for (node = fdt_first_subnode(blob, dev_of_offset(parent));
             node > 0;
             node = fdt_next_subnode(blob, node)) {
                struct led_uclass_plat *uc_plat;
index a7fcde5..38448de 100644 (file)
@@ -41,7 +41,7 @@ int mbox_get_by_index(struct udevice *dev, int index, struct mbox_chan *chan)
 
        debug("%s(dev=%p, index=%d, chan=%p)\n", __func__, dev, index, chan);
 
-       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
                                             "mboxes", "#mbox-cells", 0,
                                             index, &args);
        if (ret) {
@@ -85,7 +85,7 @@ int mbox_get_by_name(struct udevice *dev, const char *name,
 
        debug("%s(dev=%p, name=%s, chan=%p)\n", __func__, dev, name, chan);
 
-       index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset,
+       index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
                                      "mbox-names", name);
        if (index < 0) {
                debug("fdt_stringlist_search() failed: %d\n", index);
index 759bb46..3d449b2 100644 (file)
@@ -998,7 +998,7 @@ int cros_ec_register(struct udevice *dev)
 {
        struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        char id[MSG_BYTES];
 
        cdev->dev = dev;
index c4fbca0..848c67b 100644 (file)
@@ -522,7 +522,7 @@ int cros_ec_probe(struct udevice *dev)
        int err;
 
        memcpy(ec, &s_state, sizeof(*ec));
-       err = cros_ec_decode_ec_flash(blob, dev->of_offset, &ec->ec_config);
+       err = cros_ec_decode_ec_flash(blob, dev_of_offset(dev), &ec->ec_config);
        if (err)
                return err;
 
@@ -531,7 +531,7 @@ int cros_ec_probe(struct udevice *dev)
             keyb_dev;
             device_find_next_child(&keyb_dev)) {
                if (device_get_uclass_id(keyb_dev) == UCLASS_KEYBOARD) {
-                       node = keyb_dev->of_offset;
+                       node = dev_of_offset(keyb_dev);
                        break;
                }
        }
index 4410d03..02de8d7 100644 (file)
@@ -115,9 +115,9 @@ static int sandbox_i2c_eeprom_ofdata_to_platdata(struct udevice *dev)
 {
        struct sandbox_i2c_flash_plat_data *plat = dev_get_platdata(dev);
 
-       plat->size = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->size = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                    "sandbox,size", 32);
-       plat->filename = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       plat->filename = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                                     "sandbox,filename", NULL);
        if (!plat->filename) {
                debug("%s: No filename for device '%s'\n", __func__,
index f4ddbea..bd8b960 100644 (file)
@@ -112,19 +112,19 @@ static int tegra186_bpmp_bind(struct udevice *dev)
        debug("%s(dev=%p)\n", __func__, dev);
 
        ret = device_bind_driver_to_node(dev, "tegra186_clk", "tegra186_clk",
-                                        dev->of_offset, &child);
+                                        dev_of_offset(dev), &child);
        if (ret)
                return ret;
 
        ret = device_bind_driver_to_node(dev, "tegra186_reset",
-                                        "tegra186_reset", dev->of_offset,
+                                        "tegra186_reset", dev_of_offset(dev),
                                         &child);
        if (ret)
                return ret;
 
        ret = device_bind_driver_to_node(dev, "tegra186_power_domain",
                                         "tegra186_power_domain",
-                                        dev->of_offset, &child);
+                                        dev_of_offset(dev), &child);
        if (ret)
                return ret;
 
@@ -141,7 +141,7 @@ static ulong tegra186_bpmp_get_shmem(struct udevice *dev, int index)
        struct fdtdec_phandle_args args;
        fdt_addr_t reg;
 
-       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
                                              "shmem", NULL, 0, index, &args);
        if (ret < 0) {
                error("fdtdec_parse_phandle_with_args() failed: %d\n", ret);
index 0eb0096..5db3c37 100644 (file)
@@ -22,12 +22,12 @@ static int tegra_car_bpmp_bind(struct udevice *dev)
        debug("%s(dev=%p)\n", __func__, dev);
 
        ret = device_bind_driver_to_node(dev, "tegra_car_clk", "tegra_car_clk",
-                                        dev->of_offset, &child);
+                                        dev_of_offset(dev), &child);
        if (ret)
                return ret;
 
        ret = device_bind_driver_to_node(dev, "tegra_car_reset",
-                                        "tegra_car_reset", dev->of_offset,
+                                        "tegra_car_reset", dev_of_offset(dev),
                                         &child);
        if (ret)
                return ret;
index 62cb242..8522557 100644 (file)
@@ -75,7 +75,7 @@ static int atmel_sdhci_probe(struct udevice *dev)
        host->ioaddr = (void *)dev_get_addr(dev);
 
        host->quirks = 0;
-       host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                         "bus-width", 4);
 
        caps = sdhci_readl(host, SDHCI_CAPABILITIES);
index c440399..40f7892 100644 (file)
@@ -264,7 +264,7 @@ static int exynos_dwmmc_probe(struct udevice *dev)
        struct dwmci_host *host = &priv->host;
        int err;
 
-       err = exynos_dwmci_get_config(gd->fdt_blob, dev->of_offset, host);
+       err = exynos_dwmci_get_config(gd->fdt_blob, dev_of_offset(dev), host);
        if (err)
                return err;
        err = do_dwmci_init(host);
index 73473c5..adeb5df 100644 (file)
@@ -954,7 +954,7 @@ static int fsl_esdhc_probe(struct udevice *dev)
        struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
        struct fsl_esdhc_priv *priv = dev_get_priv(dev);
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        fdt_addr_t addr;
        unsigned int val;
        int ret;
index 1db683d..7a7e67f 100644 (file)
@@ -50,16 +50,16 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static int msm_sdc_clk_init(struct udevice *dev)
 {
-       uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
-                                       "clock-frequency", 400000);
+       int node = dev_of_offset(dev);
+       uint clk_rate = fdtdec_get_uint(gd->fdt_blob, node, "clock-frequency",
+                                       400000);
        uint clkd[2]; /* clk_id and clk_no */
        int clk_offset;
        struct udevice *clk_dev;
        struct clk clk;
        int ret;
 
-       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "clock", clkd,
-                                  2);
+       ret = fdtdec_get_int_array(gd->fdt_blob, node, "clock", clkd, 2);
        if (ret)
                return ret;
 
@@ -168,17 +168,14 @@ static int msm_ofdata_to_platdata(struct udevice *dev)
        struct udevice *parent = dev->parent;
        struct msm_sdhc *priv = dev_get_priv(dev);
        struct sdhci_host *host = &priv->host;
+       int node = dev_of_offset(dev);
 
        host->name = strdup(dev->name);
        host->ioaddr = (void *)dev_get_addr(dev);
-       host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-                                        "bus-width", 4);
-       host->index = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "index", 0);
+       host->bus_width = fdtdec_get_int(gd->fdt_blob, node, "bus-width", 4);
+       host->index = fdtdec_get_uint(gd->fdt_blob, node, "index", 0);
        priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-                                                             parent->of_offset,
-                                                             dev->of_offset,
-                                                             "reg", 1, NULL,
-                                                             false);
+                       dev_of_offset(parent), node, "reg", 1, NULL, false);
        if (priv->base == (void *)FDT_ADDR_T_NONE ||
            host->ioaddr == (void *)FDT_ADDR_T_NONE)
                return -EINVAL;
index b326846..5bb628d 100644 (file)
@@ -728,7 +728,7 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
 {
        struct omap_hsmmc_data *priv = dev_get_priv(dev);
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        struct mmc_config *cfg;
        int val;
 
index 1e14fa1..9d8a392 100644 (file)
@@ -38,18 +38,18 @@ static int pic32_sdhci_probe(struct udevice *dev)
        fdt_size_t size;
        int ret;
 
-       addr = fdtdec_get_addr_size(fdt, dev->of_offset, "reg", &size);
+       addr = fdtdec_get_addr_size(fdt, dev_of_offset(dev), "reg", &size);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
        host->ioaddr    = ioremap(addr, size);
        host->name      = dev->name;
        host->quirks    = SDHCI_QUIRK_NO_HISPD_BIT;
-       host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       host->bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                        "bus-width", 4);
        host->ops = &pic32_sdhci_ops;
 
-       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
                                   "clock-freq-min-max", f_min_max, 2);
        if (ret) {
                printf("sdhci: clock-freq-min-max not found\n");
index 47db678..c36eda0 100644 (file)
@@ -59,24 +59,24 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
 
        host->name = dev->name;
        host->ioaddr = (void *)dev_get_addr(dev);
-       host->buswidth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                        "bus-width", 4);
        host->get_mmc_clk = rockchip_dwmmc_get_mmc_clk;
        host->priv = dev;
 
        /* use non-removeable as sdcard and emmc as judgement */
-       if (fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "non-removable"))
+       if (fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), "non-removable"))
                host->dev_index = 0;
        else
                host->dev_index = 1;
 
-       priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       priv->fifo_depth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                    "fifo-depth", 0);
        if (priv->fifo_depth < 0)
                return -EINVAL;
-       priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+       priv->fifo_mode = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
                                          "fifo-mode");
-       if (fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
+       if (fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev),
                                 "clock-freq-min-max", priv->minmax, 2))
                return -EINVAL;
 #endif
index 1358864..bd91f91 100644 (file)
@@ -38,7 +38,7 @@ static int arasan_sdhci_probe(struct udevice *dev)
        struct clk clk;
 
 
-       max_frequency = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       max_frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                        "max-frequency", 0);
        ret = clk_get_by_index(dev, 0, &clk);
        if (!ret) {
index 28327d5..640ea02 100644 (file)
@@ -247,7 +247,7 @@ static int s5p_sdhci_probe(struct udevice *dev)
        struct sdhci_host *host = dev_get_priv(dev);
        int ret;
 
-       ret = sdhci_get_config(gd->fdt_blob, dev->of_offset, host);
+       ret = sdhci_get_config(gd->fdt_blob, dev_of_offset(dev), host);
        if (ret)
                return ret;
 
index 0a22e58..d0c3c51 100644 (file)
@@ -70,7 +70,7 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
                return -EINVAL;
        }
 
-       fifo_depth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       fifo_depth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                    "fifo-depth", 0);
        if (fifo_depth < 0) {
                printf("DWMMC: Can't get FIFO depth\n");
@@ -79,7 +79,7 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
 
        host->name = dev->name;
        host->ioaddr = (void *)dev_get_addr(dev);
-       host->buswidth = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       host->buswidth = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                        "bus-width", 4);
        host->clksel = socfpga_dwmci_clksel;
 
@@ -92,9 +92,9 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
        host->bus_hz = clk;
        host->fifoth_val = MSIZE(0x2) |
                RX_WMARK(fifo_depth / 2 - 1) | TX_WMARK(fifo_depth / 2);
-       priv->drvsel = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       priv->drvsel = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                       "drvsel", 3);
-       priv->smplsel = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       priv->smplsel = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                        "smplsel", 0);
        host->priv = priv;
 
index 0211dc7..0df74ef 100644 (file)
@@ -578,8 +578,8 @@ static int tegra_mmc_probe(struct udevice *dev)
        priv->cfg.name = "Tegra SD/MMC";
        priv->cfg.ops = &tegra_mmc_ops;
 
-       bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width",
-                                  1);
+       bus_width = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
+                                  "bus-width", 1);
 
        priv->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
        priv->cfg.host_caps = 0;
index 4af7fdb..7f20ef1 100644 (file)
@@ -705,7 +705,8 @@ static int uniphier_sd_probe(struct udevice *dev)
        plat->cfg.name = dev->name;
        plat->cfg.host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
 
-       switch (fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", 1)) {
+       switch (fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width",
+                              1)) {
        case 8:
                plat->cfg.host_caps |= MMC_MODE_8BIT;
                break;
@@ -719,7 +720,7 @@ static int uniphier_sd_probe(struct udevice *dev)
                return -EINVAL;
        }
 
-       if (fdt_get_property(gd->fdt_blob, dev->of_offset, "non-removable",
+       if (fdt_get_property(gd->fdt_blob, dev_of_offset(dev), "non-removable",
                             NULL))
                priv->caps |= UNIPHIER_SD_CAP_NONREMOVABLE;
 
index 828da11..f678110 100644 (file)
@@ -405,7 +405,8 @@ static int xenon_sdhci_probe(struct udevice *dev)
                armada_3700_soc_pad_voltage_set(host);
 
        host->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_DDR_52MHz;
-       switch (fdtdec_get_int(gd->fdt_blob, dev->of_offset, "bus-width", 1)) {
+       switch (fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "bus-width",
+               1)) {
        case 8:
                host->host_caps |= MMC_MODE_8BIT;
                break;
@@ -455,7 +456,7 @@ static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev)
        if (of_device_is_compatible(dev, "marvell,armada-3700-sdhci"))
                priv->pad_ctrl_reg = (void *)dev_get_addr_index(dev, 1);
 
-       name = fdt_getprop(gd->fdt_blob, dev->of_offset, "marvell,pad-type",
+       name = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "marvell,pad-type",
                           NULL);
        if (name) {
                if (0 == strncmp(name, "sd", 2)) {
index a9148a7..e04964b 100644 (file)
@@ -349,7 +349,7 @@ static int altera_qspi_ofdata_to_platdata(struct udevice *dev)
 {
        struct altera_qspi_platdata *pdata = dev_get_platdata(dev);
        void *blob = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const char *list, *end;
        const fdt32_t *cell;
        void *base;
index e036b88..d440f5c 100644 (file)
@@ -2441,7 +2441,7 @@ unsigned long flash_init (void)
 static int cfi_flash_probe(struct udevice *dev)
 {
        void *blob = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const fdt32_t *cell;
        phys_addr_t addr;
        int parent, addrc, sizec;
index 9166fcd..8ed7874 100644 (file)
@@ -371,7 +371,7 @@ static void pic32_flash_bank_init(flash_info_t *info,
 static int pic32_flash_probe(struct udevice *dev)
 {
        void *blob = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const char *list, *end;
        const fdt32_t *cell;
        unsigned long addr, size;
index 4944059..36a50fe 100644 (file)
@@ -516,7 +516,7 @@ int sandbox_sf_ofdata_to_platdata(struct udevice *dev)
 {
        struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        pdata->filename = fdt_getprop(blob, node, "sandbox,filename", NULL);
        pdata->device_name = fdt_getprop(blob, node, "compatible", NULL);
@@ -641,7 +641,7 @@ int sandbox_spi_get_emul(struct sandbox_state *state,
                debug("%s: busnum=%u, cs=%u: binding SPI flash emulation: ",
                      __func__, busnum, cs);
                ret = sandbox_sf_bind_emul(state, busnum, cs, bus,
-                                          slave->of_offset, slave->name);
+                                          dev_of_offset(slave), slave->name);
                if (ret) {
                        debug("failed (err=%d)\n", ret);
                        return ret;
index 2e378dc..ab7910b 100644 (file)
@@ -919,7 +919,7 @@ int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash)
 #ifdef CONFIG_DM_SPI_FLASH
        fdt_addr_t addr;
        fdt_size_t size;
-       int node = flash->dev->of_offset;
+       int node = dev_of_offset(flash->dev);
 
        addr = fdtdec_get_addr_size(blob, node, "memory-map", &size);
        if (addr == FDT_ADDR_T_NONE) {
index 346f138..f8782bc 100644 (file)
@@ -857,7 +857,7 @@ static int ag7xxx_get_phy_iface_offset(struct udevice *dev)
 {
        int offset;
 
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, "phy");
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), "phy");
        if (offset <= 0) {
                debug("%s: PHY OF node not found (ret=%i)\n", __func__, offset);
                return -EINVAL;
index 92a1b64..d4d17dd 100644 (file)
@@ -576,7 +576,7 @@ static int altera_tse_probe(struct udevice *dev)
        struct eth_pdata *pdata = dev_get_platdata(dev);
        struct altera_tse_priv *priv = dev_get_priv(dev);
        void *blob = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const char *list, *end;
        const fdt32_t *cell;
        void *base, *desc_mem = NULL;
@@ -676,7 +676,8 @@ static int altera_tse_ofdata_to_platdata(struct udevice *dev)
        const char *phy_mode;
 
        pdata->phy_interface = -1;
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+                              NULL);
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
        if (pdata->phy_interface == -1) {
index e828e85..aa52503 100644 (file)
@@ -20,7 +20,7 @@ static int davinci_emac_3517_get_macid(struct udevice *dev, u16 offset,
                                       int slave, u8 *mac_addr)
 {
        void *fdt = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        u32 macid_lsb;
        u32 macid_msb;
        fdt32_t gmii = 0;
@@ -60,7 +60,7 @@ static int cpsw_am33xx_cm_get_macid(struct udevice *dev, u16 offset, int slave,
                                    u8 *mac_addr)
 {
        void *fdt = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        u32 macid_lo;
        u32 macid_hi;
        fdt32_t gmii = 0;
index cbce683..5fbab9e 100644 (file)
@@ -981,7 +981,7 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)
 
 #ifdef CONFIG_DM_ETH
        if (slave->data->phy_of_handle)
-               phydev->dev->of_offset = slave->data->phy_of_handle;
+               dev_set_of_offset(phydev->dev, slave->data->phy_of_handle);
 #endif
 
        priv->phydev = phydev;
@@ -1286,7 +1286,7 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
        const char *phy_mode;
        const char *phy_sel_compat = NULL;
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int subnode;
        int slave_index = 0;
        int active_slave;
index e207bc6..eee4e09 100644 (file)
@@ -728,7 +728,8 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
 
        pdata->iobase = dev_get_addr(dev);
        pdata->phy_interface = -1;
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+                              NULL);
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
        if (pdata->phy_interface == -1) {
@@ -737,19 +738,19 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
        }
 
        pdata->max_speed = 0;
-       cell = fdt_getprop(gd->fdt_blob, dev->of_offset, "max-speed", NULL);
+       cell = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "max-speed", NULL);
        if (cell)
                pdata->max_speed = fdt32_to_cpu(*cell);
 
 #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;
 
        ret = gpio_request_by_name(dev, "snps,reset-gpio", 0,
                &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", dw_pdata->reset_delays, 3);
        } else if (ret == -ENOENT) {
                ret = 0;
index 3304fdd..5f34c8f 100644 (file)
@@ -1277,7 +1277,8 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
        priv->eth = (struct ethernet_regs *)pdata->iobase;
 
        pdata->phy_interface = -1;
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+                              NULL);
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
        if (pdata->phy_interface == -1) {
index 5f833fa..e9b202a 100644 (file)
@@ -36,9 +36,9 @@ static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev)
 {
        struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev);
 
-       pdata->tx_delay = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       pdata->tx_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                         "tx-delay", 0x30);
-       pdata->rx_delay = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       pdata->rx_delay = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                         "rx-delay", 0x10);
 
        return designware_eth_ofdata_to_platdata(dev);
index a5120e0..1b781f4 100644 (file)
@@ -1099,7 +1099,7 @@ static int ks2_sl_eth_ofdata_to_platdata(struct udevice *dev)
        struct ks2_eth_priv *priv = dev_get_priv(dev);
        struct eth_pdata *pdata = dev_get_platdata(dev);
        const void *fdt = gd->fdt_blob;
-       int slave = dev->of_offset;
+       int slave = dev_of_offset(dev);
        int interfaces;
        int gbe;
        int netcp_devices;
@@ -1126,13 +1126,13 @@ static int ks2_eth_ofdata_to_platdata(struct udevice *dev)
        int netcp_devices;
        int gbe;
 
-       netcp_devices = fdt_subnode_offset(fdt, dev->of_offset,
+       netcp_devices = fdt_subnode_offset(fdt, dev_of_offset(dev),
                                           "netcp-devices");
        gbe = fdt_subnode_offset(fdt, netcp_devices, "gbe");
 
        ks2_eth_bind_slaves(dev, gbe, &gbe_0);
 
-       ks2_eth_parse_slave_interface(dev->of_offset, gbe_0, priv, pdata);
+       ks2_eth_parse_slave_interface(dev_of_offset(dev), gbe_0, priv, pdata);
 
        pdata->iobase = dev_get_addr(dev);
 
index 01527f7..452fc3e 100644 (file)
@@ -999,7 +999,8 @@ static int macb_eth_probe(struct udevice *dev)
 #ifdef CONFIG_DM_ETH
        const char *phy_mode;
 
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+                              NULL);
        if (phy_mode)
                macb->phy_interface = phy_get_interface_by_name(phy_mode);
        if (macb->phy_interface == -1) {
index 00f378f..674075f 100644 (file)
@@ -1611,7 +1611,7 @@ static int mvneta_probe(struct udevice *dev)
        struct eth_pdata *pdata = dev_get_platdata(dev);
        struct mvneta_port *pp = dev_get_priv(dev);
        void *blob = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        struct mii_dev *bus;
        unsigned long addr;
        void *bd_space;
@@ -1691,7 +1691,8 @@ static int mvneta_ofdata_to_platdata(struct udevice *dev)
 
        /* Get phy-mode / phy_interface from DT */
        pdata->phy_interface = -1;
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+                              NULL);
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
        if (pdata->phy_interface == -1) {
index 405776a..88e88b9 100644 (file)
@@ -4047,7 +4047,7 @@ static int mvpp2_probe(struct udevice *dev)
                return err;
        }
 
-       return mvpp2_port_probe(dev, port, dev->of_offset, priv,
+       return mvpp2_port_probe(dev, port, dev_of_offset(dev), priv,
                                &buffer_loc.first_rxq);
 }
 
@@ -4138,7 +4138,7 @@ static int mvpp2_base_probe(struct udevice *dev)
 static int mvpp2_base_bind(struct udevice *parent)
 {
        const void *blob = gd->fdt_blob;
-       int node = parent->of_offset;
+       int node = dev_of_offset(parent);
        struct uclass_driver *drv;
        struct udevice *dev;
        struct eth_pdata *plat;
@@ -4169,7 +4169,7 @@ static int mvpp2_base_bind(struct udevice *parent)
 
                /* Create child device UCLASS_ETH and bind it */
                device_bind(parent, &mvpp2_driver, name, plat, subnode, &dev);
-               dev->of_offset = subnode;
+               dev_set_of_offset(dev, subnode);
        }
 
        return 0;
index 7163fa2..0e4a4eb 100644 (file)
@@ -244,7 +244,7 @@ static int ksz90x1_of_config_group(struct phy_device *phydev,
                return -EOPNOTSUPP;
 
        for (i = 0; i < ofcfg->grpsz; i++) {
-               val[i] = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+               val[i] = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                         ofcfg->grp[i].name, -1);
                offset = ofcfg->grp[i].off;
                if (val[i] == -1) {
index c55dd97..d1ce406 100644 (file)
@@ -167,13 +167,13 @@ static int dp83867_of_init(struct phy_device *phydev)
        struct dp83867_private *dp83867 = phydev->priv;
        struct udevice *dev = phydev->dev;
 
-       dp83867->rx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       dp83867->rx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                 "ti,rx-internal-delay", -1);
 
-       dp83867->tx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       dp83867->tx_id_delay = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                 "ti,tx-internal-delay", -1);
 
-       dp83867->fifo_depth = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       dp83867->fifo_depth = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                 "ti,fifo-depth", -1);
 
        return 0;
index 920bfcb..3f80f04 100644 (file)
@@ -104,7 +104,7 @@ static int xilinxphy_of_init(struct phy_device *phydev)
        u32 phytype;
 
        debug("%s\n", __func__);
-       phytype = fdtdec_get_int(gd->fdt_blob, phydev->dev->of_offset,
+       phytype = fdtdec_get_int(gd->fdt_blob, dev_of_offset(phydev->dev),
                                 "phy-type", -1);
        if (phytype == XAE_PHY_TYPE_1000BASE_X)
                phydev->flags |= XAE_PHY_TYPE_1000BASE_X;
index 167af8b..385aad5 100644 (file)
@@ -535,7 +535,8 @@ static int pic32_eth_probe(struct udevice *dev)
        int offset = 0;
        int phy_addr = -1;
 
-       addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
+       addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg",
+                                   &size);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
@@ -544,7 +545,8 @@ static int pic32_eth_probe(struct udevice *dev)
 
        /* get phy mode */
        pdata->phy_interface = -1;
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode",
+                              NULL);
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
        if (pdata->phy_interface == -1) {
@@ -553,13 +555,13 @@ static int pic32_eth_probe(struct udevice *dev)
        }
 
        /* get phy addr */
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
                                       "phy-handle");
        if (offset > 0)
                phy_addr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
 
        /* phy reset gpio */
-       gpio_request_by_name_nodev(gd->fdt_blob, dev->of_offset,
+       gpio_request_by_name_nodev(gd->fdt_blob, dev_of_offset(dev),
                                   "reset-gpios", 0,
                                   &priv->rst_gpio, GPIOD_IS_OUT);
 
index 5912427..9742c2c 100644 (file)
@@ -26,7 +26,7 @@ static int sb_eth_raw_start(struct udevice *dev)
 
        debug("eth_sandbox_raw: Start\n");
 
-       interface = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       interface = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                                            "host-raw-interface", NULL);
        if (interface == NULL)
                return -EINVAL;
index d538d37..79d0ae6 100644 (file)
@@ -60,8 +60,9 @@ static int sb_eth_start(struct udevice *dev)
 
        debug("eth_sandbox: Start\n");
 
-       fdtdec_get_byte_array(gd->fdt_blob, dev->of_offset, "fake-host-hwaddr",
-                             priv->fake_host_hwaddr, ARP_HLEN);
+       fdtdec_get_byte_array(gd->fdt_blob, dev_of_offset(dev),
+                             "fake-host-hwaddr", priv->fake_host_hwaddr,
+                             ARP_HLEN);
        priv->recv_packet_buffer = net_rx_packets[0];
        return 0;
 }
index abd9cc8..b87210b 100644 (file)
@@ -442,7 +442,7 @@ static int parse_phy_pins(struct udevice *dev)
        const char *pin_name;
        int drive, pull, i;
 
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
                                       "pinctrl-0");
        if (offset < 0) {
                printf("WARNING: emac: cannot find pinctrl-0 node\n");
@@ -716,6 +716,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
        struct eth_pdata *pdata = dev_get_platdata(dev);
        struct emac_eth_dev *priv = dev_get_priv(dev);
        const char *phy_mode;
+       int node = dev_of_offset(dev);
        int offset = 0;
 
        pdata->iobase = dev_get_addr_name(dev, "emac");
@@ -725,13 +726,13 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
        priv->phyaddr = -1;
        priv->use_internal_phy = false;
 
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
                                       "phy");
        if (offset > 0)
                priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg",
                                               -1);
 
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
 
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
@@ -751,7 +752,7 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
        }
 
        if (priv->variant == H3_EMAC) {
-               if (fdt_getprop(gd->fdt_blob, dev->of_offset,
+               if (fdt_getprop(gd->fdt_blob, node,
                                "allwinner,use-internal-phy", NULL))
                        priv->use_internal_phy = true;
        }
index 7df4c63..f2ce4e2 100644 (file)
@@ -783,7 +783,7 @@ int tsec_probe(struct udevice *dev)
        pdata->iobase = (phys_addr_t)dev_get_addr(dev);
        priv->regs = (struct tsec *)pdata->iobase;
 
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
                                       "phy-handle");
        if (offset > 0) {
                reg = fdtdec_get_int(gd->fdt_blob, offset, "reg", 0);
@@ -802,7 +802,7 @@ int tsec_probe(struct udevice *dev)
                return -ENOENT;
        }
 
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
                                       "tbi-handle");
        if (offset > 0) {
                reg = fdtdec_get_int(gd->fdt_blob, offset, "reg",
@@ -812,7 +812,7 @@ int tsec_probe(struct udevice *dev)
                priv->tbiaddr = CONFIG_SYS_TBIPA_VALUE;
        }
 
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                               "phy-connection-type", NULL);
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
index 51c7426..a6f24b3 100644 (file)
@@ -682,13 +682,14 @@ static int axi_emac_ofdata_to_platdata(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_platdata(dev);
        struct axidma_priv *priv = dev_get_priv(dev);
+       int node = dev_of_offset(dev);
        int offset = 0;
        const char *phy_mode;
 
        pdata->iobase = (phys_addr_t)dev_get_addr(dev);
        priv->iobase = (struct axi_regs *)pdata->iobase;
 
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
                                       "axistream-connected");
        if (offset <= 0) {
                printf("%s: axistream is not found\n", __func__);
@@ -705,12 +706,11 @@ static int axi_emac_ofdata_to_platdata(struct udevice *dev)
 
        priv->phyaddr = -1;
 
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
-                                      "phy-handle");
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle");
        if (offset > 0)
                priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
 
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
        if (pdata->phy_interface == -1) {
index ea93cf9..7d4e14f 100644 (file)
@@ -604,15 +604,15 @@ static int emaclite_ofdata_to_platdata(struct udevice *dev)
 
        emaclite->phyaddr = -1;
 
-       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset,
+       offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
                                      "phy-handle");
        if (offset > 0)
                emaclite->phyaddr = fdtdec_get_int(gd->fdt_blob, offset,
                                                   "reg", -1);
 
-       emaclite->txpp = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       emaclite->txpp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                        "xlnx,tx-ping-pong", 0);
-       emaclite->rxpp = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       emaclite->rxpp = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                        "xlnx,rx-ping-pong", 0);
 
        printf("EMACLITE: %lx, phyaddr %d, %d/%d\n", (ulong)emaclite->regs,
index 6dd87cf..86dd03f 100644 (file)
@@ -345,7 +345,7 @@ static int zynq_phy_init(struct udevice *dev)
        priv->phydev->advertising = priv->phydev->supported;
 
        if (priv->phy_of_handle > 0)
-               priv->phydev->dev->of_offset = priv->phy_of_handle;
+               dev_set_of_offset(priv->phydev->dev, priv->phy_of_handle);
 
        return phy_config(priv->phydev);
 }
@@ -684,6 +684,7 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_platdata(dev);
        struct zynq_gem_priv *priv = dev_get_priv(dev);
+       int node = dev_of_offset(dev);
        const char *phy_mode;
 
        pdata->iobase = (phys_addr_t)dev_get_addr(dev);
@@ -692,13 +693,13 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev)
        priv->emio = 0;
        priv->phyaddr = -1;
 
-       priv->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob,
-                                       dev->of_offset, "phy-handle");
+       priv->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob, node,
+                                                   "phy-handle");
        if (priv->phy_of_handle > 0)
                priv->phyaddr = fdtdec_get_int(gd->fdt_blob,
                                        priv->phy_of_handle, "reg", -1);
 
-       phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
+       phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
        if (phy_mode)
                pdata->phy_interface = phy_get_interface_by_name(phy_mode);
        if (pdata->phy_interface == -1) {
@@ -707,7 +708,7 @@ static int zynq_gem_ofdata_to_platdata(struct udevice *dev)
        }
        priv->interface = pdata->phy_interface;
 
-       priv->emio = fdtdec_get_bool(gd->fdt_blob, dev->of_offset, "xlnx,emio");
+       priv->emio = fdtdec_get_bool(gd->fdt_blob, node, "xlnx,emio");
 
        printf("ZYNQ GEM: %lx, phyaddr %x, interface %s\n", (ulong)priv->iobase,
               priv->phyaddr, phy_string_for_interface(priv->interface));
index 3b00e6a..a1408f5 100644 (file)
@@ -839,8 +839,9 @@ static int pci_uclass_pre_probe(struct udevice *bus)
        /* For bridges, use the top-level PCI controller */
        if (!device_is_on_pci_bus(bus)) {
                hose->ctlr = bus;
-               ret = decode_regions(hose, gd->fdt_blob, bus->parent->of_offset,
-                               bus->of_offset);
+               ret = decode_regions(hose, gd->fdt_blob,
+                                    dev_of_offset(bus->parent),
+                                    dev_of_offset(bus));
                if (ret) {
                        debug("%s: Cannot decode regions\n", __func__);
                        return ret;
@@ -903,7 +904,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev)
        struct fdt_pci_addr addr;
        int ret;
 
-       if (dev->of_offset == -1)
+       if (dev_of_offset(dev) == -1)
                return 0;
 
        /*
@@ -911,7 +912,7 @@ static int pci_uclass_child_post_bind(struct udevice *dev)
         * just check the address.
         */
        pplat = dev_get_parent_platdata(dev);
-       ret = fdtdec_get_pci_addr(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_get_pci_addr(gd->fdt_blob, dev_of_offset(dev),
                                  FDT_PCI_SPACE_CONFIG, "reg", &addr);
 
        if (ret) {
index 430270e..7d9c63b 100644 (file)
@@ -1099,7 +1099,7 @@ static int pci_tegra_ofdata_to_platdata(struct udevice *dev)
 
        INIT_LIST_HEAD(&pcie->ports);
 
-       if (tegra_pcie_parse_dt(gd->fdt_blob, dev->of_offset, id, pcie))
+       if (tegra_pcie_parse_dt(gd->fdt_blob, dev_of_offset(dev), id, pcie))
                return -EINVAL;
 
        return 0;
index 90b9fe2..b6806cf 100644 (file)
@@ -438,7 +438,7 @@ static int ls_pcie_probe(struct udevice *dev)
 {
        struct ls_pcie *pcie = dev_get_priv(dev);
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        u8 header_type;
        u16 link_sta;
        bool ep_mode;
index 5216001..08e2e93 100644 (file)
@@ -186,7 +186,7 @@ static int pcie_xilinx_ofdata_to_platdata(struct udevice *dev)
        DECLARE_GLOBAL_DATA_PTR;
        int err;
 
-       err = fdt_get_resource(gd->fdt_blob, dev->of_offset, "reg",
+       err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",
                               0, &reg_res);
        if (err < 0) {
                error("\"reg\" resource not found\n");
index bc2508b..caa1928 100644 (file)
@@ -107,7 +107,7 @@ void comphy_print(struct chip_serdes_phy_config *chip_cfg,
 static int comphy_probe(struct udevice *dev)
 {
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        struct chip_serdes_phy_config *chip_cfg = dev_get_priv(dev);
        struct comphy_map comphy_map_data[MAX_LANE_OPTIONS];
        int subnode;
index e3f64b6..fccc7c4 100644 (file)
@@ -75,7 +75,7 @@ static int ar933x_pinctrl_get_periph_id(struct udevice *dev,
        u32 cell[2];
        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 d02597e..a7f8c70 100644 (file)
@@ -95,7 +95,7 @@ static int qca953x_pinctrl_get_periph_id(struct udevice *dev,
        u32 cell[2];
        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 dd0a16e..5b9a592 100644 (file)
@@ -70,7 +70,7 @@ static unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name,
 int exynos_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
        const void *fdt = gd->fdt_blob;
-       int node = config->of_offset;
+       int node = dev_of_offset(config);
        unsigned int count, idx, pin_num;
        unsigned int pinfunc, pinpud, pindrv;
        unsigned long reg, value;
index 30f7cfc..b5486b8 100644 (file)
@@ -142,19 +142,19 @@ int meson_pinctrl_probe(struct udevice *dev)
        int node, gpio = -1, len;
        int na, ns;
 
-       na = fdt_address_cells(gd->fdt_blob, dev->parent->of_offset);
+       na = fdt_address_cells(gd->fdt_blob, dev_of_offset(dev->parent));
        if (na < 1) {
                debug("bad #address-cells\n");
                return -EINVAL;
        }
 
-       ns = fdt_size_cells(gd->fdt_blob, dev->parent->of_offset);
+       ns = fdt_size_cells(gd->fdt_blob, dev_of_offset(dev->parent));
        if (ns < 1) {
                debug("bad #size-cells\n");
                return -EINVAL;
        }
 
-       fdt_for_each_subnode(node, gd->fdt_blob, dev->of_offset) {
+       fdt_for_each_subnode(node, gd->fdt_blob, dev_of_offset(dev)) {
                if (fdt_getprop(gd->fdt_blob, node, "gpio-controller", &len)) {
                        gpio = node;
                        break;
index b077639..80f0dfa 100644 (file)
@@ -28,7 +28,7 @@ DECLARE_GLOBAL_DATA_PTR;
 int mvebu_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
        const void *blob = gd->fdt_blob;
-       int node = config->of_offset;
+       int node = dev_of_offset(config);
        struct mvebu_pinctrl_priv *priv;
        u32 pin_arr[MVEBU_MAX_PINS_PER_BANK];
        u32 function;
@@ -82,7 +82,7 @@ static int mvebu_pinctrl_set_state_all(struct udevice *dev,
                                       struct udevice *config)
 {
        const void *blob = gd->fdt_blob;
-       int node = config->of_offset;
+       int node = dev_of_offset(config);
        struct mvebu_pinctrl_priv *priv;
        u32 func_arr[MVEBU_MAX_PINS_PER_BANK];
        int pin, err;
@@ -128,7 +128,7 @@ static int mvebu_pinctrl_set_state_all(struct udevice *dev,
 int mvebu_pinctl_probe(struct udevice *dev)
 {
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        struct mvebu_pinctrl_priv *priv;
 
        priv = dev_get_priv(dev);
index 949d0f3..e130faf 100644 (file)
@@ -19,7 +19,7 @@ static int imx_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
        struct imx_pinctrl_priv *priv = dev_get_priv(dev);
        struct imx_pinctrl_soc_info *info = priv->info;
-       int node = config->of_offset;
+       int node = dev_of_offset(config);
        const struct fdt_property *prop;
        u32 *pin_data;
        int npins, size, pin_size;
@@ -176,7 +176,7 @@ int imx_pinctrl_probe(struct udevice *dev,
                      struct imx_pinctrl_soc_info *info)
 {
        struct imx_pinctrl_priv *priv = dev_get_priv(dev);
-       int node = dev->of_offset, ret;
+       int node = dev_of_offset(dev), ret;
        struct fdtdec_phandle_args arg;
        fdt_addr_t addr;
        fdt_size_t size;
@@ -189,7 +189,8 @@ int imx_pinctrl_probe(struct udevice *dev,
        priv->dev = dev;
        priv->info = info;
 
-       addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
+       addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg",
+                                   &size);
 
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
index 6d4aadc..5c6bff5 100644 (file)
@@ -109,7 +109,7 @@ static int atmel_pinctrl_set_state(struct udevice *dev, struct udevice *config)
 {
        struct atmel_pio4_port *bank_base;
        const void *blob = gd->fdt_blob;
-       int node = config->of_offset;
+       int node = dev_of_offset(config);
        u32 offset, func, bank, line;
        u32 cells[MAX_PINMUX_ENTRIES];
        u32 i, conf;
index 3629322..0272496 100644 (file)
@@ -245,7 +245,7 @@ static int pinctrl_generic_set_state_one(struct udevice *dev,
                                         bool is_group, unsigned selector)
 {
        const void *fdt = gd->fdt_blob;
-       int node_offset = config->of_offset;
+       int node_offset = dev_of_offset(config);
        const char *propname;
        const void *value;
        int prop_offset, len, func_selector, param, ret;
@@ -300,7 +300,7 @@ static int pinctrl_generic_set_state_subnode(struct udevice *dev,
                                             struct udevice *config)
 {
        const void *fdt = gd->fdt_blob;
-       int node = config->of_offset;
+       int node = dev_of_offset(config);
        const char *subnode_target_type = "pins";
        bool is_group = false;
        const char *name;
index 02ab9b4..49afe91 100644 (file)
@@ -64,7 +64,7 @@ static int pinctrl_config_one(struct udevice *config)
 static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
 {
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        char propname[32]; /* long enough */
        const fdt32_t *list;
        uint32_t phandle;
@@ -122,7 +122,7 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
 static int pinconfig_post_bind(struct udevice *dev)
 {
        const void *fdt = gd->fdt_blob;
-       int offset = dev->of_offset;
+       int offset = dev_of_offset(dev);
        bool pre_reloc_only = !(gd->flags & GD_FLG_RELOC);
        const char *name;
        int ret;
index 9acac29..59466ee 100644 (file)
@@ -253,7 +253,7 @@ static int pic32_pinctrl_get_periph_id(struct udevice *dev,
        int ret;
        u32 cell[2];
 
-       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;
@@ -310,7 +310,7 @@ static int pic32_pinctrl_probe(struct udevice *dev)
        struct pic32_pinctrl_priv *priv = dev_get_priv(dev);
        struct fdt_resource res;
        void *fdt = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        ret = fdt_get_named_resource(fdt, node, "reg", "reg-names",
index 6aea856..8d42584 100644 (file)
@@ -205,7 +205,7 @@ static int rk3036_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 0322264..cb13d30 100644 (file)
@@ -479,7 +479,7 @@ static int rk3288_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;
@@ -644,7 +644,7 @@ static int rk3288_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 17ea165..da30154 100644 (file)
@@ -362,7 +362,7 @@ static int rk3399_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 1bb6262..3dabbe4 100644 (file)
@@ -41,7 +41,7 @@ int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
 
        debug("%s(dev=%p, power_domain=%p)\n", __func__, dev, power_domain);
 
-       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
                                             "power-domains",
                                             "#power-domain-cells", 0, 0,
                                             &args);
index e8164bf..15da12e 100644 (file)
@@ -52,7 +52,7 @@ static int act8846_bind(struct udevice *dev)
        int regulators_node;
        int children;
 
-       regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+       regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
                                             "regulators");
        if (regulators_node <= 0) {
                debug("%s: %s regulators subnode not found!", __func__,
index aeab5c9..4f92e3d 100644 (file)
@@ -108,9 +108,9 @@ static int sandbox_i2c_pmic_ofdata_to_platdata(struct udevice *emul)
 
        debug("%s:%d Setting PMIC default registers\n", __func__, __LINE__);
 
-       reg_defaults = fdtdec_locate_byte_array(gd->fdt_blob, emul->of_offset,
-                                               "reg-defaults",
-                                               SANDBOX_PMIC_REG_COUNT);
+       reg_defaults = fdtdec_locate_byte_array(gd->fdt_blob,
+                       dev_of_offset(emul), "reg-defaults",
+                       SANDBOX_PMIC_REG_COUNT);
 
        if (!reg_defaults) {
                error("Property \"reg-defaults\" not found for device: %s!",
index 307f96b..d8f30df 100644 (file)
@@ -49,7 +49,7 @@ static int lp873x_bind(struct udevice *dev)
        int regulators_node;
        const void *blob = gd->fdt_blob;
        int children;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        regulators_node = fdt_subnode_offset(blob, node, "regulators");
 
index dc5a54a..8295fab 100644 (file)
@@ -54,7 +54,7 @@ static int max77686_bind(struct udevice *dev)
        const void *blob = gd->fdt_blob;
        int children;
 
-       regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+       regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
                                             "voltage-regulators");
        if (regulators_node <= 0) {
                debug("%s: %s regulators subnode not found!", __func__,
index 0ab425e..f5a2307 100644 (file)
@@ -49,7 +49,7 @@ static int palmas_bind(struct udevice *dev)
        int pmic_node = -1, regulators_node;
        const void *blob = gd->fdt_blob;
        int children;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int subnode, len;
 
        fdt_for_each_subnode(subnode, blob, node) {
index 3beb48e..90a43f2 100644 (file)
@@ -56,7 +56,7 @@ static int pfuze100_bind(struct udevice *dev)
        int regulators_node;
        const void *blob = gd->fdt_blob;
 
-       regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+       regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
                                             "regulators");
        if (regulators_node <= 0) {
                debug("%s: %s regulators subnode not found!", __func__,
index 7211026..0f7fa51 100644 (file)
@@ -33,7 +33,7 @@ int pmic_bind_children(struct udevice *pmic, int offset,
        int ret;
 
        debug("%s for '%s' at node offset: %d\n", __func__, pmic->name,
-             pmic->of_offset);
+             dev_of_offset(pmic));
 
        for (node = fdt_first_subnode(blob, offset);
             node > 0;
index 770f471..3f5f316 100644 (file)
@@ -61,7 +61,7 @@ static int rk808_bind(struct udevice *dev)
        int regulators_node;
        int children;
 
-       regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+       regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
                                             "regulators");
        if (regulators_node <= 0) {
                debug("%s: %s regulators subnode not found!", __func__,
index 075fe7e..25d673b 100644 (file)
@@ -58,7 +58,7 @@ static int s5m8767_bind(struct udevice *dev)
        const void *blob = gd->fdt_blob;
        int children;
 
-       node = fdt_subnode_offset(blob, dev->of_offset, "regulators");
+       node = fdt_subnode_offset(blob, dev_of_offset(dev), "regulators");
        if (node <= 0) {
                debug("%s: %s regulators subnode not found!", __func__,
                      dev->name);
index 3e56acd..b4e412e 100644 (file)
@@ -51,7 +51,7 @@ static int sandbox_pmic_read(struct udevice *dev, uint reg,
 
 static int sandbox_pmic_bind(struct udevice *dev)
 {
-       if (!pmic_bind_children(dev, dev->of_offset, pmic_children_info))
+       if (!pmic_bind_children(dev, dev_of_offset(dev), pmic_children_info))
                error("%s:%d PMIC: %s - no child found!", __func__, __LINE__,
                                                          dev->name);
 
index 4797f32..b30a7f0 100644 (file)
@@ -56,7 +56,7 @@ static int tps65090_bind(struct udevice *dev)
        const void *blob = gd->fdt_blob;
        int children;
 
-       regulators_node = fdt_subnode_offset(blob, dev->of_offset,
+       regulators_node = fdt_subnode_offset(blob, dev_of_offset(dev),
                                             "regulators");
        if (regulators_node <= 0) {
                debug("%s: %s regulators subnode not found!", __func__,
index 3d2d908..cd52137 100644 (file)
@@ -28,7 +28,7 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
        struct fixed_regulator_platdata *dev_pdata;
        struct gpio_desc *gpio;
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset, flags = GPIOD_IS_OUT;
+       int node = dev_of_offset(dev), flags = GPIOD_IS_OUT;
        int ret;
 
        dev_pdata = dev_get_platdata(dev);
@@ -54,7 +54,7 @@ static int fixed_regulator_ofdata_to_platdata(struct udevice *dev)
 
        /* Get optional ramp up delay */
        dev_pdata->startup_delay_us = fdtdec_get_uint(gd->fdt_blob,
-                                                     dev->of_offset,
+                                                     dev_of_offset(dev),
                                                      "startup-delay-us", 0);
 
        return 0;
index 0a60a9c..42391c6 100644 (file)
@@ -30,7 +30,7 @@ static int gpio_regulator_ofdata_to_platdata(struct udevice *dev)
        struct gpio_regulator_platdata *dev_pdata;
        struct gpio_desc *gpio;
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret, count, i, j;
        u32 states_array[8];
 
index b0a4c5d..4875238 100644 (file)
@@ -88,7 +88,7 @@ static int pwm_regulator_ofdata_to_platdata(struct udevice *dev)
        struct pwm_regulator_info *priv = dev_get_priv(dev);
        struct fdtdec_phandle_args args;
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        ret = fdtdec_parse_phandle_with_args(blob, node, "pwms", "#pwm-cells",
index 52a1070..2e0b5ed 100644 (file)
@@ -278,7 +278,7 @@ static bool regulator_name_is_unique(struct udevice *check_dev,
 static int regulator_post_bind(struct udevice *dev)
 {
        struct dm_regulator_uclass_platdata *uc_pdata;
-       int offset = dev->of_offset;
+       int offset = dev_of_offset(dev);
        const void *blob = gd->fdt_blob;
        const char *property = "regulator-name";
 
@@ -308,7 +308,7 @@ static int regulator_post_bind(struct udevice *dev)
 static int regulator_pre_probe(struct udevice *dev)
 {
        struct dm_regulator_uclass_platdata *uc_pdata;
-       int offset = dev->of_offset;
+       int offset = dev_of_offset(dev);
 
        uc_pdata = dev_get_uclass_platdata(dev);
        if (!uc_pdata)
index 200cf61..b6e67f2 100644 (file)
@@ -116,7 +116,7 @@ static int rproc_pre_probe(struct udevice *dev)
 
        if (!dev->platdata) {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-               int node = dev->of_offset;
+               int node = dev_of_offset(dev);
                const void *blob = gd->fdt_blob;
                bool tmp;
                if (!blob) {
index 76ac3be..bb7a145 100644 (file)
@@ -33,7 +33,7 @@ struct ti_powerproc_privdata {
 static int ti_of_to_priv(struct udevice *dev,
                         struct ti_powerproc_privdata *priv)
 {
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const void *blob = gd->fdt_blob;
        int tmp;
 
index d3744ef..e92b24f 100644 (file)
@@ -43,7 +43,7 @@ int reset_get_by_index(struct udevice *dev, int index,
        debug("%s(dev=%p, index=%d, reset_ctl=%p)\n", __func__, dev, index,
              reset_ctl);
 
-       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev->of_offset,
+       ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, dev_of_offset(dev),
                                             "resets", "#reset-cells", 0,
                                             index, &args);
        if (ret) {
@@ -88,7 +88,7 @@ int reset_get_by_name(struct udevice *dev, const char *name,
        debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name,
              reset_ctl);
 
-       index = fdt_stringlist_search(gd->fdt_blob, dev->of_offset,
+       index = fdt_stringlist_search(gd->fdt_blob, dev_of_offset(dev),
                                      "reset-names", name);
        if (index < 0) {
                debug("fdt_stringlist_search() failed: %d\n", index);
index eff9c59..8344940 100644 (file)
@@ -92,7 +92,7 @@ static int altera_uart_ofdata_to_platdata(struct udevice *dev)
        plat->regs = map_physmem(dev_get_addr(dev),
                                 sizeof(struct altera_uart_regs),
                                 MAP_NOCACHE);
-       plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                "clock-frequency", 0);
 
        return 0;
index 2df4a1f..1f819d4 100644 (file)
@@ -383,13 +383,13 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
                int ret;
 
                /* we prefer to use a memory-mapped register */
-               ret = fdtdec_get_pci_addr(gd->fdt_blob, dev->of_offset,
+               ret = fdtdec_get_pci_addr(gd->fdt_blob, dev_of_offset(dev),
                                          FDT_PCI_SPACE_MEM32, "reg",
                                          &pci_addr);
                if (ret) {
                        /* try if there is any i/o-mapped register */
                        ret = fdtdec_get_pci_addr(gd->fdt_blob,
-                                                 dev->of_offset,
+                                                 dev_of_offset(dev),
                                                  FDT_PCI_SPACE_IO,
                                                  "reg", &pci_addr);
                        if (ret)
@@ -413,9 +413,9 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
        plat->base = (unsigned long)map_physmem(addr, 0, MAP_NOCACHE);
 #endif
 
-       plat->reg_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->reg_offset = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                     "reg-offset", 0);
-       plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                         "reg-shift", 0);
 
        err = clk_get_by_index(dev, 0, &clk);
@@ -429,7 +429,7 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
        }
 
        if (!plat->clock)
-               plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+               plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                             "clock-frequency",
                                             CONFIG_SYS_NS16550_CLK);
        if (!plat->clock) {
index bcc3465..858e340 100644 (file)
@@ -152,7 +152,7 @@ static int sandbox_serial_ofdata_to_platdata(struct udevice *dev)
        int i;
 
        plat->colour = -1;
-       colour = fdt_getprop(gd->fdt_blob, dev->of_offset,
+       colour = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
                             "sandbox,text-colour", NULL);
        if (colour) {
                for (i = 0; i < ARRAY_SIZE(ansi_colour); i++) {
index 326a536..fc91977 100644 (file)
@@ -115,7 +115,7 @@ static int arc_serial_ofdata_to_platdata(struct udevice *dev)
        DECLARE_GLOBAL_DATA_PTR;
 
        plat->reg = (struct arc_serial_regs *)dev_get_addr(dev);
-       plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                       "clock-frequency", 0);
 
        return 0;
index 3884f74..e7ed899 100644 (file)
@@ -164,8 +164,9 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev)
                return -EINVAL;
 
        plat->base = addr;
-       plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
-       plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+       plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
+                                    1);
+       plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
                                          "skip-init");
        plat->disabled = false;
        return 0;
index a7cab13..63b3006 100644 (file)
@@ -146,7 +146,7 @@ static const struct dm_serial_ops msm_serial_ops = {
 
 static int msm_uart_clk_init(struct udevice *dev)
 {
-       uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+       uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev),
                                        "clock-frequency", 115200);
        uint clkd[2]; /* clk_id and clk_no */
        int clk_offset;
@@ -154,8 +154,8 @@ static int msm_uart_clk_init(struct udevice *dev)
        struct clk clk;
        int ret;
 
-       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "clock", clkd,
-                                  2);
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev_of_offset(dev), "clock",
+                                  clkd, 2);
        if (ret)
                return ret;
 
index 4fd2b1d..1cfcbf2 100644 (file)
@@ -359,7 +359,7 @@ static int mxc_serial_ofdata_to_platdata(struct udevice *dev)
 
        plat->reg = (struct mxc_uart *)addr;
 
-       plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+       plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
                                        "fsl,dte-mode");
        return 0;
 }
index c2141f0..b0e01aa 100644 (file)
@@ -141,7 +141,8 @@ static int pic32_uart_probe(struct udevice *dev)
        int ret;
 
        /* get address */
-       addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset, "reg", &size);
+       addr = fdtdec_get_addr_size(gd->fdt_blob, dev_of_offset(dev), "reg",
+                                   &size);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
index a8d3d67..a49134a 100644 (file)
@@ -354,9 +354,10 @@ static int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
                return -EINVAL;
 
        plat->base = addr;
-       plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
+       plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
+                                    1);
        plat->type = dev_get_driver_data(dev);
-       plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev->of_offset,
+       plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
                                          "skip-init");
        return 0;
 }
index 6225479..96842de 100644 (file)
@@ -187,7 +187,7 @@ static int s5p_serial_ofdata_to_platdata(struct udevice *dev)
                return -EINVAL;
 
        plat->reg = (struct s5p_uart *)addr;
-       plat->port_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       plat->port_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                        "id", dev->seq);
        return 0;
 }
index ef7cf0f..51f7fbc 100644 (file)
@@ -216,12 +216,13 @@ static int sh_serial_ofdata_to_platdata(struct udevice *dev)
        struct sh_serial_platdata *plat = dev_get_platdata(dev);
        fdt_addr_t addr;
 
-       addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+       addr = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "reg");
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
        plat->base = addr;
-       plat->clk = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "clock", 1);
+       plat->clk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
+                                  1);
        plat->type = dev_get_driver_data(dev);
        return 0;
 }
index 4ea5304..0e25cba 100644 (file)
@@ -105,7 +105,7 @@ static int uniphier_serial_probe(struct udevice *dev)
 
        priv->membase = port;
 
-       priv->uartclk = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       priv->uartclk = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                       "clock-frequency", 0);
 
        tmp = readl(&port->lcr_mcr);
index f16f90d..9a6e41f 100644 (file)
@@ -282,7 +282,7 @@ static int cadence_spi_ofdata_to_platdata(struct udevice *bus)
 {
        struct cadence_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
        int subnode;
        u32 data[4];
        int ret;
index 20aa99a..65d37b0 100644 (file)
@@ -540,7 +540,7 @@ static int davinci_ofdata_to_platadata(struct udevice *bus)
 {
        struct davinci_spi_slave *ds = dev_get_priv(bus);
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        ds->regs = dev_map_physmem(bus, sizeof(struct davinci_spi_regs));
        if (!ds->regs) {
index 24a6e98..9d5e29c 100644 (file)
@@ -132,7 +132,7 @@ static int dw_spi_ofdata_to_platdata(struct udevice *bus)
 {
        struct dw_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->regs = (struct dw_spi *)dev_get_addr(bus);
 
index 44948c3..aa0784c 100644 (file)
@@ -253,7 +253,7 @@ static int exynos_spi_ofdata_to_platdata(struct udevice *bus)
 {
        struct exynos_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->regs = (struct exynos_spi *)dev_get_addr(bus);
        plat->periph_id = pinmux_decode_periph_id(blob, node);
index f213587..e09985e 100644 (file)
@@ -646,7 +646,7 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus)
        fdt_addr_t addr;
        struct fsl_dspi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        if (fdtdec_get_bool(blob, node, "big-endian"))
                plat->flags |= DSPI_FLAG_REGMAP_ENDIAN_BIG;
index 4d378c2..b2a0583 100644 (file)
@@ -1078,7 +1078,7 @@ static int fsl_qspi_ofdata_to_platdata(struct udevice *bus)
        struct fdt_resource res_regs, res_mem;
        struct fsl_qspi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
        int ret, flash_num = 0, subnode;
 
        if (fdtdec_get_bool(blob, node, "big-endian"))
index caf0103..893fe33 100644 (file)
@@ -658,14 +658,14 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
 static int ich_spi_ofdata_to_platdata(struct udevice *dev)
 {
        struct ich_spi_platdata *plat = dev_get_platdata(dev);
+       int node = dev_of_offset(dev);
        int ret;
 
-       ret = fdt_node_check_compatible(gd->fdt_blob, dev->of_offset,
-                                       "intel,ich7-spi");
+       ret = fdt_node_check_compatible(gd->fdt_blob, node, "intel,ich7-spi");
        if (ret == 0) {
                plat->ich_version = ICHV_7;
        } else {
-               ret = fdt_node_check_compatible(gd->fdt_blob, dev->of_offset,
+               ret = fdt_node_check_compatible(gd->fdt_blob, node,
                                                "intel,ich9-spi");
                if (ret == 0)
                        plat->ich_version = ICHV_9;
index 7c58c36..ee847e4 100644 (file)
@@ -261,9 +261,9 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus)
         * it should be used to read the input clock and the DT property
         * can be removed.
         */
-       plat->clock = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+       plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
                                     "clock-frequency", 160000);
-       plat->frequency = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+       plat->frequency = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
                                         "spi-max-frequency", 40000);
 
        return 0;
index 60e9d6e..8a89450 100644 (file)
@@ -627,7 +627,7 @@ static int omap3_spi_probe(struct udevice *dev)
 {
        struct omap3_spi_priv *priv = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        struct omap2_mcspi_platform_config* data =
                (struct omap2_mcspi_platform_config*)dev_get_driver_data(dev);
index 25ca1f3..78d78bc 100644 (file)
@@ -377,13 +377,14 @@ static int pic32_spi_probe(struct udevice *bus)
 {
        struct pic32_spi_priv *priv = dev_get_priv(bus);
        struct dm_spi_bus *dm_spi = dev_get_uclass_priv(bus);
+       int node = dev_of_offset(bus);
        struct udevice *clkdev;
        fdt_addr_t addr;
        fdt_size_t size;
        int ret;
 
        debug("%s: %d, bus: %i\n", __func__, __LINE__, bus->seq);
-       addr = fdtdec_get_addr_size(gd->fdt_blob, bus->of_offset, "reg", &size);
+       addr = fdtdec_get_addr_size(gd->fdt_blob, node, "reg", &size);
        if (addr == FDT_ADDR_T_NONE)
                return -EINVAL;
 
@@ -391,8 +392,8 @@ static int pic32_spi_probe(struct udevice *bus)
        if (!priv->regs)
                return -EINVAL;
 
-       dm_spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
-                                       "spi-max-frequency", 250000000);
+       dm_spi->max_hz = fdtdec_get_int(gd->fdt_blob, node, "spi-max-frequency",
+                                       250000000);
        /* get clock rate */
        ret = clk_get_by_index(bus, 0, &clkdev);
        if (ret < 0) {
@@ -413,8 +414,7 @@ static int pic32_spi_probe(struct udevice *bus)
         * of the ongoing transfer. To avoid this sort of error we will drive
         * /CS manually by toggling cs-gpio pins.
         */
-       ret = gpio_request_by_name_nodev(gd->fdt_blob, bus->of_offset,
-                                        "cs-gpios", 0,
+       ret = gpio_request_by_name_nodev(gd->fdt_blob, node, "cs-gpios", 0,
                                         &priv->cs_gpio, GPIOD_IS_OUT);
        if (ret) {
                printf("pic32-spi: error, cs-gpios not found\n");
index 15cf0bd..3e44f17 100644 (file)
@@ -164,7 +164,7 @@ static int rockchip_spi_ofdata_to_platdata(struct udevice *bus)
        struct rockchip_spi_platdata *plat = dev_get_platdata(bus);
        struct rockchip_spi_priv *priv = dev_get_priv(bus);
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
        int ret;
 
        plat->base = dev_get_addr(bus);
index d23dc81..1690cd7 100644 (file)
@@ -202,7 +202,7 @@ static int soft_spi_ofdata_to_platdata(struct udevice *dev)
 {
        struct soft_spi_platdata *plat = dev->platdata;
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
 
        plat->spi_delay_us = fdtdec_get_int(blob, node, "spi-delay-us", 0);
 
index 1ab5b75..ac17da0 100644 (file)
@@ -113,10 +113,11 @@ static int spi_child_post_bind(struct udevice *dev)
 {
        struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
 
-       if (dev->of_offset == -1)
+       if (dev_of_offset(dev) == -1)
                return 0;
 
-       return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat);
+       return spi_slave_ofdata_to_platdata(gd->fdt_blob, dev_of_offset(dev),
+                                           plat);
 }
 #endif
 
@@ -125,7 +126,7 @@ static int spi_post_probe(struct udevice *bus)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
        struct dm_spi_bus *spi = dev_get_uclass_priv(bus);
 
-       spi->max_hz = fdtdec_get_int(gd->fdt_blob, bus->of_offset,
+       spi->max_hz = fdtdec_get_int(gd->fdt_blob, dev_of_offset(bus),
                                     "spi-max-frequency", 0);
 #endif
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
index 123a1f3..05358eb 100644 (file)
@@ -411,7 +411,7 @@ static int stm32_qspi_ofdata_to_platdata(struct udevice *bus)
        struct fdt_resource res_regs, res_mem;
        struct stm32_qspi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
        int ret;
 
        ret = fdt_get_named_resource(blob, node, "reg", "reg-names",
index 509afba..897409c 100644 (file)
@@ -101,7 +101,7 @@ static int tegra114_spi_ofdata_to_platdata(struct udevice *bus)
 {
        struct tegra_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->base = dev_get_addr(bus);
        plat->periph_id = clock_decode_periph_id(blob, node);
index ce3a2d3..ecbf4c1 100644 (file)
@@ -88,7 +88,7 @@ static int tegra20_sflash_ofdata_to_platdata(struct udevice *bus)
 {
        struct tegra_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->base = dev_get_addr(bus);
        plat->periph_id = clock_decode_periph_id(blob, node);
index e1da23b..1d99a1e 100644 (file)
@@ -94,7 +94,7 @@ static int tegra30_spi_ofdata_to_platdata(struct udevice *bus)
 {
        struct tegra_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->base = dev_get_addr(bus);
        plat->periph_id = clock_decode_periph_id(blob, node);
index 026cff0..1e094cb 100644 (file)
@@ -97,7 +97,7 @@ static int tegra210_qspi_ofdata_to_platdata(struct udevice *bus)
 {
        struct tegra_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->base = dev_get_addr(bus);
        plat->periph_id = clock_decode_periph_id(blob, node);
index 6f9f983..79955d7 100644 (file)
@@ -553,7 +553,7 @@ static int ti_qspi_ofdata_to_platdata(struct udevice *bus)
 {
        struct ti_qspi_priv *priv = dev_get_priv(bus);
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
        fdt_addr_t addr;
        void *mmap;
 
index b98663c..255e02f 100644 (file)
@@ -101,7 +101,7 @@ static int zynq_qspi_ofdata_to_platdata(struct udevice *bus)
 {
        struct zynq_qspi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->regs = (struct zynq_qspi_regs *)fdtdec_get_addr(blob,
                                                              node, "reg");
index 15ca271..5a9b1f0 100644 (file)
@@ -71,7 +71,7 @@ static int zynq_spi_ofdata_to_platdata(struct udevice *bus)
 {
        struct zynq_spi_platdata *plat = bus->platdata;
        const void *blob = gd->fdt_blob;
-       int node = bus->of_offset;
+       int node = dev_of_offset(bus);
 
        plat->regs = (struct zynq_spi_regs *)dev_get_addr(bus);
 
index 48bc157..605683f 100644 (file)
@@ -147,18 +147,14 @@ static int msm_spmi_probe(struct udevice *dev)
 {
        struct udevice *parent = dev->parent;
        struct msm_spmi_priv *priv = dev_get_priv(dev);
+       int node = dev_of_offset(dev);
        int i;
 
        priv->arb_chnl = dev_get_addr(dev);
        priv->spmi_core = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-                                                          parent->of_offset,
-                                                          dev->of_offset,
-                                                          "reg", 1, NULL,
-                                                          false);
+                       dev_of_offset(parent), node, "reg", 1, NULL, false);
        priv->spmi_obs = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
-                                                         parent->of_offset,
-                                                         dev->of_offset, "reg",
-                                                         2, NULL, false);
+                       dev_of_offset(parent), node, "reg", 2, NULL, false);
        if (priv->arb_chnl == FDT_ADDR_T_NONE ||
            priv->spmi_core == FDT_ADDR_T_NONE ||
            priv->spmi_obs == FDT_ADDR_T_NONE)
index 7ae7f38..0c4e2e1 100644 (file)
@@ -41,7 +41,7 @@ static int sandbox_sysreset_request(struct udevice *dev, enum sysreset_t type)
         * (see the U_BOOT_DEVICE() declaration below) should not do anything.
         * If we are that device, return an error.
         */
-       if (state->fdt_fname && dev->of_offset == -1)
+       if (state->fdt_fname && dev_of_offset(dev) == -1)
                return -ENODEV;
 
        switch (type) {
index 5c63e6b..1caf3cd 100644 (file)
@@ -55,7 +55,7 @@ static int timer_pre_probe(struct udevice *dev)
                uc_priv->clock_rate = ret;
        } else
                uc_priv->clock_rate = fdtdec_get_int(gd->fdt_blob,
-                               dev->of_offset, "clock-frequency", 0);
+                               dev_of_offset(dev),     "clock-frequency", 0);
 
        return 0;
 }
index 0965ad0..9abb323 100644 (file)
@@ -373,8 +373,8 @@ static int sandbox_flash_ofdata_to_platdata(struct udevice *dev)
        struct sandbox_flash_plat *plat = dev_get_platdata(dev);
        const void *blob = gd->fdt_blob;
 
-       plat->pathname = fdt_getprop(blob, dev->of_offset, "sandbox,filepath",
-                                    NULL);
+       plat->pathname = fdt_getprop(blob, dev_of_offset(dev),
+                                    "sandbox,filepath", NULL);
 
        return 0;
 }
index 624fbde..c3a8e73 100644 (file)
@@ -277,7 +277,8 @@ static int sandbox_child_post_bind(struct udevice *dev)
 {
        struct sandbox_hub_platdata *plat = dev_get_parent_platdata(dev);
 
-       plat->port = fdtdec_get_int(gd->fdt_blob, dev->of_offset, "reg", -1);
+       plat->port = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg",
+                                   -1);
 
        return 0;
 }
index d08879d..d253b94 100644 (file)
@@ -1199,8 +1199,8 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)
                return -EINVAL;
        priv->regs = (struct dwc2_core_regs *)addr;
 
-       prop = fdt_getprop(gd->fdt_blob, dev->of_offset, "disable-over-current",
-                          NULL);
+       prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev),
+                          "disable-over-current", NULL);
        if (prop)
                priv->oc_disable = true;
 
index 53281d7..981543e 100644 (file)
@@ -59,7 +59,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
        }
 
        depth = 0;
-       node = fdtdec_next_compatible_subnode(blob, dev->of_offset,
+       node = fdtdec_next_compatible_subnode(blob, dev_of_offset(dev),
                                COMPAT_SAMSUNG_EXYNOS_USB_PHY, &depth);
        if (node <= 0) {
                debug("XHCI: Can't get device node for usb3-phy controller\n");
index 9c32921..7ad50fc 100644 (file)
@@ -61,7 +61,7 @@ static int ehci_fsl_ofdata_to_platdata(struct udevice *dev)
        struct ehci_fsl_priv *priv = dev_get_priv(dev);
        const void *prop;
 
-       prop = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy_type",
+       prop = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy_type",
                           NULL);
        if (prop) {
                priv->phy_type = (char *)prop;
index 7b309b7..55ac162 100644 (file)
@@ -437,7 +437,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
        void *__iomem addr = (void *__iomem)dev_get_addr(dev);
        void *__iomem phy_ctrl, *__iomem phy_status;
        const void *blob = gd->fdt_blob;
-       int offset = dev->of_offset, phy_off;
+       int offset = dev_of_offset(dev), phy_off;
        u32 val;
 
        /*
@@ -484,7 +484,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
        struct usb_platdata *plat = dev_get_platdata(dev);
        const char *mode;
 
-       mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "dr_mode", NULL);
+       mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "dr_mode", NULL);
        if (mode) {
                if (strcmp(mode, "peripheral") == 0)
                        plat->init_type = USB_INIT_DEVICE;
index e3620da..beb3b02 100644 (file)
@@ -696,7 +696,7 @@ static void config_clock(const u32 timing[])
 static int fdt_decode_usb(struct udevice *dev, struct fdt_usb *config)
 {
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const char *phy, *mode;
 
        config->reg = (struct usb_ctlr *)dev_get_addr(dev);
index f389bff..84241cd 100644 (file)
@@ -218,7 +218,7 @@ static int vf_usb_ofdata_to_platdata(struct udevice *dev)
 {
        struct ehci_vf_priv_data *priv = dev_get_priv(dev);
        const void *dt_blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const char *mode;
 
        priv->portnr = dev->seq;
index be114fc..5cf1e9a 100644 (file)
@@ -686,16 +686,17 @@ int usb_child_post_bind(struct udevice *dev)
        const void *blob = gd->fdt_blob;
        int val;
 
-       if (dev->of_offset == -1)
+       if (dev_of_offset(dev) == -1)
                return 0;
 
        /* We only support matching a few things */
-       val = fdtdec_get_int(blob, dev->of_offset, "usb,device-class", -1);
+       val = fdtdec_get_int(blob, dev_of_offset(dev), "usb,device-class", -1);
        if (val != -1) {
                plat->id.match_flags |= USB_DEVICE_ID_MATCH_DEV_CLASS;
                plat->id.bDeviceClass = val;
        }
-       val = fdtdec_get_int(blob, dev->of_offset, "usb,interface-class", -1);
+       val = fdtdec_get_int(blob, dev_of_offset(dev), "usb,interface-class",
+                            -1);
        if (val != -1) {
                plat->id.match_flags |= USB_DEVICE_ID_MATCH_INT_CLASS;
                plat->id.bInterfaceClass = val;
index 82fcd84..b3f48b3 100644 (file)
@@ -68,7 +68,7 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
        }
 
        depth = 0;
-       node = fdtdec_next_compatible_subnode(blob, dev->of_offset,
+       node = fdtdec_next_compatible_subnode(blob, dev_of_offset(dev),
                                COMPAT_SAMSUNG_EXYNOS5_USB3_PHY, &depth);
        if (node <= 0) {
                debug("XHCI: Can't get device node for usb3-phy controller\n");
index 8cbcb8f..f559830 100644 (file)
@@ -90,11 +90,11 @@ static void rockchip_dwc3_phy_setup(struct dwc3 *dwc3_reg,
        /* Set dwc3 usb2 phy config */
        reg = readl(&dwc3_reg->g_usb2phycfg[0]);
 
-       if (fdtdec_get_bool(blob, dev->of_offset,
+       if (fdtdec_get_bool(blob, dev_of_offset(dev),
                            "snps,dis-enblslpm-quirk"))
                reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
 
-       utmi_bits = fdtdec_get_int(blob, dev->of_offset,
+       utmi_bits = fdtdec_get_int(blob, dev_of_offset(dev),
                                   "snps,phyif-utmi-bits", -1);
        if (utmi_bits == 16) {
                reg |= DWC3_GUSB2PHYCFG_PHYIF;
@@ -106,11 +106,11 @@ static void rockchip_dwc3_phy_setup(struct dwc3 *dwc3_reg,
                reg |= DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT;
        }
 
-       if (fdtdec_get_bool(blob, dev->of_offset,
+       if (fdtdec_get_bool(blob, dev_of_offset(dev),
                            "snps,dis-u2-freeclk-exists-quirk"))
                reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
 
-       if (fdtdec_get_bool(blob, dev->of_offset,
+       if (fdtdec_get_bool(blob, dev_of_offset(dev),
                            "snps,dis-u2-susphy-quirk"))
                reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
 
index c888c64..ed6da19 100644 (file)
@@ -219,7 +219,7 @@ static int musb_usb_probe(struct udevice *dev)
        struct musb_host_data *mdata = &pdata->mdata;
        struct fdt_resource mc, glue;
        void *fdt = (void *)gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        void __iomem *mregs;
        int ret;
 
index 1c15aa2..852f07f 100644 (file)
@@ -83,7 +83,7 @@ static int ti_musb_ofdata_to_platdata(struct udevice *dev)
 {
        struct ti_musb_platdata *platdata = dev_get_platdata(dev);
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int phys;
        int ctrl_mod;
        int usb_index;
@@ -178,7 +178,7 @@ static int ti_musb_host_ofdata_to_platdata(struct udevice *dev)
 {
        struct ti_musb_platdata *platdata = dev_get_platdata(dev);
        const void *fdt = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
 
        ret = ti_musb_ofdata_to_platdata(dev);
@@ -209,7 +209,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
        int node;
        int ret;
 
-       for (node = fdt_first_subnode(fdt, parent->of_offset); node > 0;
+       for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
             node = fdt_next_subnode(fdt, node)) {
                struct udevice *dev;
                const char *name = fdt_get_name(fdt, node, NULL);
index 39cd7ca..ed2bd30 100644 (file)
@@ -276,7 +276,7 @@ static int atmel_fb_ofdata_to_platdata(struct udevice *dev)
        struct display_timing *timing = &priv->timing;
        const void *blob = gd->fdt_blob;
 
-       if (fdtdec_decode_display_timing(blob, dev->of_offset,
+       if (fdtdec_decode_display_timing(blob, dev_of_offset(dev),
                                         plat->timing_index, timing)) {
                debug("%s: Failed to decode display timing\n", __func__);
                return -EINVAL;
index 80f63e3..46aacca 100644 (file)
@@ -86,7 +86,8 @@ static int ps8622_attach(struct udevice *dev)
        if (ret)
                return ret;
 
-       params = fdt_getprop(gd->fdt_blob, dev->of_offset, "parade,regs", &len);
+       params = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "parade,regs",
+                            &len);
        if (!params || len % 3) {
                debug("%s: missing/invalid params=%p, len=%x\n", __func__,
                      params, len);
index beef770..4612d04 100644 (file)
@@ -705,7 +705,7 @@ static int broadwell_igd_ofdata_to_platdata(struct udevice *dev)
 {
        struct broadwell_igd_plat *plat = dev_get_platdata(dev);
        struct broadwell_igd_priv *priv = dev_get_priv(dev);
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        const void *blob = gd->fdt_blob;
 
        if (fdtdec_get_int_array(blob, node, "intel,dp-hotplug",
index fc39f2c..c5039e7 100644 (file)
@@ -880,7 +880,7 @@ static int exynos_dp_ofdata_to_platdata(struct udevice *dev)
 {
        struct exynos_dp_priv *priv = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
-       unsigned int node = dev->of_offset;
+       unsigned int node = dev_of_offset(dev);
        fdt_addr_t addr;
 
        addr = dev_get_addr(dev);
index 5483d66..46320e7 100644 (file)
@@ -383,7 +383,7 @@ void exynos_fimd_lcd_init(struct udevice *dev)
        unsigned int offset;
        unsigned int node;
 
-       node = dev->of_offset;
+       node = dev_of_offset(dev);
        if (fdtdec_get_bool(gd->fdt_blob, node, "samsung,disable-sysmmu"))
                exynos_fimd_disable_sysmmu();
 
@@ -482,7 +482,7 @@ unsigned long exynos_fimd_calc_fbsize(struct exynos_fb_priv *priv)
 int exynos_fb_ofdata_to_platdata(struct udevice *dev)
 {
        struct exynos_fb_priv *priv = dev_get_priv(dev);
-       unsigned int node = dev->of_offset;
+       unsigned int node = dev_of_offset(dev);
        const void *blob = gd->fdt_blob;
        fdt_addr_t addr;
 
index f16d725..d8af2e1 100644 (file)
@@ -517,7 +517,7 @@ static int gma_pm_init_pre_vbios(void *gtt_bar, int rev)
 static int gma_pm_init_post_vbios(struct udevice *dev, int rev, void *gtt_bar)
 {
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        u32 reg32, cycle_delay;
 
        debug("GT Power Management Init (post VBIOS)\n");
index de6277f..3697f49 100644 (file)
@@ -61,7 +61,7 @@ static int pwm_backlight_ofdata_to_platdata(struct udevice *dev)
        struct pwm_backlight_priv *priv = dev_get_priv(dev);
        struct fdtdec_phandle_args args;
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int index, ret, count, len;
        const u32 *cell;
 
index fcbb4d6..ee43255 100644 (file)
@@ -162,7 +162,7 @@ int rk_lvds_enable(struct udevice *dev, int panel_bpp,
 int rk_lvds_read_timing(struct udevice *dev, struct display_timing *timing)
 {
        if (fdtdec_decode_display_timing
-           (gd->fdt_blob, dev->of_offset, 0, timing)) {
+           (gd->fdt_blob, dev_of_offset(dev), 0, timing)) {
                debug("%s: Failed to decode display timing\n", __func__);
                return -EINVAL;
        }
@@ -174,7 +174,7 @@ static int rk_lvds_ofdata_to_platdata(struct udevice *dev)
 {
        struct rk_lvds_priv *priv = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int ret;
        priv->regs = (void *)dev_get_addr(dev);
        priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
index eab5486..aeecb58 100644 (file)
@@ -321,7 +321,7 @@ static int rk_vop_probe(struct udevice *dev)
         * clock so it is currently not possible to use more than one display
         * device simultaneously.
         */
-       port = fdt_subnode_offset(blob, dev->of_offset, "port");
+       port = fdt_subnode_offset(blob, dev_of_offset(dev), "port");
        if (port < 0)
                return -EINVAL;
        for (node = fdt_first_subnode(blob, port);
index dc5a220..18afe2f 100644 (file)
@@ -46,7 +46,7 @@ static int sandbox_sdl_bind(struct udevice *dev)
        struct video_uc_platdata *uc_plat = dev_get_uclass_platdata(dev);
        struct sandbox_sdl_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 = 0;
 
        plat->xres = fdtdec_get_int(blob, node, "xres", LCD_MAX_WIDTH);
index 92214d6..0ba3f2c 100644 (file)
@@ -338,7 +338,7 @@ static int tegra_lcd_ofdata_to_platdata(struct udevice *dev)
        struct tegra_lcd_priv *priv = dev_get_priv(dev);
        const void *blob = gd->fdt_blob;
        struct display_timing *timing;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int panel_node;
        int rgb;
        int ret;
@@ -392,7 +392,7 @@ static int tegra_lcd_bind(struct udevice *dev)
 {
        struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
        const void *blob = gd->fdt_blob;
-       int node = dev->of_offset;
+       int node = dev_of_offset(dev);
        int rgb;
 
        rgb = fdt_subnode_offset(blob, node, "rgb");
index 28db96c..bbbca13 100644 (file)
@@ -363,9 +363,9 @@ static int display_init(struct udevice *dev, void *lcdbase,
                return ret;
        }
 
-       dc_ctlr = (struct dc_ctlr *)fdtdec_get_addr(blob, dev->of_offset,
+       dc_ctlr = (struct dc_ctlr *)fdtdec_get_addr(blob, dev_of_offset(dev),
                                                    "reg");
-       if (fdtdec_decode_display_timing(blob, dev->of_offset, 0, timing)) {
+       if (fdtdec_decode_display_timing(blob, dev_of_offset(dev), 0, timing)) {
                debug("%s: Failed to decode display timing\n", __func__);
                return -EINVAL;
        }
index e5cea51..5e4140f 100644 (file)
@@ -757,7 +757,7 @@ int tegra_dc_sor_attach(struct udevice *dc_dev, struct udevice *dev,
 
        /* Use the first display controller */
        debug("%s\n", __func__);
-       node = dc_dev->of_offset;
+       node = dev_of_offset(dc_dev);
        disp_ctrl = (struct dc_ctlr *)fdtdec_get_addr(blob, node, "reg");
 
        tegra_dc_sor_enable_dc(disp_ctrl);
@@ -973,7 +973,7 @@ int tegra_dc_sor_detach(struct udevice *dc_dev, struct udevice *dev)
 
        debug("%s\n", __func__);
        /* Use the first display controller */
-       node = dc_dev->of_offset;
+       node = dev_of_offset(dc_dev);
        disp_ctrl = (struct dc_ctlr *)fdtdec_get_addr(blob, node, "reg");
 
        /* Sleep mode */
@@ -1045,7 +1045,7 @@ static int tegra_sor_ofdata_to_platdata(struct udevice *dev)
        int node;
        int ret;
 
-       priv->base = (void *)fdtdec_get_addr(blob, dev->of_offset, "reg");
+       priv->base = (void *)fdtdec_get_addr(blob, dev_of_offset(dev), "reg");
 
        node = fdtdec_next_compatible(blob, 0, COMPAT_NVIDIA_TEGRA124_PMC);
        if (node < 0) {
index 9948bd4..4e95fb7 100644 (file)
@@ -121,6 +121,16 @@ struct udevice {
 /* Returns non-zero if the device is active (probed and not removed) */
 #define device_active(dev)     ((dev)->flags & DM_FLAG_ACTIVATED)
 
+static inline int dev_of_offset(const struct udevice *dev)
+{
+       return dev->of_offset;
+}
+
+static inline void dev_set_of_offset(struct udevice *dev, int of_offset)
+{
+       dev->of_offset = of_offset;
+}
+
 /**
  * struct udevice_id - Lists the compatible strings supported by a driver
  * @compatible: Compatible string
index 5733096..f52cb73 100644 (file)
@@ -35,7 +35,7 @@ static int dm_test_spi_find(struct unit_test_state *uts)
         */
        ut_asserteq(0, uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus));
        ut_assertok(spi_cs_info(bus, cs, &info));
-       of_offset = info.dev->of_offset;
+       of_offset = dev_of_offset(info.dev);
        device_remove(info.dev);
        device_unbind(info.dev);
 
index 49a36cb..3048a7b 100644 (file)
@@ -37,9 +37,9 @@ static int testfdt_ofdata_to_platdata(struct udevice *dev)
 {
        struct dm_test_pdata *pdata = dev_get_platdata(dev);
 
-       pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+       pdata->ping_add = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                        "ping-add", -1);
-       pdata->base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset,
+       pdata->base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev),
                                      "ping-expect");
 
        return 0;
@@ -121,10 +121,10 @@ int dm_check_devices(struct unit_test_state *uts, int num_devices)
                 * want to test the code that sets that up
                 * (testfdt_drv_probe()).
                 */
-               base = fdtdec_get_addr(gd->fdt_blob, dev->of_offset,
+               base = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev),
                                       "ping-expect");
                debug("dev=%d, base=%d: %s\n", i, base,
-                     fdt_get_name(gd->fdt_blob, dev->of_offset, NULL));
+                     fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL));
 
                ut_assert(!dm_check_operations(uts, dev, base,
                                               dev_get_priv(dev)));