All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] phy: rockchip: use of_device_get_match_data()
@ 2017-08-09  9:17 ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Heiko Stuebner, Kukjin Kim, Krzysztof Kozlowski, Kamil Debski,
	Sylwester Nawrocki, Thierry Reding, Jonathan Hunter,
	Matthias Brugger, Bartlomiej Zolnierkiewicz, Lee Jones,
	Vivek Gautam, Chunfeng Yun, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c |    9 +++------
 drivers/phy/rockchip/phy-rockchip-pcie.c      |    7 +++----
 drivers/phy/rockchip/phy-rockchip-usb.c       |   10 +++-------
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 626883d..c2379b2 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -27,6 +27,7 @@
 #include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
@@ -1024,7 +1025,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	struct phy_provider *provider;
 	struct rockchip_usb2phy *rphy;
 	const struct rockchip_usb2phy_cfg *phy_cfgs;
-	const struct of_device_id *match;
 	unsigned int reg;
 	int index, ret;
 
@@ -1032,11 +1032,9 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	if (!rphy)
 		return -ENOMEM;
 
-	match = of_match_device(dev->driver->of_match_table, dev);
-	if (!match || !match->data) {
-		dev_err(dev, "phy configs are not assigned!\n");
+	phy_cfgs = of_device_get_match_data(dev);
+	if (!phy_cfgs)
 		return -EINVAL;
-	}
 
 	if (!dev->parent || !dev->parent->of_node)
 		return -EINVAL;
@@ -1052,7 +1050,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	}
 
 	rphy->dev = dev;
-	phy_cfgs = match->data;
 	rphy->chg_state = USB_CHG_STATE_UNDEFINED;
 	rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN;
 	platform_set_drvdata(pdev, rphy);
diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c
index 6904633..f7dc0d6 100644
--- a/drivers/phy/rockchip/phy-rockchip-pcie.c
+++ b/drivers/phy/rockchip/phy-rockchip-pcie.c
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -286,7 +287,6 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
 	struct phy *generic_phy;
 	struct phy_provider *phy_provider;
 	struct regmap *grf;
-	const struct of_device_id *of_id;
 
 	grf = syscon_node_to_regmap(dev->parent->of_node);
 	if (IS_ERR(grf)) {
@@ -298,11 +298,10 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
 	if (!rk_phy)
 		return -ENOMEM;
 
-	of_id = of_match_device(rockchip_pcie_phy_dt_ids, &pdev->dev);
-	if (!of_id)
+	rk_phy->phy_data = of_device_get_match_data(dev);
+	if (!rk_phy->phy_data)
 		return -EINVAL;
 
-	rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data;
 	rk_phy->reg_base = grf;
 
 	rk_phy->phy_rst = devm_reset_control_get(dev, "phy");
diff --git a/drivers/phy/rockchip/phy-rockchip-usb.c b/drivers/phy/rockchip/phy-rockchip-usb.c
index 3378eeb..7db1166 100644
--- a/drivers/phy/rockchip/phy-rockchip-usb.c
+++ b/drivers/phy/rockchip/phy-rockchip-usb.c
@@ -22,6 +22,7 @@
 #include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -417,7 +418,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct rockchip_usb_phy_base *phy_base;
 	struct phy_provider *phy_provider;
-	const struct of_device_id *match;
 	struct device_node *child;
 	int err;
 
@@ -425,13 +425,9 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	if (!phy_base)
 		return -ENOMEM;
 
-	match = of_match_device(dev->driver->of_match_table, dev);
-	if (!match || !match->data) {
-		dev_err(dev, "missing phy data\n");
+	phy_base->pdata = of_device_get_match_data(dev);
+	if (!phy_base->pdata)
 		return -EINVAL;
-	}
-
-	phy_base->pdata = match->data;
 
 	phy_base->dev = dev;
 	phy_base->reg_base = ERR_PTR(-ENODEV);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 1/4] phy: rockchip: use of_device_get_match_data()
@ 2017-08-09  9:17 ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Heiko Stuebner, Kukjin Kim, Krzysztof Kozlowski, Kamil Debski,
	Sylwester Nawrocki, Thierry Reding, Jonathan Hunter,
	Matthias Brugger, Bartlomiej Zolnierkiewicz, Lee Jones,
	Vivek Gautam, Chunfeng Yun, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung, linux-kernel,
	linux-arm-kernel, linux-rockchip, linux-samsung-soc, linux-tegra,
	linux-mediatek

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c |    9 +++------
 drivers/phy/rockchip/phy-rockchip-pcie.c      |    7 +++----
 drivers/phy/rockchip/phy-rockchip-usb.c       |   10 +++-------
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 626883d..c2379b2 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -27,6 +27,7 @@
 #include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
@@ -1024,7 +1025,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	struct phy_provider *provider;
 	struct rockchip_usb2phy *rphy;
 	const struct rockchip_usb2phy_cfg *phy_cfgs;
-	const struct of_device_id *match;
 	unsigned int reg;
 	int index, ret;
 
@@ -1032,11 +1032,9 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	if (!rphy)
 		return -ENOMEM;
 
-	match = of_match_device(dev->driver->of_match_table, dev);
-	if (!match || !match->data) {
-		dev_err(dev, "phy configs are not assigned!\n");
+	phy_cfgs = of_device_get_match_data(dev);
+	if (!phy_cfgs)
 		return -EINVAL;
-	}
 
 	if (!dev->parent || !dev->parent->of_node)
 		return -EINVAL;
@@ -1052,7 +1050,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	}
 
 	rphy->dev = dev;
-	phy_cfgs = match->data;
 	rphy->chg_state = USB_CHG_STATE_UNDEFINED;
 	rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN;
 	platform_set_drvdata(pdev, rphy);
diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c
index 6904633..f7dc0d6 100644
--- a/drivers/phy/rockchip/phy-rockchip-pcie.c
+++ b/drivers/phy/rockchip/phy-rockchip-pcie.c
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -286,7 +287,6 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
 	struct phy *generic_phy;
 	struct phy_provider *phy_provider;
 	struct regmap *grf;
-	const struct of_device_id *of_id;
 
 	grf = syscon_node_to_regmap(dev->parent->of_node);
 	if (IS_ERR(grf)) {
@@ -298,11 +298,10 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
 	if (!rk_phy)
 		return -ENOMEM;
 
-	of_id = of_match_device(rockchip_pcie_phy_dt_ids, &pdev->dev);
-	if (!of_id)
+	rk_phy->phy_data = of_device_get_match_data(dev);
+	if (!rk_phy->phy_data)
 		return -EINVAL;
 
-	rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data;
 	rk_phy->reg_base = grf;
 
 	rk_phy->phy_rst = devm_reset_control_get(dev, "phy");
diff --git a/drivers/phy/rockchip/phy-rockchip-usb.c b/drivers/phy/rockchip/phy-rockchip-usb.c
index 3378eeb..7db1166 100644
--- a/drivers/phy/rockchip/phy-rockchip-usb.c
+++ b/drivers/phy/rockchip/phy-rockchip-usb.c
@@ -22,6 +22,7 @@
 #include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -417,7 +418,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct rockchip_usb_phy_base *phy_base;
 	struct phy_provider *phy_provider;
-	const struct of_device_id *match;
 	struct device_node *child;
 	int err;
 
@@ -425,13 +425,9 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	if (!phy_base)
 		return -ENOMEM;
 
-	match = of_match_device(dev->driver->of_match_table, dev);
-	if (!match || !match->data) {
-		dev_err(dev, "missing phy data\n");
+	phy_base->pdata = of_device_get_match_data(dev);
+	if (!phy_base->pdata)
 		return -EINVAL;
-	}
-
-	phy_base->pdata = match->data;
 
 	phy_base->dev = dev;
 	phy_base->reg_base = ERR_PTR(-ENODEV);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 1/4] phy: rockchip: use of_device_get_match_data()
@ 2017-08-09  9:17 ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: linux-arm-kernel

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c |    9 +++------
 drivers/phy/rockchip/phy-rockchip-pcie.c      |    7 +++----
 drivers/phy/rockchip/phy-rockchip-usb.c       |   10 +++-------
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 626883d..c2379b2 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -27,6 +27,7 @@
 #include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
@@ -1024,7 +1025,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	struct phy_provider *provider;
 	struct rockchip_usb2phy *rphy;
 	const struct rockchip_usb2phy_cfg *phy_cfgs;
-	const struct of_device_id *match;
 	unsigned int reg;
 	int index, ret;
 
@@ -1032,11 +1032,9 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	if (!rphy)
 		return -ENOMEM;
 
-	match = of_match_device(dev->driver->of_match_table, dev);
-	if (!match || !match->data) {
-		dev_err(dev, "phy configs are not assigned!\n");
+	phy_cfgs = of_device_get_match_data(dev);
+	if (!phy_cfgs)
 		return -EINVAL;
-	}
 
 	if (!dev->parent || !dev->parent->of_node)
 		return -EINVAL;
@@ -1052,7 +1050,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev)
 	}
 
 	rphy->dev = dev;
-	phy_cfgs = match->data;
 	rphy->chg_state = USB_CHG_STATE_UNDEFINED;
 	rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN;
 	platform_set_drvdata(pdev, rphy);
diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c
index 6904633..f7dc0d6 100644
--- a/drivers/phy/rockchip/phy-rockchip-pcie.c
+++ b/drivers/phy/rockchip/phy-rockchip-pcie.c
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -286,7 +287,6 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
 	struct phy *generic_phy;
 	struct phy_provider *phy_provider;
 	struct regmap *grf;
-	const struct of_device_id *of_id;
 
 	grf = syscon_node_to_regmap(dev->parent->of_node);
 	if (IS_ERR(grf)) {
@@ -298,11 +298,10 @@ static int rockchip_pcie_phy_probe(struct platform_device *pdev)
 	if (!rk_phy)
 		return -ENOMEM;
 
-	of_id = of_match_device(rockchip_pcie_phy_dt_ids, &pdev->dev);
-	if (!of_id)
+	rk_phy->phy_data = of_device_get_match_data(dev);
+	if (!rk_phy->phy_data)
 		return -EINVAL;
 
-	rk_phy->phy_data = (struct rockchip_pcie_data *)of_id->data;
 	rk_phy->reg_base = grf;
 
 	rk_phy->phy_rst = devm_reset_control_get(dev, "phy");
diff --git a/drivers/phy/rockchip/phy-rockchip-usb.c b/drivers/phy/rockchip/phy-rockchip-usb.c
index 3378eeb..7db1166 100644
--- a/drivers/phy/rockchip/phy-rockchip-usb.c
+++ b/drivers/phy/rockchip/phy-rockchip-usb.c
@@ -22,6 +22,7 @@
 #include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
@@ -417,7 +418,6 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct rockchip_usb_phy_base *phy_base;
 	struct phy_provider *phy_provider;
-	const struct of_device_id *match;
 	struct device_node *child;
 	int err;
 
@@ -425,13 +425,9 @@ static int rockchip_usb_phy_probe(struct platform_device *pdev)
 	if (!phy_base)
 		return -ENOMEM;
 
-	match = of_match_device(dev->driver->of_match_table, dev);
-	if (!match || !match->data) {
-		dev_err(dev, "missing phy data\n");
+	phy_base->pdata = of_device_get_match_data(dev);
+	if (!phy_base->pdata)
 		return -EINVAL;
-	}
-
-	phy_base->pdata = match->data;
 
 	phy_base->dev = dev;
 	phy_base->reg_base = ERR_PTR(-ENODEV);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/4] phy: samsung: use of_device_get_match_data()
  2017-08-09  9:17 ` Chunfeng Yun
  (?)
@ 2017-08-09  9:17   ` Chunfeng Yun
  -1 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Heiko Stuebner, Kukjin Kim, Krzysztof Kozlowski, Kamil Debski,
	Sylwester Nawrocki, Thierry Reding, Jonathan Hunter,
	Matthias Brugger, Bartlomiej Zolnierkiewicz, Lee Jones,
	Vivek Gautam, Chunfeng Yun, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung, linux-kernel,
	linux-arm-kernel

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/samsung/phy-exynos-dp-video.c |    5 ++---
 drivers/phy/samsung/phy-exynos5-usbdrd.c  |    7 ++++---
 drivers/phy/samsung/phy-samsung-usb2.c    |    9 +++------
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/samsung/phy-exynos-dp-video.c b/drivers/phy/samsung/phy-exynos-dp-video.c
index bb3279d..2dd6dd1 100644
--- a/drivers/phy/samsung/phy-exynos-dp-video.c
+++ b/drivers/phy/samsung/phy-exynos-dp-video.c
@@ -16,6 +16,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
@@ -78,7 +79,6 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 {
 	struct exynos_dp_video_phy *state;
 	struct device *dev = &pdev->dev;
-	const struct of_device_id *match;
 	struct phy_provider *phy_provider;
 	struct phy *phy;
 
@@ -93,8 +93,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 		return PTR_ERR(state->regs);
 	}
 
-	match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
-	state->drvdata = match->data;
+	state->drvdata = of_device_get_match_data(dev);
 
 	phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops);
 	if (IS_ERR(phy)) {
diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
index 7c41daa..22c68f5 100644
--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
+++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
@@ -662,7 +663,6 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 	struct exynos5_usbdrd_phy *phy_drd;
 	struct phy_provider *phy_provider;
 	struct resource *res;
-	const struct of_device_id *match;
 	const struct exynos5_usbdrd_phy_drvdata *drv_data;
 	struct regmap *reg_pmu;
 	u32 pmu_offset;
@@ -681,9 +681,10 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 	if (IS_ERR(phy_drd->reg_phy))
 		return PTR_ERR(phy_drd->reg_phy);
 
-	match = of_match_node(exynos5_usbdrd_phy_of_match, pdev->dev.of_node);
+	drv_data = of_device_get_match_data(dev);
+	if (!drv_data)
+		return -EINVAL;
 
-	drv_data = match->data;
 	phy_drd->drv_data = drv_data;
 
 	ret = exynos5_usbdrd_phy_clk_handle(phy_drd);
diff --git a/drivers/phy/samsung/phy-samsung-usb2.c b/drivers/phy/samsung/phy-samsung-usb2.c
index 1d22d93..ea81886 100644
--- a/drivers/phy/samsung/phy-samsung-usb2.c
+++ b/drivers/phy/samsung/phy-samsung-usb2.c
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
@@ -142,7 +143,6 @@ static struct phy *samsung_usb2_phy_xlate(struct device *dev,
 
 static int samsung_usb2_phy_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	const struct samsung_usb2_phy_config *cfg;
 	struct device *dev = &pdev->dev;
 	struct phy_provider *phy_provider;
@@ -155,12 +155,9 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	match = of_match_node(samsung_usb2_phy_of_match, pdev->dev.of_node);
-	if (!match) {
-		dev_err(dev, "of_match_node() failed\n");
+	cfg = of_device_get_match_data(dev);
+	if (!cfg)
 		return -EINVAL;
-	}
-	cfg = match->data;
 
 	drv = devm_kzalloc(dev, sizeof(struct samsung_usb2_phy_driver) +
 		cfg->num_phys * sizeof(struct samsung_usb2_phy_instance),
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/4] phy: samsung: use of_device_get_match_data()
@ 2017-08-09  9:17   ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Heiko Stuebner, Kukjin Kim, Krzysztof Kozlowski, Kamil Debski,
	Sylwester Nawrocki, Thierry Reding, Jonathan Hunter,
	Matthias Brugger, Bartlomiej Zolnierkiewicz, Lee Jones,
	Vivek Gautam, Chunfeng Yun, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung, linux-kernel,
	linux-arm-kernel, linux-rockchip, linux-samsung-soc, linux-tegra,
	linux-mediatek

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/samsung/phy-exynos-dp-video.c |    5 ++---
 drivers/phy/samsung/phy-exynos5-usbdrd.c  |    7 ++++---
 drivers/phy/samsung/phy-samsung-usb2.c    |    9 +++------
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/samsung/phy-exynos-dp-video.c b/drivers/phy/samsung/phy-exynos-dp-video.c
index bb3279d..2dd6dd1 100644
--- a/drivers/phy/samsung/phy-exynos-dp-video.c
+++ b/drivers/phy/samsung/phy-exynos-dp-video.c
@@ -16,6 +16,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
@@ -78,7 +79,6 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 {
 	struct exynos_dp_video_phy *state;
 	struct device *dev = &pdev->dev;
-	const struct of_device_id *match;
 	struct phy_provider *phy_provider;
 	struct phy *phy;
 
@@ -93,8 +93,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 		return PTR_ERR(state->regs);
 	}
 
-	match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
-	state->drvdata = match->data;
+	state->drvdata = of_device_get_match_data(dev);
 
 	phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops);
 	if (IS_ERR(phy)) {
diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
index 7c41daa..22c68f5 100644
--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
+++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
@@ -662,7 +663,6 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 	struct exynos5_usbdrd_phy *phy_drd;
 	struct phy_provider *phy_provider;
 	struct resource *res;
-	const struct of_device_id *match;
 	const struct exynos5_usbdrd_phy_drvdata *drv_data;
 	struct regmap *reg_pmu;
 	u32 pmu_offset;
@@ -681,9 +681,10 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 	if (IS_ERR(phy_drd->reg_phy))
 		return PTR_ERR(phy_drd->reg_phy);
 
-	match = of_match_node(exynos5_usbdrd_phy_of_match, pdev->dev.of_node);
+	drv_data = of_device_get_match_data(dev);
+	if (!drv_data)
+		return -EINVAL;
 
-	drv_data = match->data;
 	phy_drd->drv_data = drv_data;
 
 	ret = exynos5_usbdrd_phy_clk_handle(phy_drd);
diff --git a/drivers/phy/samsung/phy-samsung-usb2.c b/drivers/phy/samsung/phy-samsung-usb2.c
index 1d22d93..ea81886 100644
--- a/drivers/phy/samsung/phy-samsung-usb2.c
+++ b/drivers/phy/samsung/phy-samsung-usb2.c
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
@@ -142,7 +143,6 @@ static struct phy *samsung_usb2_phy_xlate(struct device *dev,
 
 static int samsung_usb2_phy_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	const struct samsung_usb2_phy_config *cfg;
 	struct device *dev = &pdev->dev;
 	struct phy_provider *phy_provider;
@@ -155,12 +155,9 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	match = of_match_node(samsung_usb2_phy_of_match, pdev->dev.of_node);
-	if (!match) {
-		dev_err(dev, "of_match_node() failed\n");
+	cfg = of_device_get_match_data(dev);
+	if (!cfg)
 		return -EINVAL;
-	}
-	cfg = match->data;
 
 	drv = devm_kzalloc(dev, sizeof(struct samsung_usb2_phy_driver) +
 		cfg->num_phys * sizeof(struct samsung_usb2_phy_instance),
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/4] phy: samsung: use of_device_get_match_data()
@ 2017-08-09  9:17   ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: linux-arm-kernel

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/samsung/phy-exynos-dp-video.c |    5 ++---
 drivers/phy/samsung/phy-exynos5-usbdrd.c  |    7 ++++---
 drivers/phy/samsung/phy-samsung-usb2.c    |    9 +++------
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/phy/samsung/phy-exynos-dp-video.c b/drivers/phy/samsung/phy-exynos-dp-video.c
index bb3279d..2dd6dd1 100644
--- a/drivers/phy/samsung/phy-exynos-dp-video.c
+++ b/drivers/phy/samsung/phy-exynos-dp-video.c
@@ -16,6 +16,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
@@ -78,7 +79,6 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 {
 	struct exynos_dp_video_phy *state;
 	struct device *dev = &pdev->dev;
-	const struct of_device_id *match;
 	struct phy_provider *phy_provider;
 	struct phy *phy;
 
@@ -93,8 +93,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 		return PTR_ERR(state->regs);
 	}
 
-	match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
-	state->drvdata = match->data;
+	state->drvdata = of_device_get_match_data(dev);
 
 	phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops);
 	if (IS_ERR(phy)) {
diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
index 7c41daa..22c68f5 100644
--- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
+++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
@@ -662,7 +663,6 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 	struct exynos5_usbdrd_phy *phy_drd;
 	struct phy_provider *phy_provider;
 	struct resource *res;
-	const struct of_device_id *match;
 	const struct exynos5_usbdrd_phy_drvdata *drv_data;
 	struct regmap *reg_pmu;
 	u32 pmu_offset;
@@ -681,9 +681,10 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)
 	if (IS_ERR(phy_drd->reg_phy))
 		return PTR_ERR(phy_drd->reg_phy);
 
-	match = of_match_node(exynos5_usbdrd_phy_of_match, pdev->dev.of_node);
+	drv_data = of_device_get_match_data(dev);
+	if (!drv_data)
+		return -EINVAL;
 
-	drv_data = match->data;
 	phy_drd->drv_data = drv_data;
 
 	ret = exynos5_usbdrd_phy_clk_handle(phy_drd);
diff --git a/drivers/phy/samsung/phy-samsung-usb2.c b/drivers/phy/samsung/phy-samsung-usb2.c
index 1d22d93..ea81886 100644
--- a/drivers/phy/samsung/phy-samsung-usb2.c
+++ b/drivers/phy/samsung/phy-samsung-usb2.c
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
@@ -142,7 +143,6 @@ static struct phy *samsung_usb2_phy_xlate(struct device *dev,
 
 static int samsung_usb2_phy_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	const struct samsung_usb2_phy_config *cfg;
 	struct device *dev = &pdev->dev;
 	struct phy_provider *phy_provider;
@@ -155,12 +155,9 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	match = of_match_node(samsung_usb2_phy_of_match, pdev->dev.of_node);
-	if (!match) {
-		dev_err(dev, "of_match_node() failed\n");
+	cfg = of_device_get_match_data(dev);
+	if (!cfg)
 		return -EINVAL;
-	}
-	cfg = match->data;
 
 	drv = devm_kzalloc(dev, sizeof(struct samsung_usb2_phy_driver) +
 		cfg->num_phys * sizeof(struct samsung_usb2_phy_instance),
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/4] phy: ti: use of_device_get_match_data()
  2017-08-09  9:17 ` Chunfeng Yun
  (?)
@ 2017-08-09  9:17   ` Chunfeng Yun
  -1 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Heiko Stuebner, Kukjin Kim, Krzysztof Kozlowski, Kamil Debski,
	Sylwester Nawrocki, Thierry Reding, Jonathan Hunter,
	Matthias Brugger, Bartlomiej Zolnierkiewicz, Lee Jones,
	Vivek Gautam, Chunfeng Yun, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung, linux-kernel,
	linux-arm-kernel

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/ti/phy-omap-usb2.c |   11 ++++-------
 drivers/phy/ti/phy-ti-pipe3.c  |    8 ++------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/phy/ti/phy-omap-usb2.c b/drivers/phy/ti/phy-omap-usb2.c
index fe909fd..70375b1 100644
--- a/drivers/phy/ti/phy-omap-usb2.c
+++ b/drivers/phy/ti/phy-omap-usb2.c
@@ -31,6 +31,7 @@
 #include <linux/phy/phy.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
@@ -280,16 +281,12 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *control_node;
 	struct platform_device *control_pdev;
-	const struct of_device_id *of_id;
-	struct usb_phy_data *phy_data;
+	const struct usb_phy_data *phy_data;
 
-	of_id = of_match_device(omap_usb2_id_table, &pdev->dev);
-
-	if (!of_id)
+	phy_data = of_device_get_match_data(&pdev->dev);
+	if (!phy_data)
 		return -EINVAL;
 
-	phy_data = (struct usb_phy_data *)of_id->data;
-
 	phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy)
 		return -ENOMEM;
diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index 9c84d32..063ab2e 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -27,6 +27,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/delay.h>
 #include <linux/phy/omap_control_phy.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
@@ -516,7 +517,6 @@ static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy)
 static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy)
 {
 	struct resource *res;
-	const struct of_device_id *match;
 	struct device *dev = phy->dev;
 	struct device_node *node = dev->of_node;
 	struct platform_device *pdev = to_platform_device(dev);
@@ -524,11 +524,7 @@ static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy)
 	if (of_device_is_compatible(node, "ti,phy-pipe3-pcie"))
 		return 0;
 
-	match = of_match_device(ti_pipe3_id_table, dev);
-	if (!match)
-		return -EINVAL;
-
-	phy->dpll_map = (struct pipe3_dpll_map *)match->data;
+	phy->dpll_map = of_device_get_match_data(dev);
 	if (!phy->dpll_map) {
 		dev_err(dev, "no DPLL data\n");
 		return -EINVAL;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/4] phy: ti: use of_device_get_match_data()
@ 2017-08-09  9:17   ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Heiko Stuebner, Kukjin Kim, Krzysztof Kozlowski, Kamil Debski,
	Sylwester Nawrocki, Thierry Reding, Jonathan Hunter,
	Matthias Brugger, Bartlomiej Zolnierkiewicz, Lee Jones,
	Vivek Gautam, Chunfeng Yun, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung, linux-kernel,
	linux-arm-kernel, linux-rockchip, linux-samsung-soc, linux-tegra,
	linux-mediatek

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/ti/phy-omap-usb2.c |   11 ++++-------
 drivers/phy/ti/phy-ti-pipe3.c  |    8 ++------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/phy/ti/phy-omap-usb2.c b/drivers/phy/ti/phy-omap-usb2.c
index fe909fd..70375b1 100644
--- a/drivers/phy/ti/phy-omap-usb2.c
+++ b/drivers/phy/ti/phy-omap-usb2.c
@@ -31,6 +31,7 @@
 #include <linux/phy/phy.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
@@ -280,16 +281,12 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *control_node;
 	struct platform_device *control_pdev;
-	const struct of_device_id *of_id;
-	struct usb_phy_data *phy_data;
+	const struct usb_phy_data *phy_data;
 
-	of_id = of_match_device(omap_usb2_id_table, &pdev->dev);
-
-	if (!of_id)
+	phy_data = of_device_get_match_data(&pdev->dev);
+	if (!phy_data)
 		return -EINVAL;
 
-	phy_data = (struct usb_phy_data *)of_id->data;
-
 	phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy)
 		return -ENOMEM;
diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index 9c84d32..063ab2e 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -27,6 +27,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/delay.h>
 #include <linux/phy/omap_control_phy.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
@@ -516,7 +517,6 @@ static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy)
 static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy)
 {
 	struct resource *res;
-	const struct of_device_id *match;
 	struct device *dev = phy->dev;
 	struct device_node *node = dev->of_node;
 	struct platform_device *pdev = to_platform_device(dev);
@@ -524,11 +524,7 @@ static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy)
 	if (of_device_is_compatible(node, "ti,phy-pipe3-pcie"))
 		return 0;
 
-	match = of_match_device(ti_pipe3_id_table, dev);
-	if (!match)
-		return -EINVAL;
-
-	phy->dpll_map = (struct pipe3_dpll_map *)match->data;
+	phy->dpll_map = of_device_get_match_data(dev);
 	if (!phy->dpll_map) {
 		dev_err(dev, "no DPLL data\n");
 		return -EINVAL;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/4] phy: ti: use of_device_get_match_data()
@ 2017-08-09  9:17   ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:17 UTC (permalink / raw)
  To: linux-arm-kernel

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/ti/phy-omap-usb2.c |   11 ++++-------
 drivers/phy/ti/phy-ti-pipe3.c  |    8 ++------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/phy/ti/phy-omap-usb2.c b/drivers/phy/ti/phy-omap-usb2.c
index fe909fd..70375b1 100644
--- a/drivers/phy/ti/phy-omap-usb2.c
+++ b/drivers/phy/ti/phy-omap-usb2.c
@@ -31,6 +31,7 @@
 #include <linux/phy/phy.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 
 #define USB2PHY_DISCON_BYP_LATCH (1 << 31)
@@ -280,16 +281,12 @@ static int omap_usb2_probe(struct platform_device *pdev)
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *control_node;
 	struct platform_device *control_pdev;
-	const struct of_device_id *of_id;
-	struct usb_phy_data *phy_data;
+	const struct usb_phy_data *phy_data;
 
-	of_id = of_match_device(omap_usb2_id_table, &pdev->dev);
-
-	if (!of_id)
+	phy_data = of_device_get_match_data(&pdev->dev);
+	if (!phy_data)
 		return -EINVAL;
 
-	phy_data = (struct usb_phy_data *)of_id->data;
-
 	phy = devm_kzalloc(&pdev->dev, sizeof(*phy), GFP_KERNEL);
 	if (!phy)
 		return -ENOMEM;
diff --git a/drivers/phy/ti/phy-ti-pipe3.c b/drivers/phy/ti/phy-ti-pipe3.c
index 9c84d32..063ab2e 100644
--- a/drivers/phy/ti/phy-ti-pipe3.c
+++ b/drivers/phy/ti/phy-ti-pipe3.c
@@ -27,6 +27,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/delay.h>
 #include <linux/phy/omap_control_phy.h>
+#include <linux/of_device.h>
 #include <linux/of_platform.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
@@ -516,7 +517,6 @@ static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy)
 static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy)
 {
 	struct resource *res;
-	const struct of_device_id *match;
 	struct device *dev = phy->dev;
 	struct device_node *node = dev->of_node;
 	struct platform_device *pdev = to_platform_device(dev);
@@ -524,11 +524,7 @@ static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy)
 	if (of_device_is_compatible(node, "ti,phy-pipe3-pcie"))
 		return 0;
 
-	match = of_match_device(ti_pipe3_id_table, dev);
-	if (!match)
-		return -EINVAL;
-
-	phy->dpll_map = (struct pipe3_dpll_map *)match->data;
+	phy->dpll_map = of_device_get_match_data(dev);
 	if (!phy->dpll_map) {
 		dev_err(dev, "no DPLL data\n");
 		return -EINVAL;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/4] phy: tegra: use of_device_get_match_data()
  2017-08-09  9:17 ` Chunfeng Yun
  (?)
@ 2017-08-09  9:18     ` Chunfeng Yun
  -1 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:18 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Heiko Stuebner, Kukjin Kim, Krzysztof Kozlowski, Kamil Debski,
	Sylwester Nawrocki, Thierry Reding, Jonathan Hunter,
	Matthias Brugger, Bartlomiej Zolnierkiewicz, Lee Jones,
	Vivek Gautam, Chunfeng Yun, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
---
 drivers/phy/tegra/xusb.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 3cbcb25..25cdfb1 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -848,7 +848,6 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 	struct device_node *np = of_node_get(pdev->dev.of_node);
 	const struct tegra_xusb_padctl_soc *soc;
 	struct tegra_xusb_padctl *padctl;
-	const struct of_device_id *match;
 	struct resource *res;
 	int err;
 
@@ -861,8 +860,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 
 	of_node_put(np);
 
-	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
-	soc = match->data;
+	soc = of_device_get_match_data(&pdev->dev);
+	if (!soc)
+		return -EINVAL;
 
 	padctl = soc->ops->probe(&pdev->dev, soc);
 	if (IS_ERR(padctl))
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/4] phy: tegra: use of_device_get_match_data()
@ 2017-08-09  9:18     ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:18 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Heiko Stuebner, Kukjin Kim, Krzysztof Kozlowski, Kamil Debski,
	Sylwester Nawrocki, Thierry Reding, Jonathan Hunter,
	Matthias Brugger, Bartlomiej Zolnierkiewicz, Lee Jones,
	Vivek Gautam, Chunfeng Yun, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung, linux-kernel,
	linux-arm-kernel, linux-rockchip, linux-samsung-soc, linux-tegra,
	linux-mediatek

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/tegra/xusb.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 3cbcb25..25cdfb1 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -848,7 +848,6 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 	struct device_node *np = of_node_get(pdev->dev.of_node);
 	const struct tegra_xusb_padctl_soc *soc;
 	struct tegra_xusb_padctl *padctl;
-	const struct of_device_id *match;
 	struct resource *res;
 	int err;
 
@@ -861,8 +860,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 
 	of_node_put(np);
 
-	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
-	soc = match->data;
+	soc = of_device_get_match_data(&pdev->dev);
+	if (!soc)
+		return -EINVAL;
 
 	padctl = soc->ops->probe(&pdev->dev, soc);
 	if (IS_ERR(padctl))
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/4] phy: tegra: use of_device_get_match_data()
@ 2017-08-09  9:18     ` Chunfeng Yun
  0 siblings, 0 replies; 15+ messages in thread
From: Chunfeng Yun @ 2017-08-09  9:18 UTC (permalink / raw)
  To: linux-arm-kernel

reduce the boilerplate code to get the specific data

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/tegra/xusb.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
index 3cbcb25..25cdfb1 100644
--- a/drivers/phy/tegra/xusb.c
+++ b/drivers/phy/tegra/xusb.c
@@ -848,7 +848,6 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 	struct device_node *np = of_node_get(pdev->dev.of_node);
 	const struct tegra_xusb_padctl_soc *soc;
 	struct tegra_xusb_padctl *padctl;
-	const struct of_device_id *match;
 	struct resource *res;
 	int err;
 
@@ -861,8 +860,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
 
 	of_node_put(np);
 
-	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
-	soc = match->data;
+	soc = of_device_get_match_data(&pdev->dev);
+	if (!soc)
+		return -EINVAL;
 
 	padctl = soc->ops->probe(&pdev->dev, soc);
 	if (IS_ERR(padctl))
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] phy: tegra: use of_device_get_match_data()
  2017-08-09  9:18     ` Chunfeng Yun
  (?)
@ 2017-08-18 12:42       ` Thierry Reding
  -1 siblings, 0 replies; 15+ messages in thread
From: Thierry Reding @ 2017-08-18 12:42 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Kishon Vijay Abraham I, Heiko Stuebner, Kukjin Kim,
	Krzysztof Kozlowski, Kamil Debski, Sylwester Nawrocki,
	Jonathan Hunter, Matthias Brugger, Bartlomiej Zolnierkiewicz,
	Lee Jones, Vivek Gautam, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung, linux-kernel,
	linux-arm-kernel, linux-rockchip

[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]

On Wed, Aug 09, 2017 at 05:18:00PM +0800, Chunfeng Yun wrote:
> reduce the boilerplate code to get the specific data
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/phy/tegra/xusb.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

You're not reducing by much here. =)

> diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
> index 3cbcb25..25cdfb1 100644
> --- a/drivers/phy/tegra/xusb.c
> +++ b/drivers/phy/tegra/xusb.c
> @@ -848,7 +848,6 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
>  	struct device_node *np = of_node_get(pdev->dev.of_node);
>  	const struct tegra_xusb_padctl_soc *soc;
>  	struct tegra_xusb_padctl *padctl;
> -	const struct of_device_id *match;
>  	struct resource *res;
>  	int err;
>  
> @@ -861,8 +860,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
>  
>  	of_node_put(np);
>  
> -	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
> -	soc = match->data;
> +	soc = of_device_get_match_data(&pdev->dev);
> +	if (!soc)
> +		return -EINVAL;

This is never going to happen. There will always be a match, otherwise
this function would never be called.

Also, if you omit these last two lines, then you actually do reduce the
boilerplate.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] phy: tegra: use of_device_get_match_data()
@ 2017-08-18 12:42       ` Thierry Reding
  0 siblings, 0 replies; 15+ messages in thread
From: Thierry Reding @ 2017-08-18 12:42 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Kishon Vijay Abraham I, Heiko Stuebner, Kukjin Kim,
	Krzysztof Kozlowski, Kamil Debski, Sylwester Nawrocki,
	Jonathan Hunter, Matthias Brugger, Bartlomiej Zolnierkiewicz,
	Lee Jones, Vivek Gautam, Axel Lin, Baoyou Xie, Arnd Bergmann,
	Sekhar Nori, Viresh Kumar, Jaehoon Chung, linux-kernel,
	linux-arm-kernel, linux-rockchip, linux-samsung-soc, linux-tegra,
	linux-mediatek

[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]

On Wed, Aug 09, 2017 at 05:18:00PM +0800, Chunfeng Yun wrote:
> reduce the boilerplate code to get the specific data
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/phy/tegra/xusb.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

You're not reducing by much here. =)

> diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
> index 3cbcb25..25cdfb1 100644
> --- a/drivers/phy/tegra/xusb.c
> +++ b/drivers/phy/tegra/xusb.c
> @@ -848,7 +848,6 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
>  	struct device_node *np = of_node_get(pdev->dev.of_node);
>  	const struct tegra_xusb_padctl_soc *soc;
>  	struct tegra_xusb_padctl *padctl;
> -	const struct of_device_id *match;
>  	struct resource *res;
>  	int err;
>  
> @@ -861,8 +860,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
>  
>  	of_node_put(np);
>  
> -	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
> -	soc = match->data;
> +	soc = of_device_get_match_data(&pdev->dev);
> +	if (!soc)
> +		return -EINVAL;

This is never going to happen. There will always be a match, otherwise
this function would never be called.

Also, if you omit these last two lines, then you actually do reduce the
boilerplate.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/4] phy: tegra: use of_device_get_match_data()
@ 2017-08-18 12:42       ` Thierry Reding
  0 siblings, 0 replies; 15+ messages in thread
From: Thierry Reding @ 2017-08-18 12:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Aug 09, 2017 at 05:18:00PM +0800, Chunfeng Yun wrote:
> reduce the boilerplate code to get the specific data
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/phy/tegra/xusb.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

You're not reducing by much here. =)

> diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
> index 3cbcb25..25cdfb1 100644
> --- a/drivers/phy/tegra/xusb.c
> +++ b/drivers/phy/tegra/xusb.c
> @@ -848,7 +848,6 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
>  	struct device_node *np = of_node_get(pdev->dev.of_node);
>  	const struct tegra_xusb_padctl_soc *soc;
>  	struct tegra_xusb_padctl *padctl;
> -	const struct of_device_id *match;
>  	struct resource *res;
>  	int err;
>  
> @@ -861,8 +860,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
>  
>  	of_node_put(np);
>  
> -	match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node);
> -	soc = match->data;
> +	soc = of_device_get_match_data(&pdev->dev);
> +	if (!soc)
> +		return -EINVAL;

This is never going to happen. There will always be a match, otherwise
this function would never be called.

Also, if you omit these last two lines, then you actually do reduce the
boilerplate.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170818/a7a7029c/attachment.sig>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-08-18 12:42 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-09  9:17 [PATCH 1/4] phy: rockchip: use of_device_get_match_data() Chunfeng Yun
2017-08-09  9:17 ` Chunfeng Yun
2017-08-09  9:17 ` Chunfeng Yun
2017-08-09  9:17 ` [PATCH 2/4] phy: samsung: " Chunfeng Yun
2017-08-09  9:17   ` Chunfeng Yun
2017-08-09  9:17   ` Chunfeng Yun
2017-08-09  9:17 ` [PATCH 3/4] phy: ti: " Chunfeng Yun
2017-08-09  9:17   ` Chunfeng Yun
2017-08-09  9:17   ` Chunfeng Yun
     [not found] ` <1502270280-13792-1-git-send-email-chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2017-08-09  9:18   ` [PATCH 4/4] phy: tegra: " Chunfeng Yun
2017-08-09  9:18     ` Chunfeng Yun
2017-08-09  9:18     ` Chunfeng Yun
2017-08-18 12:42     ` Thierry Reding
2017-08-18 12:42       ` Thierry Reding
2017-08-18 12:42       ` Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.