Skip to contentSkip to conversation

pinctrl: tegra: Use of_device_get_match_data()

PATCH In review Thierry Reding 2 participants 3 messages Sep 23, 2019 – Oct 4, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: tegra: Use of_device_get_match_data()

From: Thierry Reding <[email protected]>

Use the of_device_get_match_data() helper instead of open-coding.

---
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pinctrl/tegra/pinctrl-tegra-xusb.c +2 -3
index 95002e3ecaff..6b6d027c6fd0 100644
@@ -7,6 +7,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/pinctrl/pinmux.h>
@@ -872,7 +873,6 @@ int tegra_xusb_padctl_legacy_remove(struct platform_device *pdev);
 int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev)
 {
 	struct tegra_xusb_padctl *padctl;
-	const struct of_device_id *match;
 	struct resource *res;
 	struct phy *phy;
 	int err;
@@ -885,8 +885,7 @@ int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev)
 	mutex_init(&padctl->lock);
 	padctl->dev = &pdev->dev;
 
-	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
-	padctl->soc = match->data;
+	padctl->soc = of_device_get_match_data(&pdev->dev);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	padctl->regs = devm_ioremap_resource(&pdev->dev, res);
Signature · 1 line
2.23.0
#1 lore raw
Quoted 8 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Use the of_device_get_match_data() helper instead of open-coding.

---
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Actually, scratch that. We can't do this because the match table is different for the legacy case from what the new PHY driver uses which calls this only for the legacy case. Instead, I'd propose the attached patch.

Thierry

--- >8 ---
From 6c96f18a2608b21d178007c97337400b788c3f9e Mon Sep 17 00:00:00 2001
From: Thierry Reding <[email protected]>
Date: Mon, 23 Sep 2019 11:47:25 +0200
Subject: [PATCH] pinctrl: tegra: xusb: Add note about legacy status

Add a comment about why the call to of_match_node() cannot be replaced by of_device_get_match_data(). This will hopefully prevent people from attempting to clean this up in the future.

---
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pinctrl/tegra/pinctrl-tegra-xusb.c +6 -0
index 95002e3ecaff..f2fa1f76ebb7 100644
@@ -885,6 +885,12 @@ int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev)
 	mutex_init(&padctl->lock);
 	padctl->dev = &pdev->dev;
 
+	/*
+	 * Note that we can't replace this by of_device_get_match_data()
+	 * because we need the separate matching table for this legacy code on
+	 * Tegra124. of_device_get_match_data() would attempt to use the table
+	 * from the updated driver and fail.
+	 */
 	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
 	padctl->soc = match->data;
 
Signature · 1 line
2.23.0
#2 lore raw
Quoted 4 lines · Thierry Reding

Actually, scratch that. We can't do this because the match table is different for the legacy case from what the new PHY driver uses which calls this only for the legacy case. Instead, I'd propose the attached patch.

OK I applied that instead.

Yours,
Linus Walleij