[PATCH 6/8] pinctrl: at91: replace dev_get_drvdata with device_get_match_data

Ahmad Fatoum a.fatoum at pengutronix.de
Mon May 5 23:34:44 PDT 2025


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 at 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




More information about the barebox mailing list