From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 6/8] pinctrl: at91: replace dev_get_drvdata with device_get_match_data
Date: Tue, 6 May 2025 08:34:44 +0200 [thread overview]
Message-ID: <20250506063446.3133582-6-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250506063446.3133582-1-a.fatoum@pengutronix.de>
dev_get_drvdata() and device_get_match_data() can already deal with both
OF and non-OF match data, so at91_pinctrl_get_driver_data only adds some
unneeded complexity. Remove it and while at it switch to the less
error-prone device_get_match_data.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/pinctrl/pinctrl-at91.c | 27 +++------------------------
1 file changed, 3 insertions(+), 24 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 25b4d084ed6d..eb0ce648095d 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -26,13 +26,13 @@
struct at91_pinctrl {
struct pinctrl_device pctl;
- struct at91_pinctrl_mux_ops *ops;
+ const struct at91_pinctrl_mux_ops *ops;
};
struct at91_gpio_chip {
struct gpio_chip chip;
void __iomem *regbase; /* PIO bank virtual address */
- struct at91_pinctrl_mux_ops *ops; /* ops */
+ const struct at91_pinctrl_mux_ops *ops; /* ops */
};
#define MAX_GPIO_BANKS 5
@@ -384,27 +384,6 @@ static struct of_device_id at91_pinctrl_dt_ids[] = {
};
MODULE_DEVICE_TABLE(of, at91_pinctrl_dt_ids);
-static struct at91_pinctrl_mux_ops *at91_pinctrl_get_driver_data(struct device *dev)
-{
- struct at91_pinctrl_mux_ops *ops_data = NULL;
- int rc;
-
- if (dev->of_node) {
- const struct of_device_id *match;
- match = of_match_node(at91_pinctrl_dt_ids, dev->of_node);
- if (!match)
- ops_data = NULL;
- else
- ops_data = (struct at91_pinctrl_mux_ops *)match->data;
- } else {
- rc = dev_get_drvdata(dev, (const void **)&ops_data);
- if (rc)
- ops_data = NULL;
- }
-
- return ops_data;
-}
-
static int at91_pinctrl_set_conf(struct at91_pinctrl *info, unsigned int pin_num, unsigned int mux, unsigned int conf)
{
unsigned int mask;
@@ -492,7 +471,7 @@ static int at91_pinctrl_probe(struct device *dev)
info = xzalloc(sizeof(struct at91_pinctrl));
- info->ops = at91_pinctrl_get_driver_data(dev);
+ info->ops = device_get_match_data(dev);
if (!info->ops) {
dev_err(dev, "failed to retrieve driver data\n");
return -ENODEV;
--
2.39.5
next prev parent reply other threads:[~2025-05-06 6:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 6:34 [PATCH 1/8] treewide: " Ahmad Fatoum
2025-05-06 6:34 ` [PATCH 2/8] ARM: i.MX: esdctl: " Ahmad Fatoum
2025-05-06 6:34 ` [PATCH 3/8] driver: switch dev_get_drvdata to Linux semantics Ahmad Fatoum
2025-05-06 6:34 ` [PATCH 4/8] gpio: gpio-mxs: replace dev_get_drvdata with device_get_match_data Ahmad Fatoum
2025-05-06 7:42 ` Sascha Hauer
2025-05-06 6:34 ` [PATCH 5/8] mci: am654-sdhci: fix error code printed in error messages Ahmad Fatoum
2025-05-06 6:34 ` Ahmad Fatoum [this message]
2025-05-06 6:34 ` [PATCH 7/8] drivers: maintain const when converting from struct driver Ahmad Fatoum
2025-05-06 6:34 ` [PATCH 8/8] driver: base: invert driver match callback for Linux compatibility Ahmad Fatoum
2025-05-06 7:41 ` [PATCH 1/8] treewide: replace dev_get_drvdata with device_get_match_data 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=20250506063446.3133582-6-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