dm: Use access methods for dev/uclass private data
Most drivers use these access methods but a few do not. Update them.
In some cases the access is not permitted, so mark those with a FIXME tag
for the maintainer to check.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index acd77b6..e6e9194 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -141,7 +141,7 @@
static int gpio_dwapb_probe(struct udevice *dev)
{
struct gpio_dev_priv *priv = dev_get_uclass_priv(dev);
- struct gpio_dwapb_plat *plat = dev->plat;
+ struct gpio_dwapb_plat *plat = dev_get_plat(dev);
if (!plat) {
/* Reset on parent device only */
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 65b18ce..952c111 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -1165,7 +1165,7 @@
if (!dev)
return -1;
- uc_priv = dev->uclass_priv;
+ uc_priv = dev_get_uclass_priv(dev);
return uc_priv->gpio_base + desc->offset;
}
diff --git a/drivers/gpio/hi6220_gpio.c b/drivers/gpio/hi6220_gpio.c
index f5e5fc6..04f8d90 100644
--- a/drivers/gpio/hi6220_gpio.c
+++ b/drivers/gpio/hi6220_gpio.c
@@ -67,7 +67,7 @@
{
struct gpio_bank *bank = dev_get_priv(dev);
struct hikey_gpio_plat *plat = dev_get_plat(dev);
- struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+ struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
char name[18], *str;
sprintf(name, "GPIO%d_", plat->bank_index);
diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c
index 17edd40..a5a290a 100644
--- a/drivers/gpio/imx_rgpio2p.c
+++ b/drivers/gpio/imx_rgpio2p.c
@@ -11,6 +11,7 @@
#include <fdtdec.h>
#include <asm/gpio.h>
#include <asm/io.h>
+#include <dm/device-internal.h>
#include <malloc.h>
enum imx_rgpio2p_direction {
@@ -151,7 +152,7 @@
static int imx_rgpio2p_bind(struct udevice *dev)
{
- struct imx_rgpio2p_plat *plat = dev->plat;
+ struct imx_rgpio2p_plat *plat = dev_get_plat(dev);
fdt_addr_t addr;
/*
@@ -184,7 +185,7 @@
plat->regs = (struct gpio_regs *)addr;
plat->bank_index = dev_seq(dev);
- dev->plat = plat;
+ dev_set_plat(dev, plat);
return 0;
}
diff --git a/drivers/gpio/lpc32xx_gpio.c b/drivers/gpio/lpc32xx_gpio.c
index ffaec32..de66c76 100644
--- a/drivers/gpio/lpc32xx_gpio.c
+++ b/drivers/gpio/lpc32xx_gpio.c
@@ -295,7 +295,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;
+ struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
if (dev_of_offset(dev) == -1) {
/* Tell the uclass how many GPIOs we have */
diff --git a/drivers/gpio/mt7621_gpio.c b/drivers/gpio/mt7621_gpio.c
index 65b4cbf..43bb4df 100644
--- a/drivers/gpio/mt7621_gpio.c
+++ b/drivers/gpio/mt7621_gpio.c
@@ -130,7 +130,7 @@
*/
static int gpio_mediatek_bind(struct udevice *parent)
{
- struct mediatek_gpio_plat *plat = parent->plat;
+ struct mediatek_gpio_plat *plat = dev_get_plat(parent);
ofnode node;
int bank = 0;
int ret;
diff --git a/drivers/gpio/mxs_gpio.c b/drivers/gpio/mxs_gpio.c
index 5ad65e4..fd5e0ea 100644
--- a/drivers/gpio/mxs_gpio.c
+++ b/drivers/gpio/mxs_gpio.c
@@ -264,7 +264,7 @@
#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
static int mxs_of_to_plat(struct udevice *dev)
{
- struct mxs_gpio_plat *plat = dev->plat;
+ struct mxs_gpio_plat *plat = dev_get_plat(dev);
struct fdtdec_phandle_args args;
int node = dev_of_offset(dev);
int ret;
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index 400c6ca..336ece4 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -22,6 +22,7 @@
#include <fdtdec.h>
#include <asm/gpio.h>
#include <asm/io.h>
+#include <dm/device-internal.h>
#include <linux/errno.h>
#include <malloc.h>
@@ -328,7 +329,7 @@
plat->base = base_addr;
plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
- dev->plat = plat;
+ dev_set_plat(dev, plat);
return 0;
}
diff --git a/drivers/gpio/s5p_gpio.c b/drivers/gpio/s5p_gpio.c
index 9de9541..796fe3e 100644
--- a/drivers/gpio/s5p_gpio.c
+++ b/drivers/gpio/s5p_gpio.c
@@ -286,8 +286,8 @@
static int gpio_exynos_probe(struct udevice *dev)
{
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
- struct exynos_bank_info *priv = dev->priv;
- struct exynos_gpio_plat *plat = dev->plat;
+ struct exynos_bank_info *priv = dev_get_priv(dev);
+ struct exynos_gpio_plat *plat = dev_get_plat(dev);
/* Only child devices have ports */
if (!plat)
@@ -307,7 +307,7 @@
*/
static int gpio_exynos_bind(struct udevice *parent)
{
- struct exynos_gpio_plat *plat = parent->plat;
+ struct exynos_gpio_plat *plat = dev_get_plat(parent);
struct s5p_gpio_bank *bank, *base;
const void *blob = gd->fdt_blob;
int node;
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index 2708838..489271b 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -11,6 +11,7 @@
#include <acpi/acpi_device.h>
#include <asm/gpio.h>
#include <dm/acpi.h>
+#include <dm/device-internal.h>
#include <dm/device_compat.h>
#include <dm/lists.h>
#include <dm/of.h>
@@ -297,14 +298,15 @@
/* Tell the uclass how many GPIOs we have */
uc_priv->gpio_count = CONFIG_SANDBOX_GPIO_COUNT;
- dev->priv = calloc(sizeof(struct gpio_state), uc_priv->gpio_count);
+ dev_set_priv(dev,
+ calloc(sizeof(struct gpio_state), uc_priv->gpio_count));
return 0;
}
static int gpio_sandbox_remove(struct udevice *dev)
{
- free(dev->priv);
+ free(dev_get_priv(dev));
return 0;
}
diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index 75494c7..7633422 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -285,7 +285,7 @@
{
struct sunxi_gpio_soc_data *soc_data =
(struct sunxi_gpio_soc_data *)dev_get_driver_data(parent);
- struct sunxi_gpio_plat *plat = parent->plat;
+ struct sunxi_gpio_plat *plat = dev_get_plat(parent);
struct sunxi_gpio_reg *ctlr;
int bank, ret;
diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c
index cd1fb65..82dcaf9 100644
--- a/drivers/gpio/tegra186_gpio.c
+++ b/drivers/gpio/tegra186_gpio.c
@@ -34,7 +34,7 @@
static uint32_t *tegra186_gpio_reg(struct udevice *dev, uint32_t reg,
uint32_t gpio)
{
- struct tegra186_gpio_plat *plat = dev->plat;
+ struct tegra186_gpio_plat *plat = dev_get_plat(dev);
uint32_t index = (reg + (gpio * TEGRA186_GPIO_PER_GPIO_STRIDE)) / 4;
return &(plat->regs[index]);
@@ -166,7 +166,7 @@
*/
static int tegra186_gpio_bind(struct udevice *parent)
{
- struct tegra186_gpio_plat *parent_plat = parent->plat;
+ struct tegra186_gpio_plat *parent_plat = dev_get_plat(parent);
struct tegra186_gpio_ctlr_data *ctlr_data =
(struct tegra186_gpio_ctlr_data *)dev_get_driver_data(parent);
uint32_t *regs;
@@ -201,7 +201,7 @@
static int tegra186_gpio_probe(struct udevice *dev)
{
- struct tegra186_gpio_plat *plat = dev->plat;
+ struct tegra186_gpio_plat *plat = dev_get_plat(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
/* Only child devices have ports */
diff --git a/drivers/gpio/tegra_gpio.c b/drivers/gpio/tegra_gpio.c
index c489796..5d3af8a 100644
--- a/drivers/gpio/tegra_gpio.c
+++ b/drivers/gpio/tegra_gpio.c
@@ -291,8 +291,8 @@
static int gpio_tegra_probe(struct udevice *dev)
{
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
- struct tegra_port_info *priv = dev->priv;
- struct tegra_gpio_plat *plat = dev->plat;
+ struct tegra_port_info *priv = dev_get_priv(dev);
+ struct tegra_gpio_plat *plat = dev_get_plat(dev);
/* Only child devices have ports */
if (!plat)
@@ -313,7 +313,7 @@
*/
static int gpio_tegra_bind(struct udevice *parent)
{
- struct tegra_gpio_plat *plat = parent->plat;
+ struct tegra_gpio_plat *plat = dev_get_plat(parent);
struct gpio_ctlr *ctlr;
int bank_count;
int bank;