summaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-01-17 16:52:55 -0700
committerSimon Glass <sjg@chromium.org>2017-02-08 06:12:14 -0700
commite160f7d430f163bc42757aff3bf2bcac0a459f02 (patch)
treece006f94b4a52f6fff567eacd86922c3be6df706 /drivers/gpio
parent8aa41363ebf46b9ff63b311bd2aa793c67a49def (diff)
downloadu-boot-e160f7d430f163bc42757aff3bf2bcac0a459f02.tar.gz
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 <sjg@chromium.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/74x164_gpio.c2
-rw-r--r--drivers/gpio/altera_pio.c4
-rw-r--r--drivers/gpio/atmel_pio4.c5
-rw-r--r--drivers/gpio/dwapb_gpio.c6
-rw-r--r--drivers/gpio/gpio-uclass.c6
-rw-r--r--drivers/gpio/intel_broadwell_gpio.c4
-rw-r--r--drivers/gpio/intel_ich6_gpio.c4
-rw-r--r--drivers/gpio/lpc32xx_gpio.c2
-rw-r--r--drivers/gpio/mpc85xx_gpio.c8
-rw-r--r--drivers/gpio/msm_gpio.c4
-rw-r--r--drivers/gpio/omap_gpio.c2
-rw-r--r--drivers/gpio/pca953x_gpio.c2
-rw-r--r--drivers/gpio/pcf8575_gpio.c8
-rw-r--r--drivers/gpio/pic32_gpio.c3
-rw-r--r--drivers/gpio/pm8916_gpio.c4
-rw-r--r--drivers/gpio/s5p_gpio.c4
-rw-r--r--drivers/gpio/sandbox.c6
-rw-r--r--drivers/gpio/sunxi_gpio.c2
-rw-r--r--drivers/gpio/tegra186_gpio.c2
-rw-r--r--drivers/gpio/tegra_gpio.c5
-rw-r--r--drivers/gpio/vybrid_gpio.c2
21 files changed, 44 insertions, 41 deletions
diff --git a/drivers/gpio/74x164_gpio.c b/drivers/gpio/74x164_gpio.c
index 9ac10a745d..750eedfffd 100644
--- a/drivers/gpio/74x164_gpio.c
+++ b/drivers/gpio/74x164_gpio.c
@@ -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);
diff --git a/drivers/gpio/altera_pio.c b/drivers/gpio/altera_pio.c
index 6f42bf8a22..92849c5295 100644
--- a/drivers/gpio/altera_pio.c
+++ b/drivers/gpio/altera_pio.c
@@ -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;
diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c
index cb90b0241a..81c3047551 100644
--- a/drivers/gpio/atmel_pio4.c
+++ b/drivers/gpio/atmel_pio4.c
@@ -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;
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 85e0a8647f..7d1904c1e1 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -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++;
}
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 4559739d61..9ab9df4ce7 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -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) {
diff --git a/drivers/gpio/intel_broadwell_gpio.c b/drivers/gpio/intel_broadwell_gpio.c
index 81ce446e1a..790577ac81 100644
--- a/drivers/gpio/intel_broadwell_gpio.c
+++ b/drivers/gpio/intel_broadwell_gpio.c
@@ -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;
diff --git a/drivers/gpio/intel_ich6_gpio.c b/drivers/gpio/intel_ich6_gpio.c
index fd6181fa5a..8b782260bc 100644
--- a/drivers/gpio/intel_ich6_gpio.c
+++ b/drivers/gpio/intel_ich6_gpio.c
@@ -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;
diff --git a/drivers/gpio/lpc32xx_gpio.c b/drivers/gpio/lpc32xx_gpio.c
index 9674ee75f0..1bf945acfc 100644
--- a/drivers/gpio/lpc32xx_gpio.c
+++ b/drivers/gpio/lpc32xx_gpio.c
@@ -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;
}
diff --git a/drivers/gpio/mpc85xx_gpio.c b/drivers/gpio/mpc85xx_gpio.c
index 168c696c4d..cfeb6e7632 100644
--- a/drivers/gpio/mpc85xx_gpio.c
+++ b/drivers/gpio/mpc85xx_gpio.c
@@ -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;
}
diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c
index 03029792c2..01ce1d6fa0 100644
--- a/drivers/gpio/msm_gpio.c
+++ b/drivers/gpio/msm_gpio.c
@@ -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";
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index f906b97fb7..5338552179 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -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;
diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c
index 0410add518..b81f0fa90c 100644
--- a/drivers/gpio/pca953x_gpio.c
+++ b/drivers/gpio/pca953x_gpio.c
@@ -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;
diff --git a/drivers/gpio/pcf8575_gpio.c b/drivers/gpio/pcf8575_gpio.c
index 2bda0ff996..2cbb9e61ea 100644
--- a/drivers/gpio/pcf8575_gpio.c
+++ b/drivers/gpio/pcf8575_gpio.c
@@ -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;
diff --git a/drivers/gpio/pic32_gpio.c b/drivers/gpio/pic32_gpio.c
index 7a037f3a77..e838ad45a8 100644
--- a/drivers/gpio/pic32_gpio.c
+++ b/drivers/gpio/pic32_gpio.c
@@ -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;
diff --git a/drivers/gpio/pm8916_gpio.c b/drivers/gpio/pm8916_gpio.c
index 0b61975843..e38cee8869 100644
--- a/drivers/gpio/pm8916_gpio.c
+++ b/drivers/gpio/pm8916_gpio.c
@@ -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";
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
index 377fed467f..042996e559 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -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)
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index f6435a0543..ae6d93013f 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -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;
}
diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index e8accaa333..8d2bb18504 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -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;
diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c
index 1c681514db..b0c22e5bfe 100644
--- a/drivers/gpio/tegra186_gpio.c
+++ b/drivers/gpio/tegra186_gpio.c
@@ -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;
diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c
index 5a031159ca..b01968a304 100644
--- a/drivers/gpio/tegra_gpio.c
+++ b/drivers/gpio/tegra_gpio.c
@@ -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));
}
}
diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c
index a30ba5d2ed..458104e8b0 100644
--- a/drivers/gpio/vybrid_gpio.c
+++ b/drivers/gpio/vybrid_gpio.c
@@ -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;