Skip to contentSkip to conversation

component: Add common helpers for compare/release

PATCH Applied Yong Wu 7 participants 31 messages Feb 14, 2022 – Feb 25, 2022

Subsystems (37)
lore
Share & tools
lore

Yong Wu

author maintainer
#0 lore raw

cover component: Add common helpers for compare/release

The component requires the compare/release functions, there are many copies in current kernel. This patchset just defines four common helpers for them. No functional change.

Change note:
v1: a) Split the original patch into many small patches.
b) Use device_match_of_node helper.
c) Move the functions into c and export since the callback doesn't look like it should be "inline".
d) Add "component_" prefix for the functon names.
e) Add a new component_compare_dev_name.

RFC: https://lore.kernel.org/dri-devel/[email protected]/

    rebase on v5.17-rc1

Yong Wu (23):
component: Add common helper for compare/release functions drm/komeda: Make use of the helper component_compare_of drm/armada: Make use of the helper component_compare_of/dev_name drm/etnaviv: Make use of the helper component_compare_of/dev_name drm/hirin: Make use of the helper component_compare_of drm/ingenic: Make use of the helper component_compare_of drm/mediatek: Make use of the helper component_compare_of drm/meson: Make use of the helper component_compare_of drm/msm: Make use of the helper component_compare_of drm/sprd: Make use of the helper component_compare_of drm/sti: Make use of the helper component_compare_of drm/sun4i: Make use of the helper component_compare_of drm/rockchip: Make use of the helper component_compare_dev drm/exynos: Make use of the helper component_compare_dev drm/mcde: Make use of the helper component_compare_dev drm/omap: dss: Make use of the helper component_compare_dev drm/vc4: Make use of the helper component_compare_dev
drm: of: Make use of the helper component_release_of iommu/mediatek: Make use of the helper component_compare/release_of
ASoC: codecs: wcd938x: Make use of the helper
component_compare/release_of
power: supply: ab8500: Make use of the helper component_compare_dev
video: omapfb: dss: Make use of the helper component_compare_dev
ALSA: hda/realtek: Make use of the helper component_compare_dev_name

 drivers/base/component.c                      | 58 +++++++++++++++++++
 .../gpu/drm/arm/display/komeda/komeda_drv.c   |  7 +--
 drivers/gpu/drm/armada/armada_drv.c           | 17 +-----
 drivers/gpu/drm/drm_of.c                      |  7 +--
 drivers/gpu/drm/etnaviv/etnaviv_drv.c         | 16 +----
 drivers/gpu/drm/exynos/exynos_drm_drv.c       |  8 +--
 .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c   |  7 +--
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c     |  7 +--
 drivers/gpu/drm/mcde/mcde_drv.c               |  7 +--
 drivers/gpu/drm/mediatek/mtk_drm_drv.c        |  7 +--
 drivers/gpu/drm/meson/meson_drv.c             | 10 +---
 drivers/gpu/drm/msm/msm_drv.c                 | 15 +----
 drivers/gpu/drm/omapdrm/dss/dss.c             |  8 +--
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c   |  7 +--
 drivers/gpu/drm/sprd/sprd_drm.c               |  7 +--
 drivers/gpu/drm/sti/sti_drv.c                 |  7 +--
 drivers/gpu/drm/sun4i/sun4i_drv.c             | 11 +---
 drivers/gpu/drm/vc4/vc4_drv.c                 |  7 +--
 drivers/iommu/mtk_iommu.c                     |  4 +-
 drivers/iommu/mtk_iommu.h                     | 10 ----
 drivers/iommu/mtk_iommu_v1.c                  |  4 +-
 drivers/power/supply/ab8500_charger.c         |  8 +--
 drivers/video/fbdev/omap2/omapfb/dss/dss.c    |  8 +--
 include/linux/component.h                     |  6 ++
 sound/pci/hda/patch_realtek.c                 | 11 +---
 sound/soc/codecs/wcd938x.c                    | 18 ++----
 26 files changed, 99 insertions(+), 183 deletions(-)
Signature · 1 line
2.18.0
author maintainer
#1 lore raw

PATCH 1/23 component: Add common helper for compare/release functions

The component requires the compare/release functions, there are so many copies in current kernel. Just define four common helpers for them.

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>

---
I have run "make htmldocs". Due to my poor english, If the grammer is wrong or need more comments, please help to correct or supplement. Thanks.

---
 drivers/base/component.c  | 58 +++++++++++++++++++++++++++++++++++++++
 include/linux/component.h |  6 ++++
 2 files changed, 64 insertions(+)
drivers/base/component.c +58 -0
index 2d25a6416587..3d72d2820d7d 100644
@@ -11,6 +11,7 @@
 #include <linux/device.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
+#include <linux/of.h>
 #include <linux/slab.h>
 #include <linux/debugfs.h>
 
@@ -287,6 +288,63 @@ static void take_down_master(struct master *master)
 	}
 }
 
+/**
+ * component_compare_of - A common component compare function for of_node
+ * @dev: component device
+ * @data: @compare_data from component_match_add_release()
+ *
+ * A common compare function when compare_data is device of_node. e.g.
+ * component_match_add_release(masterdev, &match, component_release_of,
+ * component_compare_of, component_dev_of_node)
+ */
+int component_compare_of(struct device *dev, void *data)
+{
+	return device_match_of_node(dev, data);
+}
+EXPORT_SYMBOL_GPL(component_compare_of);
+
+/**
+ * component_release_of - A common component release function for of_node
+ * @dev: component device
+ * @data: @compare_data from component_match_add_release()
+ *
+ * About the example, Please see component_compare_of().
+ */
+void component_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+EXPORT_SYMBOL_GPL(component_release_of);
+
+/**
+ * component_compare_dev - A common component compare function for dev
+ * @dev: component device
+ * @data: @compare_data from component_match_add_release()
+ *
+ * A common compare function when compare_data is struce device. e.g.
+ * component_match_add(masterdev, &match, component_compare_dev, component_dev)
+ */
+int component_compare_dev(struct device *dev, void *data)
+{
+	return dev == data;
+}
+EXPORT_SYMBOL_GPL(component_compare_dev);
+
+/**
+ * component_compare_dev_name - A common component compare function for device name
+ * @dev: component device
+ * @data: @compare_data from component_match_add_release()
+ *
+ * A common compare function when compare_data is device name string. e.g.
+ * component_match_add(masterdev, &match, component_compare_dev_name,
+ * "component_dev_name")
+ */
+int component_compare_dev_name(struct device *dev, void *data)
+{
+	return device_match_name(dev, data);
+}
+EXPORT_SYMBOL_GPL(component_compare_dev_name);
+
 static void devm_component_match_release(struct device *parent, void *res)
 {
 	struct component_match *match = res;
include/linux/component.h +6 -0
index 16de18f473d7..6bc1c6e7f76d 100644
@@ -82,6 +82,12 @@ struct component_master_ops {
 	void (*unbind)(struct device *master);
 };
 
+/* A set helper functions for component compare/release */
+int component_compare_of(struct device *dev, void *data);
+void component_release_of(struct device *dev, void *data);
+int component_compare_dev(struct device *dev, void *data);
+int component_compare_dev_name(struct device *dev, void *data);
+
 void component_master_del(struct device *,
 	const struct component_master_ops *);
 
Signature · 1 line
2.18.0
author maintainer
#2 lore raw

PATCH 2/23 drm/komeda: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

Cc "James (Qian) Wang" <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Mihail Atanassov <[email protected]>
Cc Brian Starkey <[email protected]>
---
 drivers/gpu/drm/arm/display/komeda/komeda_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/arm/display/komeda/komeda_drv.c +1 -6
index e7933930a657..c325872699ec 100644
@@ -92,11 +92,6 @@ static const struct component_master_ops komeda_master_ops = {
 	.unbind	= komeda_unbind,
 };
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static void komeda_add_slave(struct device *master,
 			     struct component_match **match,
 			     struct device_node *np,
@@ -106,7 +101,7 @@ static void komeda_add_slave(struct device *master,
 
 	remote = of_graph_get_remote_node(np, port, endpoint);
 	if (remote) {
-		drm_of_component_match_add(master, match, compare_of, remote);
+		drm_of_component_match_add(master, match, component_compare_of, remote);
 		of_node_put(remote);
 	}
 }
Signature · 1 line
2.18.0
author maintainer
#3 lore raw

PATCH 3/23 drm/armada: Make use of the helper component_compare_of/dev_name

In reply to Yong Wu

Use the common compare helpers from component.

Cc Russell King <[email protected]>
---
 drivers/gpu/drm/armada/armada_drv.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/gpu/drm/armada/armada_drv.c +3 -14
index 8e3e98f13db4..224607a6ae16 100644
@@ -177,17 +177,6 @@ static void armada_drm_unbind(struct device *dev)
 	drm_mm_takedown(&priv->linear);
 }
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
-static int compare_dev_name(struct device *dev, void *data)
-{
-	const char *name = data;
-	return !strcmp(dev_name(dev), name);
-}
-
 static void armada_add_endpoints(struct device *dev,
 	struct component_match **match, struct device_node *dev_node)
 {
@@ -196,7 +185,7 @@ static void armada_add_endpoints(struct device *dev,
 	for_each_endpoint_of_node(dev_node, ep) {
 		remote = of_graph_get_remote_port_parent(ep);
 		if (remote && of_device_is_available(remote))
-			drm_of_component_match_add(dev, match, compare_of,
+			drm_of_component_match_add(dev, match, component_compare_of,
 						   remote);
 		of_node_put(remote);
 	}
@@ -213,7 +202,7 @@ static int armada_drm_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	int ret;
 
-	ret = drm_of_component_probe(dev, compare_dev_name, &armada_master_ops);
+	ret = drm_of_component_probe(dev, component_compare_dev_name, &armada_master_ops);
 	if (ret != -EINVAL)
 		return ret;
 
@@ -223,7 +212,7 @@ static int armada_drm_probe(struct platform_device *pdev)
 		int i;
 
 		for (i = 0; devices[i]; i++)
-			component_match_add(dev, &match, compare_dev_name,
+			component_match_add(dev, &match, component_compare_dev_name,
 					    devices[i]);
 
 		if (i == 0) {
Signature · 1 line
2.18.0
author maintainer
#4 lore raw

PATCH 4/23 drm/etnaviv: Make use of the helper component_compare_of/dev_name

In reply to Yong Wu

Use the common compare helpers from component.

Cc Lucas Stach <[email protected]>
Cc Russell King <[email protected]>
Cc Christian Gmeiner <[email protected]>
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_drv.c +2 -14
index 0b756ecb1bc2..1d2b4fb4bcf8 100644
@@ -574,18 +574,6 @@ static const struct component_master_ops etnaviv_master_ops = {
 	.unbind = etnaviv_unbind,
 };
 
-static int compare_of(struct device *dev, void *data)
-{
-	struct device_node *np = data;
-
-	return dev->of_node == np;
-}
-
-static int compare_str(struct device *dev, void *data)
-{
-	return !strcmp(dev_name(dev), data);
-}
-
 static int etnaviv_pdev_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -603,14 +591,14 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
 				first_node = core_node;
 
 			drm_of_component_match_add(&pdev->dev, &match,
-						   compare_of, core_node);
+						   component_compare_of, core_node);
 		}
 	} else {
 		char **names = dev->platform_data;
 		unsigned i;
 
 		for (i = 0; names[i]; i++)
-			component_match_add(dev, &match, compare_str, names[i]);
+			component_match_add(dev, &match, component_compare_dev_name, names[i]);
 	}
 
 	/*
Signature · 1 line
2.18.0
author maintainer
#5 lore raw

PATCH 5/23 drm/hirin: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

Cc Xinliang Liu <[email protected]>
Cc Tian Tao <[email protected]>
Cc John Stultz <[email protected]>
Cc Xinwei Kong <[email protected]>
Cc Chen Feng <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Hao Fang <[email protected]>
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +1 -6
index 98ae9a48f3fe..8041ec11bd48 100644
@@ -203,11 +203,6 @@ static int kirin_drm_kms_init(struct drm_device *dev,
 	return ret;
 }
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int kirin_drm_kms_cleanup(struct drm_device *dev)
 {
 	drm_kms_helper_poll_fini(dev);
@@ -278,7 +273,7 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
 	if (!remote)
 		return -ENODEV;
 
-	drm_of_component_match_add(dev, &match, compare_of, remote);
+	drm_of_component_match_add(dev, &match, component_compare_of, remote);
 	of_node_put(remote);
 
 	return component_master_add_with_match(dev, &kirin_drm_ops, match);
Signature · 1 line
2.18.0
author maintainer
#6 lore raw

PATCH 6/23 drm/ingenic: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +1 -6
index b4943a56be09..23b8f012b418 100644
@@ -1322,11 +1322,6 @@ static int ingenic_drm_bind_with_components(struct device *dev)
 	return ingenic_drm_bind(dev, true);
 }
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static void ingenic_drm_unbind(struct device *dev)
 {
 	struct ingenic_drm *priv = dev_get_drvdata(dev);
@@ -1360,7 +1355,7 @@ static int ingenic_drm_probe(struct platform_device *pdev)
 	if (!np)
 		return ingenic_drm_bind(dev, false);
 
-	drm_of_component_match_add(dev, &match, compare_of, np);
+	drm_of_component_match_add(dev, &match, component_compare_of, np);
 	of_node_put(np);
 
 	return component_master_add_with_match(dev, &ingenic_master_ops, match);
Signature · 1 line
2.18.0
maintainer Acked-by on v1 6/23
#7 lore raw

Re: [PATCH 06/23] drm/ingenic: Make use of the helper component_compare_of

Hi,

Quoted 5 lines · Yong Wu

Use the common compare helper from component.

Cheers,
-Paul

Quoted 35 lines
---
 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +0 -5
index b4943a56be09..23b8f012b418 100644
@@ -1322,11 +1322,6 @@ static int 
 ingenic_drm_bind_with_components(struct device *dev)
 	return ingenic_drm_bind(dev, true);
 }
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static void ingenic_drm_unbind(struct device *dev)
 {
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +1 -1
 	struct ingenic_drm *priv = dev_get_drvdata(dev);
@@ -1360,7 +1355,7 @@ static int ingenic_drm_probe(struct 
 platform_device *pdev)
 	if (!np)
 		return ingenic_drm_bind(dev, false);
 
-	drm_of_component_match_add(dev, &match, compare_of, np);
+	drm_of_component_match_add(dev, &match, component_compare_of, np);
 	of_node_put(np);
 

return component_master_add_with_match(dev, &ingenic_master_ops,
match);
--
2.18.0

author maintainer
#8 lore raw

PATCH 7/23 drm/mediatek: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

Cc Chun-Kuang Hu <[email protected]>
Cc Philipp Zabel <[email protected]>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1 -6
index 56ff8c57ef8f..cd14399eaf8f 100644
@@ -369,11 +369,6 @@ static const struct drm_driver mtk_drm_driver = {
 	.minor = DRIVER_MINOR,
 };
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int mtk_drm_bind(struct device *dev)
 {
 	struct mtk_drm_private *private = dev_get_drvdata(dev);
@@ -614,7 +609,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
 		    comp_type == MTK_DSI) {
 			dev_info(dev, "Adding component match for %pOF\n",
 				 node);
-			drm_of_component_match_add(dev, &match, compare_of,
+			drm_of_component_match_add(dev, &match, component_compare_of,
 						   node);
 		}
 
Signature · 1 line
2.18.0
author maintainer
#9 lore raw

PATCH 8/23 drm/meson: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

Cc Neil Armstrong <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Jerome Brunet <[email protected]>
Cc Martin Blumenstingl <[email protected]>
---
 drivers/gpu/drm/meson/meson_drv.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/meson/meson_drv.c +1 -9
index 80f1d439841a..3a9768a135bb 100644
@@ -423,14 +423,6 @@ static int __maybe_unused meson_drv_pm_resume(struct device *dev)
 	return drm_mode_config_helper_resume(priv->drm);
 }
 
-static int compare_of(struct device *dev, void *data)
-{
-	DRM_DEBUG_DRIVER("Comparing of node %pOF with %pOF\n",
-			 dev->of_node, data);
-
-	return dev->of_node == data;
-}
-
 static void meson_drv_shutdown(struct platform_device *pdev)
 {
 	struct meson_drm *priv = dev_get_drvdata(&pdev->dev);
@@ -473,7 +465,7 @@ static int meson_drv_probe(struct platform_device *pdev)
 		dev_dbg(&pdev->dev, "parent %pOF remote match add %pOF parent %s\n",
 			np, remote, dev_name(&pdev->dev));
 
-		component_match_add(&pdev->dev, &match, compare_of, remote);
+		component_match_add(&pdev->dev, &match, component_compare_of, remote);
 
 		of_node_put(remote);
 
Signature · 1 line
2.18.0
author maintainer
#10 lore raw

PATCH 9/23 drm/msm: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

---
 drivers/gpu/drm/msm/msm_drv.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +3 -12
index ad35a5d94053..50e5a6ff6487 100644
@@ -1173,15 +1173,6 @@ static const struct dev_pm_ops msm_pm_ops = {
  * Componentized driver support:
  */
 
-/*
- * NOTE: duplication of the same code as exynos or imx (or probably any other).
- * so probably some room for some helpers
- */
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 /*
  * Identify what components need to be added by parsing what remote-endpoints
  * our MDP output ports are connected to. In the case of LVDS on MDP4, there
@@ -1239,7 +1230,7 @@ static int add_components_mdp(struct device *mdp_dev,
 
 		if (of_device_is_available(intf))
 			drm_of_component_match_add(master_dev, matchptr,
-						   compare_of, intf);
+						   component_compare_of, intf);
 
 		of_node_put(intf);
 	}
@@ -1285,7 +1276,7 @@ static int add_display_components(struct platform_device *pdev,
 		put_device(mdp_dev);
 
 		/* add the MDP component itself */
-		drm_of_component_match_add(dev, matchptr, compare_of,
+		drm_of_component_match_add(dev, matchptr, component_compare_of,
 					   mdp_dev->of_node);
 		break;
 	case KMS_MDP4:
@@ -1324,7 +1315,7 @@ static int add_gpu_components(struct device *dev,
 		return 0;
 
 	if (of_device_is_available(np))
-		drm_of_component_match_add(dev, matchptr, compare_of, np);
+		drm_of_component_match_add(dev, matchptr, component_compare_of, np);
 
 	of_node_put(np);
 
Signature · 1 line
2.18.0
author maintainer
#11 lore raw

PATCH 10/23 drm/sprd: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

Cc Orson Zhai <[email protected]>
Cc Baolin Wang <[email protected]>
Cc Chunyan Zhang <[email protected]>
Cc Kevin Tang <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
---
 drivers/gpu/drm/sprd/sprd_drm.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/sprd/sprd_drm.c +1 -6
index a077e2d4d721..5d534a8db913 100644
@@ -134,14 +134,9 @@ static const struct component_master_ops drm_component_ops = {
 	.unbind = sprd_drm_unbind,
 };
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int sprd_drm_probe(struct platform_device *pdev)
 {
-	return drm_of_component_probe(&pdev->dev, compare_of, &drm_component_ops);
+	return drm_of_component_probe(&pdev->dev, component_compare_of, &drm_component_ops);
 }
 
 static int sprd_drm_remove(struct platform_device *pdev)
Signature · 1 line
2.18.0
author maintainer
#12 lore raw

PATCH 11/23 drm/sti: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

Cc Benjamin Gaignard <[email protected]>
---
 drivers/gpu/drm/sti/sti_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/sti/sti_drv.c +1 -6
index c7efb43b83ee..890c3103f6bd 100644
@@ -144,11 +144,6 @@ static const struct drm_driver sti_driver = {
 	.minor = DRIVER_MINOR,
 };
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int sti_init(struct drm_device *ddev)
 {
 	struct sti_private *private;
@@ -244,7 +239,7 @@ static int sti_platform_probe(struct platform_device *pdev)
 	child_np = of_get_next_available_child(node, NULL);
 
 	while (child_np) {
-		drm_of_component_match_add(dev, &match, compare_of,
+		drm_of_component_match_add(dev, &match, component_compare_of,
 					   child_np);
 		child_np = of_get_next_available_child(node, child_np);
 	}
Signature · 1 line
2.18.0
author maintainer
#13 lore raw

PATCH 12/23 drm/sun4i: Make use of the helper component_compare_of

In reply to Yong Wu

Use the common compare helper from component.

Cc Maxime Ripard <[email protected]>
Cc Chen-Yu Tsai <[email protected]>
Cc Jernej Skrabec <[email protected]>
---
 drivers/gpu/drm/sun4i/sun4i_drv.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/gpu/drm/sun4i/sun4i_drv.c +1 -10
index b630614b3d72..a3e3e51c600d 100644
@@ -201,15 +201,6 @@ static bool sun4i_drv_node_is_tcon_top(struct device_node *node)
 		!!of_match_node(sun8i_tcon_top_of_table, node);
 }
 
-static int compare_of(struct device *dev, void *data)
-{
-	DRM_DEBUG_DRIVER("Comparing of node %pOF with %pOF\n",
-			 dev->of_node,
-			 data);
-
-	return dev->of_node == data;
-}
-
 /*
  * The encoder drivers use drm_of_find_possible_crtcs to get upstream
  * crtcs from the device tree using of_graph. For the results to be
@@ -329,7 +320,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
 	     of_device_is_available(node))) {
 		/* Add current component */
 		DRM_DEBUG_DRIVER("Adding component %pOF\n", node);
-		drm_of_component_match_add(dev, match, compare_of, node);
+		drm_of_component_match_add(dev, match, component_compare_of, node);
 		count++;
 	}
 
Signature · 1 line
2.18.0
author maintainer
#14 lore raw

PATCH 13/23 drm/rockchip: Make use of the helper component_compare_dev

In reply to Yong Wu

Use the common compare helper from component.

Cc Sandy Huang <[email protected]>
Cc "Heiko St¨¹bner" <[email protected]>
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -6
index bec207de4544..3c2f2d6ecc36 100644
@@ -290,11 +290,6 @@ int rockchip_drm_endpoint_is_subdriver(struct device_node *ep)
 	return false;
 }
 
-static int compare_dev(struct device *dev, void *data)
-{
-	return dev == (struct device *)data;
-}
-
 static void rockchip_drm_match_remove(struct device *dev)
 {
 	struct device_link *link;
@@ -321,7 +316,7 @@ static struct component_match *rockchip_drm_match_add(struct device *dev)
 				break;
 
 			device_link_add(dev, d, DL_FLAG_STATELESS);
-			component_match_add(dev, &match, compare_dev, d);
+			component_match_add(dev, &match, component_compare_dev, d);
 		} while (true);
 	}
 
Signature · 1 line
2.18.0
maintainer Acked-by on v1 13/23
#15 lore raw

Re: [PATCH 13/23] drm/rockchip: Make use of the helper component_compare_dev

Am Montag, 14. Februar 2022, 07:08:09 CET schrieb Yong Wu:

Quoted 6 lines

Use the common compare helper from component.

Cc Sandy Huang <[email protected]>
Cc "Heiko St¨¹bner" <[email protected]>
Quoted 30 lines
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/rockchip/rockchip_drm_drv.c +1 -6
index bec207de4544..3c2f2d6ecc36 100644
@@ -290,11 +290,6 @@ int rockchip_drm_endpoint_is_subdriver(struct device_node *ep)
 	return false;
 }
 
-static int compare_dev(struct device *dev, void *data)
-{
-	return dev == (struct device *)data;
-}
-
 static void rockchip_drm_match_remove(struct device *dev)
 {
 	struct device_link *link;
@@ -321,7 +316,7 @@ static struct component_match *rockchip_drm_match_add(struct device *dev)
 				break;
 
 			device_link_add(dev, d, DL_FLAG_STATELESS);
-			component_match_add(dev, &match, compare_dev, d);
+			component_match_add(dev, &match, component_compare_dev, d);
 		} while (true);
 	}
 
author maintainer
#16 lore raw

PATCH 14/23 drm/exynos: Make use of the helper component_compare_dev

In reply to Yong Wu

Use the common compare helper from component.

Cc Inki Dae <[email protected]>
Cc Joonyoung Shim <[email protected]>
Cc Seung-Woo Kim <[email protected]>
Cc Kyungmin Park <[email protected]>
Cc Krzysztof Kozlowski <[email protected]>
---
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_drv.c +1 -7
index 9743b6b17447..d8b49a3c9b0f 100644
@@ -212,11 +212,6 @@ static struct exynos_drm_driver_info exynos_drm_drivers[] = {
 	}
 };
 
-static int compare_dev(struct device *dev, void *data)
-{
-	return dev == (struct device *)data;
-}
-
 static struct component_match *exynos_drm_match_add(struct device *dev)
 {
 	struct component_match *match = NULL;
@@ -234,8 +229,7 @@ static struct component_match *exynos_drm_match_add(struct device *dev)
 
 			if (!(info->flags & DRM_FIMC_DEVICE) ||
 			    exynos_drm_check_fimc_device(d) == 0)
-				component_match_add(dev, &match,
-						    compare_dev, d);
+				component_match_add(dev, &match, component_compare_dev, d);
 			p = d;
 		}
 		put_device(p);
Signature · 1 line
2.18.0
author maintainer
#17 lore raw

PATCH 15/23 drm/mcde: Make use of the helper component_compare_dev

In reply to Yong Wu

Use the common compare helper from component.

Cc Linus Walleij <[email protected]>
---
 drivers/gpu/drm/mcde/mcde_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/mcde/mcde_drv.c +1 -6
index 5b5afc6aaf8e..a17bfbb152a2 100644
@@ -265,11 +265,6 @@ static struct platform_driver *const mcde_component_drivers[] = {
 	&mcde_dsi_driver,
 };
 
-static int mcde_compare_dev(struct device *dev, void *data)
-{
-	return dev == data;
-}
-
 static int mcde_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -399,7 +394,7 @@ static int mcde_probe(struct platform_device *pdev)
 
 		while ((d = platform_find_device_by_driver(p, drv))) {
 			put_device(p);
-			component_match_add(dev, &match, mcde_compare_dev, d);
+			component_match_add(dev, &match, component_compare_dev, d);
 			p = d;
 		}
 		put_device(p);
Signature · 1 line
2.18.0
author maintainer
#18 lore raw

PATCH 16/23 drm/omap: dss: Make use of the helper component_compare_dev

In reply to Yong Wu

Use the common compare helper from component.

Cc Tomi Valkeinen <[email protected]>
Cc Cai Huoqing <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/omapdrm/dss/dss.c +1 -7
index 69b3e15b9356..0399f3390a0a 100644
@@ -1344,12 +1344,6 @@ static const struct component_master_ops dss_component_ops = {
 	.unbind = dss_unbind,
 };
 
-static int dss_component_compare(struct device *dev, void *data)
-{
-	struct device *child = data;
-	return dev == child;
-}
-
 struct dss_component_match_data {
 	struct device *dev;
 	struct component_match **match;
@@ -1379,7 +1373,7 @@ static int dss_add_child_component(struct device *dev, void *data)
 		return device_for_each_child(dev, cmatch,
 					     dss_add_child_component);
 
-	component_match_add(cmatch->dev, match, dss_component_compare, dev);
+	component_match_add(cmatch->dev, match, component_compare_dev, dev);
 
 	return 0;
 }
Signature · 1 line
2.18.0
author maintainer
#19 lore raw

PATCH 17/23 drm/vc4: Make use of the helper component_compare_dev

In reply to Yong Wu

Use the common compare helper from component.

Cc Emma Anholt <[email protected]>
Cc Maxime Ripard <[email protected]>
---
 drivers/gpu/drm/vc4/vc4_drv.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/vc4/vc4_drv.c +1 -6
index 16abc3a3d601..e0f4c2ef8ba6 100644
@@ -187,11 +187,6 @@ static struct drm_driver vc4_drm_driver = {
 	.patchlevel = DRIVER_PATCHLEVEL,
 };
 
-static int compare_dev(struct device *dev, void *data)
-{
-	return dev == data;
-}
-
 static void vc4_match_add_drivers(struct device *dev,
 				  struct component_match **match,
 				  struct platform_driver *const *drivers,
@@ -205,7 +200,7 @@ static void vc4_match_add_drivers(struct device *dev,
 
 		while ((d = platform_find_device_by_driver(p, drv))) {
 			put_device(p);
-			component_match_add(dev, match, compare_dev, d);
+			component_match_add(dev, match, component_compare_dev, d);
 			p = d;
 		}
 		put_device(p);
Signature · 1 line
2.18.0
author maintainer
#20 lore raw

PATCH 18/23 drm: of: Make use of the helper component_release_of

In reply to Yong Wu

Use the common release helper from component.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
---
 drivers/gpu/drm/drm_of.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/gpu/drm/drm_of.c +1 -6
index 59d368ea006b..9a2cfab3a177 100644
@@ -18,11 +18,6 @@
  * properties.
  */
 
-static void drm_release_of(struct device *dev, void *data)
-{
-	of_node_put(data);
-}
-
 /**
  * drm_of_crtc_port_mask - find the mask of a registered CRTC by port OF node
  * @dev: DRM device
@@ -94,7 +89,7 @@ void drm_of_component_match_add(struct device *master,
 				struct device_node *node)
 {
 	of_node_get(node);
-	component_match_add_release(master, matchptr, drm_release_of,
+	component_match_add_release(master, matchptr, component_release_of,
 				    compare, node);
 }
 EXPORT_SYMBOL_GPL(drm_of_component_match_add);
Signature · 1 line
2.18.0
author maintainer
#21 lore raw

PATCH 19/23 iommu/mediatek: Make use of the helper component_compare/release_of

In reply to Yong Wu

Use the common compare/release helpers from component.

Cc Joerg Roedel <[email protected]>
Cc Will Deacon <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc Yunfei Wang <[email protected]>
Cc Libo Kang <[email protected]>
Cc Anan Sun <[email protected]>
Cc Mingyuan Ma <[email protected]>
Cc Xueqi Zhang <[email protected]>
---
 drivers/iommu/mtk_iommu.c    |  4 ++--
 drivers/iommu/mtk_iommu.h    | 10 ----------
 drivers/iommu/mtk_iommu_v1.c |  4 ++--
 3 files changed, 4 insertions(+), 14 deletions(-)
drivers/iommu/mtk_iommu.c +2 -2
index 25b834104790..a2ec9003826c 100644
@@ -852,8 +852,8 @@ static int mtk_iommu_probe(struct platform_device *pdev)
 		}
 		data->larb_imu[id].dev = &plarbdev->dev;
 
-		component_match_add_release(dev, &match, release_of,
-					    compare_of, larbnode);
+		component_match_add_release(dev, &match, component_release_of,
+					    component_compare_of, larbnode);
 	}
 
 	/* Get smi-common dev from the last larb. */
drivers/iommu/mtk_iommu.h +0 -10
index f81fa8862ed0..b742432220c5 100644
@@ -84,16 +84,6 @@ struct mtk_iommu_data {
 	struct mtk_smi_larb_iommu	larb_imu[MTK_LARB_NR_MAX];
 };
 
-static inline int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
-static inline void release_of(struct device *dev, void *data)
-{
-	of_node_put(data);
-}
-
 static inline int mtk_iommu_bind(struct device *dev)
 {
 	struct mtk_iommu_data *data = dev_get_drvdata(dev);
drivers/iommu/mtk_iommu_v1.c +2 -2
index be22fcf988ce..83bd10617c9f 100644
@@ -599,8 +599,8 @@ static int mtk_iommu_probe(struct platform_device *pdev)
 		}
 		data->larb_imu[i].dev = &plarbdev->dev;
 
-		component_match_add_release(dev, &match, release_of,
-					    compare_of, larbnode);
+		component_match_add_release(dev, &match, component_release_of,
+					    component_compare_of, larbnode);
 	}
 
 	platform_set_drvdata(pdev, data);
Signature · 1 line
2.18.0
author maintainer
#22 lore raw

PATCH 20/23 ASoC: codecs: wcd938x: Make use of the helper component_compare/release_of

In reply to Yong Wu

Use the common compare/release helpers from component.

Cc Liam Girdwood <[email protected]>
Cc Mark Brown <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Srinivas Kandagatla <[email protected]>
Cc Pierre-Louis Bossart <[email protected]>
---
 sound/soc/codecs/wcd938x.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
sound/soc/codecs/wcd938x.c +4 -14
index eff200a07d9f..54f4a41ceca2 100644
@@ -4417,16 +4417,6 @@ static const struct component_master_ops wcd938x_comp_ops = {
 	.unbind = wcd938x_unbind,
 };
 
-static int wcd938x_compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
-static void wcd938x_release_of(struct device *dev, void *data)
-{
-	of_node_put(data);
-}
-
 static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
 					struct device *dev,
 					struct component_match **matchptr)
@@ -4442,8 +4432,8 @@ static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
 	}
 
 	of_node_get(wcd938x->rxnode);
-	component_match_add_release(dev, matchptr, wcd938x_release_of,
-				    wcd938x_compare_of,	wcd938x->rxnode);
+	component_match_add_release(dev, matchptr, component_release_of,
+				    component_compare_of, wcd938x->rxnode);
 
 	wcd938x->txnode = of_parse_phandle(np, "qcom,tx-device", 0);
 	if (!wcd938x->txnode) {
@@ -4451,8 +4441,8 @@ static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x,
 		return -ENODEV;
 	}
 	of_node_get(wcd938x->txnode);
-	component_match_add_release(dev, matchptr, wcd938x_release_of,
-				    wcd938x_compare_of,	wcd938x->txnode);
+	component_match_add_release(dev, matchptr, component_release_of,
+				    component_compare_of, wcd938x->txnode);
 	return 0;
 }
 
Signature · 1 line
2.18.0
maintainer
#23 lore raw

Re: [PATCH 20/23] ASoC: codecs: wcd938x: Make use of the helper component_compare/release_of

Quoted 1 line · Yong Wu

Use the common compare/release helpers from component.

What's the story with dependencies here? I've just got this one patch with no cover letter...

#24 lore raw

Re: [PATCH 20/23] ASoC: codecs: wcd938x: Make use of the helper component_compare/release_of

Il 14/02/22 13:40, Mark Brown ha scritto:

Quoted 5 lines · Yong Wu
Quoted 1 line

Use the common compare/release helpers from component.

What's the story with dependencies here? I've just got this one patch with no cover letter...

Hello Mark,
I agree, the cover letter should be sent to everyone; Yong, please add the proper Ccs to it next time.

Anyway, context:
https://patchwork.kernel.org/project/linux-mediatek/cover/[email protected]/

Cheers,
Angelo

author maintainer
#25 lore raw

Re: [PATCH 20/23] ASoC: codecs: wcd938x: Make use of the helper component_compare/release_of

Quoted 7 lines · AngeloGioacchino Del Regno

Il 14/02/22 13:40, Mark Brown ha scritto:

Quoted 6 lines · Yong Wu
Quoted 1 line

Use the common compare/release helpers from component.

What's the story with dependencies here? I've just got this one patch
with no cover letter...

Sorry for this. I will add in cover letter next time. Maybe in next week. Just to see if there is any other comment.

Thanks.

Quoted 8 lines

Hello Mark,
I agree, the cover letter should be sent to everyone; Yong, please add the
proper Ccs to it next time.

Anyway, context:

https://patchwork.kernel.org/project/linux-mediatek/cover/[email protected]/

Thanks very much:)

Quoted 3 lines

Cheers,
Angelo

author maintainer
#26 lore raw

PATCH 21/23 power: supply: ab8500: Make use of the helper component_compare_dev

In reply to Yong Wu

Use the common compare helper from component.

---
 drivers/power/supply/ab8500_charger.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/power/supply/ab8500_charger.c +1 -7
index ce074c018dcb..875fe665f8a8 100644
@@ -3414,11 +3414,6 @@ static struct platform_driver *const ab8500_charger_component_drivers[] = {
 	&ab8500_chargalg_driver,
 };
 
-static int ab8500_charger_compare_dev(struct device *dev, void *data)
-{
-	return dev == data;
-}
-
 static int ab8500_charger_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -3657,8 +3652,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
 
 		while ((d = platform_find_device_by_driver(p, drv))) {
 			put_device(p);
-			component_match_add(dev, &match,
-					    ab8500_charger_compare_dev, d);
+			component_match_add(dev, &match, component_compare_dev, d);
 			p = d;
 		}
 		put_device(p);
Signature · 1 line
2.18.0
author maintainer
#27 lore raw

PATCH 22/23 video: omapfb: dss: Make use of the helper component_compare_dev

In reply to Yong Wu

Use the common compare helper from component.

---
 drivers/video/fbdev/omap2/omapfb/dss/dss.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/video/fbdev/omap2/omapfb/dss/dss.c +1 -7
index a6b1c1598040..45b9d3cf3860 100644
@@ -1193,12 +1193,6 @@ static const struct component_master_ops dss_component_ops = {
 	.unbind = dss_unbind,
 };
 
-static int dss_component_compare(struct device *dev, void *data)
-{
-	struct device *child = data;
-	return dev == child;
-}
-
 static int dss_add_child_component(struct device *dev, void *data)
 {
 	struct component_match **match = data;
@@ -1212,7 +1206,7 @@ static int dss_add_child_component(struct device *dev, void *data)
 	if (strstr(dev_name(dev), "rfbi"))
 		return 0;
 
-	component_match_add(dev->parent, match, dss_component_compare, dev);
+	component_match_add(dev->parent, match, component_compare_dev, dev);
 
 	return 0;
 }
Signature · 6 lines
2.18.0

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
maintainer Applied
#28 lore raw

Re: [PATCH 22/23] video: omapfb: dss: Make use of the helper component_compare_dev

Quoted 6 lines · Yong Wu

Use the common compare helper from component.

Applied to the fbdev for-next branch.

Thanks!
Helge

Quoted 30 lines
 drivers/video/fbdev/omap2/omapfb/dss/dss.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/video/fbdev/omap2/omapfb/dss/dss.c +1 -7
index a6b1c1598040..45b9d3cf3860 100644
@@ -1193,12 +1193,6 @@ static const struct component_master_ops dss_component_ops = {
 	.unbind = dss_unbind,
 };
 
-static int dss_component_compare(struct device *dev, void *data)
-{
-	struct device *child = data;
-	return dev == child;
-}
-
 static int dss_add_child_component(struct device *dev, void *data)
 {
 	struct component_match **match = data;
@@ -1212,7 +1206,7 @@ static int dss_add_child_component(struct device *dev, void *data)
 	if (strstr(dev_name(dev), "rfbi"))
 		return 0;
 
-	component_match_add(dev->parent, match, dss_component_compare, dev);
+	component_match_add(dev->parent, match, component_compare_dev, dev);
 
 	return 0;
 }
author maintainer
#30 lore raw

PATCH 23/23 ALSA: hda/realtek: Make use of the helper component_compare_dev_name

In reply to Yong Wu

Use the common compare helper from component.

Cc Jaroslav Kysela <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Jeremy Szu <[email protected]>
Cc Werner Sembach <[email protected]>
Cc Hui Wang <[email protected]>
Cc Cameron Berkenpas <[email protected]>
Cc Kailang Yang <[email protected]>
Cc Lucas Tanure <[email protected]>
Cc Sami Loone <[email protected]>
---
 sound/pci/hda/patch_realtek.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
sound/pci/hda/patch_realtek.c +3 -8
index 668274e52674..9da004d99cdb 100644
@@ -6530,11 +6530,6 @@ static void alc287_fixup_legion_15imhg05_speakers(struct hda_codec *codec,
 	}
 }
 
-static int comp_match_dev_name(struct device *dev, void *data)
-{
-	return strcmp(dev_name(dev), data) == 0;
-}
-
 static int find_comp_by_dev_name(struct alc_spec *spec, const char *name)
 {
 	int i;
@@ -6595,7 +6590,7 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char
 					      "%s-%s:00-cs35l41-hda.%d", bus, hid, i);
 			if (!name)
 				return;
-			component_match_add(dev, &spec->match, comp_match_dev_name, name);
+			component_match_add(dev, &spec->match, component_compare_dev_name, name);
 		}
 		ret = component_master_add_with_match(dev, &comp_master_ops, spec->match);
 		if (ret)
@@ -6644,9 +6639,9 @@ static void alc287_fixup_legion_16achg6_speakers(struct hda_codec *cdc, const st
 
 	switch (action) {
 	case HDA_FIXUP_ACT_PRE_PROBE:
-		component_match_add(dev, &spec->match, comp_match_dev_name,
+		component_match_add(dev, &spec->match, component_compare_dev_name,
 				    "i2c-CLSA0100:00-cs35l41-hda.0");
-		component_match_add(dev, &spec->match, comp_match_dev_name,
+		component_match_add(dev, &spec->match, component_compare_dev_name,
 				    "i2c-CLSA0100:00-cs35l41-hda.1");
 		ret = component_master_add_with_match(dev, &comp_master_ops, spec->match);
 		if (ret)
Signature · 1 line
2.18.0