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/mmc/msm_sdhci.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'drivers/mmc/msm_sdhci.c') diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c index 1db683d..7a7e67f 100644 --- a/drivers/mmc/msm_sdhci.c +++ b/drivers/mmc/msm_sdhci.c @@ -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; -- cgit v1.1