From e160f7d430f163bc42757aff3bf2bcac0a459f02 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2017 16:52:55 -0700 Subject: dm: core: Replace of_offset with accessor 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 --- drivers/clk/at91/clk-generated.c | 5 ++--- drivers/clk/at91/pmc.c | 5 +++-- drivers/clk/clk-uclass.c | 4 ++-- drivers/clk/clk_fixed_rate.c | 2 +- drivers/clk/clk_pic32.c | 5 +++-- 5 files changed, 11 insertions(+), 10 deletions(-) (limited to 'drivers/clk') diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index d36f64ffdf..ac27d3e675 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -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; diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 76ba91af81..c73156a0df 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -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; diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 153ceba702..6fcfd6997c 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -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); diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c index 9c4d2b322f..3911bf61a0 100644 --- a/drivers/clk/clk_fixed_rate.c +++ b/drivers/clk/clk_fixed_rate.c @@ -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 diff --git a/drivers/clk/clk_pic32.c b/drivers/clk/clk_pic32.c index 70ec3543cf..f6eef314ec 100644 --- a/drivers/clk/clk_pic32.c +++ b/drivers/clk/clk_pic32.c @@ -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; -- cgit