mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 7/7] driver: migrate some from dev_get_drvdata to device_get_match_data
Date: Mon, 28 Sep 2020 17:42:47 +0200	[thread overview]
Message-ID: <20200928154247.15619-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200928154247.15619-1-a.fatoum@pengutronix.de>

The dev_get_drvdata instances here all store a valid pointer in the
match data and can be readily converted. Do so.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mfd/da9063.c                 | 4 +---
 drivers/pinctrl/imx-iomux-v3.c       | 4 ++--
 drivers/pinctrl/pinctrl-at91-pio4.c  | 4 ++--
 drivers/pinctrl/pinctrl-tegra-xusb.c | 2 +-
 drivers/pinctrl/pinctrl-tegra30.c    | 4 ++--
 drivers/serial/serial_ns16550.c      | 6 ++----
 6 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/da9063.c b/drivers/mfd/da9063.c
index e48c38affac6..31359cf8b822 100644
--- a/drivers/mfd/da9063.c
+++ b/drivers/mfd/da9063.c
@@ -370,11 +370,9 @@ static int da9063_probe(struct device_d *dev)
 {
 	struct da9063 *priv = NULL;
 	struct da906x_device_data const *dev_data;
-	void const *dev_data_tmp;
 	int ret;
 
-	ret = dev_get_drvdata(dev, &dev_data_tmp);
-	dev_data = ret < 0 ? NULL : dev_data_tmp;
+	dev_data = device_get_match_data(dev);
 
 	priv = xzalloc(sizeof(struct da9063));
 	priv->wd.set_timeout = da9063_watchdog_set_timeout;
diff --git a/drivers/pinctrl/imx-iomux-v3.c b/drivers/pinctrl/imx-iomux-v3.c
index fd0527451276..4276981d94c0 100644
--- a/drivers/pinctrl/imx-iomux-v3.c
+++ b/drivers/pinctrl/imx-iomux-v3.c
@@ -168,10 +168,10 @@ static struct pinctrl_ops imx_iomux_v3_ops = {
 static int imx_pinctrl_dt(struct device_d *dev, void __iomem *base)
 {
 	struct imx_iomux_v3 *iomux;
-	struct imx_iomux_v3_data *drvdata = NULL;
+	const struct imx_iomux_v3_data *drvdata;
 	int ret;
 
-	dev_get_drvdata(dev, (const void **)&drvdata);
+	drvdata = device_get_match_data(dev);
 	iomux = xzalloc(sizeof(*iomux));
 
 	iomux->base = base;
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index b527114f1ba0..18b1aded6a1b 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -229,7 +229,7 @@ static struct gpio_ops at91_gpio4_ops = {
 static int pinctrl_at91_pio4_gpiochip_add(struct device_d *dev,
 					  struct pinctrl_at91_pio4 *pinctrl)
 {
-	struct at91_pinctrl_data *drvdata;
+	const struct at91_pinctrl_data *drvdata;
 	struct clk *clk;
 	int ret;
 
@@ -247,7 +247,7 @@ static int pinctrl_at91_pio4_gpiochip_add(struct device_d *dev,
 		return ret;
 	}
 
-	dev_get_drvdata(dev, (const void **)&drvdata);
+	drvdata = device_get_match_data(dev);
 
 	pinctrl->gpiochip.ops = &at91_gpio4_ops;
 	pinctrl->gpiochip.base = 0;
diff --git a/drivers/pinctrl/pinctrl-tegra-xusb.c b/drivers/pinctrl/pinctrl-tegra-xusb.c
index c4d3bbe8d429..558742665ea8 100644
--- a/drivers/pinctrl/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/pinctrl-tegra-xusb.c
@@ -388,7 +388,7 @@ static int pinctrl_tegra_xusb_probe(struct device_d *dev)
 	dev->priv = padctl;
 	padctl->dev = dev;
 
-	dev_get_drvdata(dev, (const void **)&padctl->soc);
+	padctl->soc = device_get_match_data(dev);
 
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores)) {
diff --git a/drivers/pinctrl/pinctrl-tegra30.c b/drivers/pinctrl/pinctrl-tegra30.c
index 278ea8c4a0b3..cc71b79f6c9b 100644
--- a/drivers/pinctrl/pinctrl-tegra30.c
+++ b/drivers/pinctrl/pinctrl-tegra30.c
@@ -32,7 +32,7 @@ struct pinctrl_tegra30 {
 		u32 __iomem *mux;
 	} regs;
 	struct pinctrl_device pinctrl;
-	struct pinctrl_tegra30_drvdata *drvdata;
+	const struct pinctrl_tegra30_drvdata *drvdata;
 };
 
 struct tegra_pingroup {
@@ -893,7 +893,7 @@ static int pinctrl_tegra30_probe(struct device_d *dev)
 		regs[i] = IOMEM(iores->start);
 	}
 
-	dev_get_drvdata(dev, (const void **)&ctrl->drvdata);
+	ctrl->drvdata = device_get_match_data(dev);
 
 	ctrl->pinctrl.dev = dev;
 	ctrl->pinctrl.ops = &pinctrl_tegra30_ops;
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index f117ab9dc10a..fc6fa7dc3e43 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -468,12 +468,10 @@ static int ns16550_probe(struct device_d *dev)
 	struct ns16550_priv *priv;
 	struct console_device *cdev;
 	struct NS16550_plat *plat = (struct NS16550_plat *)dev->platform_data;
-	struct ns16550_drvdata *devtype;
+	const struct ns16550_drvdata *devtype;
 	int ret;
 
-	ret = dev_get_drvdata(dev, (const void **)&devtype);
-	if (ret)
-		devtype = &ns16550_drvdata;
+	devtype = device_get_match_data(dev) ?: &ns16550_drvdata;
 
 	priv = xzalloc(sizeof(*priv));
 
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-09-28 15:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 15:42 [PATCH 1/7] driver: introduce less error-prone dev_get_drvdata alternative Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 2/7] led: pca955x: fix probing from device tree Ahmad Fatoum
2020-09-29  7:19   ` Sascha Hauer
2020-09-30  7:28     ` Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 3/7] dma: apbh: fix out-of-bounds write on 64-bit SoCs Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 4/7] aiodev: lm75: " Ahmad Fatoum
2020-09-28 15:42 ` [PATCH 5/7] mtd: nand-mxs: " Ahmad Fatoum
2020-09-28 16:01   ` Marco Felsch
2020-09-28 16:03     ` Ahmad Fatoum
2020-09-28 16:08       ` Marco Felsch
2020-09-28 15:42 ` [PATCH 6/7] video: imx-hdmi: fix dev_get_drvdata misuse Ahmad Fatoum
2020-09-28 15:42 ` Ahmad Fatoum [this message]
2020-09-28 15:46 ` [PATCH 1/7] driver: introduce less error-prone dev_get_drvdata alternative Ahmad Fatoum
2020-09-29  6:45 ` Sascha Hauer
2020-09-29  7:32 ` Sascha Hauer
2020-09-29  9:42   ` Ahmad Fatoum
2020-09-30  7:48     ` Sascha Hauer
2020-09-30 13:13       ` Ahmad Fatoum
2020-10-05  8:31         ` Ahmad Fatoum
2020-10-07  8:43           ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200928154247.15619-7-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox