All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03  7:58 ` Russell King
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-06-03  7:58 UTC (permalink / raw)
  To: Liviu Dudau, David Airlie, Rob Clark, Mark Yao, Heiko Stuebner,
	Benjamin Gaignard, Vincent Abriou, dri-devel, linux-arm-msm,
	freedreno, linux-arm-kernel, linux-rockchip

Convert DT component matching to use component_match_add_release().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/gpu/drm/arm/hdlcd_drv.c             | 10 ++++++++--
 drivers/gpu/drm/armada/armada_drv.c         |  9 +++++++--
 drivers/gpu/drm/drm_of.c                    | 13 +++++++++----
 drivers/gpu/drm/msm/msm_drv.c               |  8 +++++++-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++---
 drivers/gpu/drm/sti/sti_drv.c               |  9 +++++++--
 drivers/gpu/drm/tilcdc/tilcdc_external.c    |  9 +++++++--
 7 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index b987c63ba8d6..bbde48c4f550 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = {
 	.unbind		= hdlcd_drm_unbind,
 };
 
-static int compare_dev(struct device *dev, void *data)
+static int compare_of(struct device *dev, void *data)
 {
 	return dev->of_node == data;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static int hdlcd_probe(struct platform_device *pdev)
 {
 	struct device_node *port, *ep;
@@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev)
 		return -EAGAIN;
 	}
 
-	component_match_add(&pdev->dev, &match, compare_dev, port);
+	component_match_add_release(&pdev->dev, &match, release_of,
+				    compare_of, port);
 
 	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
 					       match);
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 439824a61aa5..6ca2aa36515e 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static int compare_dev_name(struct device *dev, void *data)
 {
 	const char *name = data;
@@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
-		of_node_put(remote);
+		component_match_add_release(dev, match, release_of,
+					    compare_of, remote);
 	}
 }
 
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index bc98bb94264d..5d183479d7d6 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -6,6 +6,11 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_of.h>
 
+static void drm_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 /**
  * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
  * @dev: DRM device
@@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, &match, compare_of, port);
-		of_node_put(port);
+		component_match_add_release(dev, &match, drm_release_of,
+					    compare_of, port);
 	}
 
 	if (i == 0) {
@@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev,
 				continue;
 			}
 
-			component_match_add(dev, &match, compare_of, remote);
-			of_node_put(remote);
+			component_match_add_release(dev, &match, drm_release_of,
+						    compare_of, remote);
 		}
 		of_node_put(port);
 	}
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 9c654092ef78..1f7de47d817e 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static int add_components(struct device *dev, struct component_match **matchptr,
 		const char *name)
 {
@@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
 		if (!node)
 			break;
 
-		component_match_add(dev, matchptr, compare_of, node);
+		component_match_add_release(dev, matchptr, release_of,
+					    compare_of, node);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index a409d1f703cb..f5a68fc031ed 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == np;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static void rockchip_add_endpoints(struct device *dev,
 				   struct component_match **match,
 				   struct device_node *port)
@@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
-		of_node_put(remote);
+		component_match_add_release(dev, match, release_of,
+					    compare_of, remote);
 	}
 }
 
@@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
 			is_support_iommu = false;
 		}
 
-		component_match_add(dev, &match, compare_of, port->parent);
+		of_node_get(port->parent);
+		component_match_add_release(dev, &match, release_of,
+					    compare_of, port->parent);
 		of_node_put(port);
 	}
 
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 872495e72294..4ee6fa4f1beb 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static int sti_bind(struct device *dev)
 {
 	return drm_platform_init(&sti_driver, to_platform_device(dev));
@@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev)
 	child_np = of_get_next_available_child(node, NULL);
 
 	while (child_np) {
-		component_match_add(dev, &match, compare_of, child_np);
-		of_node_put(child_np);
+		component_match_add_release(dev, &match, release_of,
+					    compare_of, child_np);
 		child_np = of_get_next_available_child(node, child_np);
 	}
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 03acb4f99982..7e11b5ecdd4a 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
+static void dev_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 int tilcdc_get_external_components(struct device *dev,
 				   struct component_match **match)
 {
@@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
 
 		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
 		if (match)
-			component_match_add(dev, match, dev_match_of, node);
-		of_node_put(node);
+			component_match_add_release(dev, match, dev_release_of,
+						    dev_match_of, node);
 		count++;
 	}
 
-- 
2.1.0

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03  7:58 ` Russell King
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-06-03  7:58 UTC (permalink / raw)
  To: linux-arm-kernel

Convert DT component matching to use component_match_add_release().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/gpu/drm/arm/hdlcd_drv.c             | 10 ++++++++--
 drivers/gpu/drm/armada/armada_drv.c         |  9 +++++++--
 drivers/gpu/drm/drm_of.c                    | 13 +++++++++----
 drivers/gpu/drm/msm/msm_drv.c               |  8 +++++++-
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++---
 drivers/gpu/drm/sti/sti_drv.c               |  9 +++++++--
 drivers/gpu/drm/tilcdc/tilcdc_external.c    |  9 +++++++--
 7 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index b987c63ba8d6..bbde48c4f550 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = {
 	.unbind		= hdlcd_drm_unbind,
 };
 
-static int compare_dev(struct device *dev, void *data)
+static int compare_of(struct device *dev, void *data)
 {
 	return dev->of_node == data;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static int hdlcd_probe(struct platform_device *pdev)
 {
 	struct device_node *port, *ep;
@@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev)
 		return -EAGAIN;
 	}
 
-	component_match_add(&pdev->dev, &match, compare_dev, port);
+	component_match_add_release(&pdev->dev, &match, release_of,
+				    compare_of, port);
 
 	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
 					       match);
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 439824a61aa5..6ca2aa36515e 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static int compare_dev_name(struct device *dev, void *data)
 {
 	const char *name = data;
@@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
-		of_node_put(remote);
+		component_match_add_release(dev, match, release_of,
+					    compare_of, remote);
 	}
 }
 
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index bc98bb94264d..5d183479d7d6 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -6,6 +6,11 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_of.h>
 
+static void drm_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 /**
  * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
  * @dev: DRM device
@@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, &match, compare_of, port);
-		of_node_put(port);
+		component_match_add_release(dev, &match, drm_release_of,
+					    compare_of, port);
 	}
 
 	if (i == 0) {
@@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev,
 				continue;
 			}
 
-			component_match_add(dev, &match, compare_of, remote);
-			of_node_put(remote);
+			component_match_add_release(dev, &match, drm_release_of,
+						    compare_of, remote);
 		}
 		of_node_put(port);
 	}
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 9c654092ef78..1f7de47d817e 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static int add_components(struct device *dev, struct component_match **matchptr,
 		const char *name)
 {
@@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
 		if (!node)
 			break;
 
-		component_match_add(dev, matchptr, compare_of, node);
+		component_match_add_release(dev, matchptr, release_of,
+					    compare_of, node);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index a409d1f703cb..f5a68fc031ed 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == np;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static void rockchip_add_endpoints(struct device *dev,
 				   struct component_match **match,
 				   struct device_node *port)
@@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
-		of_node_put(remote);
+		component_match_add_release(dev, match, release_of,
+					    compare_of, remote);
 	}
 }
 
@@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
 			is_support_iommu = false;
 		}
 
-		component_match_add(dev, &match, compare_of, port->parent);
+		of_node_get(port->parent);
+		component_match_add_release(dev, &match, release_of,
+					    compare_of, port->parent);
 		of_node_put(port);
 	}
 
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 872495e72294..4ee6fa4f1beb 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
+static void release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 static int sti_bind(struct device *dev)
 {
 	return drm_platform_init(&sti_driver, to_platform_device(dev));
@@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev)
 	child_np = of_get_next_available_child(node, NULL);
 
 	while (child_np) {
-		component_match_add(dev, &match, compare_of, child_np);
-		of_node_put(child_np);
+		component_match_add_release(dev, &match, release_of,
+					    compare_of, child_np);
 		child_np = of_get_next_available_child(node, child_np);
 	}
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 03acb4f99982..7e11b5ecdd4a 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data)
 	return dev->of_node == data;
 }
 
+static void dev_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 int tilcdc_get_external_components(struct device *dev,
 				   struct component_match **match)
 {
@@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
 
 		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
 		if (match)
-			component_match_add(dev, match, dev_match_of, node);
-		of_node_put(node);
+			component_match_add_release(dev, match, dev_release_of,
+						    dev_match_of, node);
 		count++;
 	}
 
-- 
2.1.0

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-06-03  7:58 ` Russell King
@ 2016-06-03  9:40   ` Liviu Dudau
  -1 siblings, 0 replies; 56+ messages in thread
From: Liviu Dudau @ 2016-06-03  9:40 UTC (permalink / raw)
  To: Russell King
  Cc: freedreno, linux-arm-msm, dri-devel, linux-rockchip,
	Vincent Abriou, linux-arm-kernel

On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().

Hi Russell,

Any reason for not keeping the component_match_add() calls in the drivers?
Planning to remove it?

> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Looks good to me!

Reviewed-by: Liviu Dudau <Liviu.Dudau@arm.com>

For the HDLCD part:
Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>

Thanks,
Liviu

> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c             | 10 ++++++++--
>  drivers/gpu/drm/armada/armada_drv.c         |  9 +++++++--
>  drivers/gpu/drm/drm_of.c                    | 13 +++++++++----
>  drivers/gpu/drm/msm/msm_drv.c               |  8 +++++++-
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++---
>  drivers/gpu/drm/sti/sti_drv.c               |  9 +++++++--
>  drivers/gpu/drm/tilcdc/tilcdc_external.c    |  9 +++++++--
>  7 files changed, 55 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index b987c63ba8d6..bbde48c4f550 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = {
>  	.unbind		= hdlcd_drm_unbind,
>  };
>  
> -static int compare_dev(struct device *dev, void *data)
> +static int compare_of(struct device *dev, void *data)
>  {
>  	return dev->of_node == data;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static int hdlcd_probe(struct platform_device *pdev)
>  {
>  	struct device_node *port, *ep;
> @@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	component_match_add_release(&pdev->dev, &match, release_of,
> +				    compare_of, port);
>  
>  	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  					       match);
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 439824a61aa5..6ca2aa36515e 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data)
>  	return dev->of_node == data;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static int compare_dev_name(struct device *dev, void *data)
>  {
>  	const char *name = data;
> @@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> -		of_node_put(remote);
> +		component_match_add_release(dev, match, release_of,
> +					    compare_of, remote);
>  	}
>  }
>  
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..5d183479d7d6 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>  
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port);
> -		of_node_put(port);
> +		component_match_add_release(dev, &match, drm_release_of,
> +					    compare_of, port);
>  	}
>  
>  	if (i == 0) {
> @@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev,
>  				continue;
>  			}
>  
> -			component_match_add(dev, &match, compare_of, remote);
> -			of_node_put(remote);
> +			component_match_add_release(dev, &match, drm_release_of,
> +						    compare_of, remote);
>  		}
>  		of_node_put(port);
>  	}
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 9c654092ef78..1f7de47d817e 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data)
>  	return dev->of_node == data;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static int add_components(struct device *dev, struct component_match **matchptr,
>  		const char *name)
>  {
> @@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
>  		if (!node)
>  			break;
>  
> -		component_match_add(dev, matchptr, compare_of, node);
> +		component_match_add_release(dev, matchptr, release_of,
> +					    compare_of, node);
>  	}
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index a409d1f703cb..f5a68fc031ed 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data)
>  	return dev->of_node == np;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static void rockchip_add_endpoints(struct device *dev,
>  				   struct component_match **match,
>  				   struct device_node *port)
> @@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> -		of_node_put(remote);
> +		component_match_add_release(dev, match, release_of,
> +					    compare_of, remote);
>  	}
>  }
>  
> @@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>  			is_support_iommu = false;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		of_node_get(port->parent);
> +		component_match_add_release(dev, &match, release_of,
> +					    compare_of, port->parent);
>  		of_node_put(port);
>  	}
>  
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..4ee6fa4f1beb 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data)
>  	return dev->of_node == data;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static int sti_bind(struct device *dev)
>  {
>  	return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>  	child_np = of_get_next_available_child(node, NULL);
>  
>  	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		component_match_add_release(dev, &match, release_of,
> +					    compare_of, child_np);
>  		child_np = of_get_next_available_child(node, child_np);
>  	}
>  
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 03acb4f99982..7e11b5ecdd4a 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data)
>  	return dev->of_node == data;
>  }
>  
> +static void dev_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  int tilcdc_get_external_components(struct device *dev,
>  				   struct component_match **match)
>  {
> @@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
>  
>  		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>  		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> -		of_node_put(node);
> +			component_match_add_release(dev, match, dev_release_of,
> +						    dev_match_of, node);
>  		count++;
>  	}
>  
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03  9:40   ` Liviu Dudau
  0 siblings, 0 replies; 56+ messages in thread
From: Liviu Dudau @ 2016-06-03  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().

Hi Russell,

Any reason for not keeping the component_match_add() calls in the drivers?
Planning to remove it?

> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Looks good to me!

Reviewed-by: Liviu Dudau <Liviu.Dudau@arm.com>

For the HDLCD part:
Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>

Thanks,
Liviu

> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c             | 10 ++++++++--
>  drivers/gpu/drm/armada/armada_drv.c         |  9 +++++++--
>  drivers/gpu/drm/drm_of.c                    | 13 +++++++++----
>  drivers/gpu/drm/msm/msm_drv.c               |  8 +++++++-
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++---
>  drivers/gpu/drm/sti/sti_drv.c               |  9 +++++++--
>  drivers/gpu/drm/tilcdc/tilcdc_external.c    |  9 +++++++--
>  7 files changed, 55 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index b987c63ba8d6..bbde48c4f550 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = {
>  	.unbind		= hdlcd_drm_unbind,
>  };
>  
> -static int compare_dev(struct device *dev, void *data)
> +static int compare_of(struct device *dev, void *data)
>  {
>  	return dev->of_node == data;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static int hdlcd_probe(struct platform_device *pdev)
>  {
>  	struct device_node *port, *ep;
> @@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	component_match_add_release(&pdev->dev, &match, release_of,
> +				    compare_of, port);
>  
>  	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  					       match);
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 439824a61aa5..6ca2aa36515e 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data)
>  	return dev->of_node == data;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static int compare_dev_name(struct device *dev, void *data)
>  {
>  	const char *name = data;
> @@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> -		of_node_put(remote);
> +		component_match_add_release(dev, match, release_of,
> +					    compare_of, remote);
>  	}
>  }
>  
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..5d183479d7d6 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>  
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port);
> -		of_node_put(port);
> +		component_match_add_release(dev, &match, drm_release_of,
> +					    compare_of, port);
>  	}
>  
>  	if (i == 0) {
> @@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev,
>  				continue;
>  			}
>  
> -			component_match_add(dev, &match, compare_of, remote);
> -			of_node_put(remote);
> +			component_match_add_release(dev, &match, drm_release_of,
> +						    compare_of, remote);
>  		}
>  		of_node_put(port);
>  	}
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 9c654092ef78..1f7de47d817e 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data)
>  	return dev->of_node == data;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static int add_components(struct device *dev, struct component_match **matchptr,
>  		const char *name)
>  {
> @@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
>  		if (!node)
>  			break;
>  
> -		component_match_add(dev, matchptr, compare_of, node);
> +		component_match_add_release(dev, matchptr, release_of,
> +					    compare_of, node);
>  	}
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index a409d1f703cb..f5a68fc031ed 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data)
>  	return dev->of_node == np;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static void rockchip_add_endpoints(struct device *dev,
>  				   struct component_match **match,
>  				   struct device_node *port)
> @@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> -		of_node_put(remote);
> +		component_match_add_release(dev, match, release_of,
> +					    compare_of, remote);
>  	}
>  }
>  
> @@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>  			is_support_iommu = false;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		of_node_get(port->parent);
> +		component_match_add_release(dev, &match, release_of,
> +					    compare_of, port->parent);
>  		of_node_put(port);
>  	}
>  
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..4ee6fa4f1beb 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data)
>  	return dev->of_node == data;
>  }
>  
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  static int sti_bind(struct device *dev)
>  {
>  	return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>  	child_np = of_get_next_available_child(node, NULL);
>  
>  	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		component_match_add_release(dev, &match, release_of,
> +					    compare_of, child_np);
>  		child_np = of_get_next_available_child(node, child_np);
>  	}
>  
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 03acb4f99982..7e11b5ecdd4a 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data)
>  	return dev->of_node == data;
>  }
>  
> +static void dev_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  int tilcdc_get_external_components(struct device *dev,
>  				   struct component_match **match)
>  {
> @@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
>  
>  		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>  		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> -		of_node_put(node);
> +			component_match_add_release(dev, match, dev_release_of,
> +						    dev_match_of, node);
>  		count++;
>  	}
>  
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ?\_(?)_/?

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-06-03  9:40   ` Liviu Dudau
@ 2016-06-03 10:36     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 10:36 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: David Airlie, Rob Clark, Mark Yao, Heiko Stuebner,
	Benjamin Gaignard, Vincent Abriou, dri-devel, linux-arm-msm,
	freedreno, linux-arm-kernel, linux-rockchip

On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
> On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
> > Convert DT component matching to use component_match_add_release().
> 
> Hi Russell,
> 
> Any reason for not keeping the component_match_add() calls in the drivers?

Sorry, I don't understand your comment.

If we kept component_match_add() in these drivers, then this patch
would not exist, because there wouldn't be any changes to the drivers.

> Planning to remove it?

Possibly in the longer term, but at the moment there are drivers where
the match data that is passed does not need any release functionality
eg, data allocated with devm_k*alloc(), or

	component_match_add(dev->parent, match, dss_component_compare, dev);

There are some new cases that need converting which have cropped up
during the last merge window, and I expect this to be an on-going
educational point for driver authors, so I'm not too bothered about
capturing all existing cases in this patch.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03 10:36     ` Russell King - ARM Linux
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 10:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
> On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
> > Convert DT component matching to use component_match_add_release().
> 
> Hi Russell,
> 
> Any reason for not keeping the component_match_add() calls in the drivers?

Sorry, I don't understand your comment.

If we kept component_match_add() in these drivers, then this patch
would not exist, because there wouldn't be any changes to the drivers.

> Planning to remove it?

Possibly in the longer term, but at the moment there are drivers where
the match data that is passed does not need any release functionality
eg, data allocated with devm_k*alloc(), or

	component_match_add(dev->parent, match, dss_component_compare, dev);

There are some new cases that need converting which have cropped up
during the last merge window, and I expect this to be an on-going
educational point for driver authors, so I'm not too bothered about
capturing all existing cases in this patch.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-06-03  7:58 ` Russell King
@ 2016-06-03 10:56   ` Robin Murphy
  -1 siblings, 0 replies; 56+ messages in thread
From: Robin Murphy @ 2016-06-03 10:56 UTC (permalink / raw)
  To: Russell King, Liviu Dudau, David Airlie, Rob Clark, Mark Yao,
	Heiko Stuebner, Benjamin Gaignard, Vincent Abriou, dri-devel,
	linux-arm-msm, freedreno, linux-arm-kernel, linux-rockchip

Hi Russell,

On 03/06/16 08:58, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>   drivers/gpu/drm/arm/hdlcd_drv.c             | 10 ++++++++--
>   drivers/gpu/drm/armada/armada_drv.c         |  9 +++++++--
>   drivers/gpu/drm/drm_of.c                    | 13 +++++++++----
>   drivers/gpu/drm/msm/msm_drv.c               |  8 +++++++-
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++---
>   drivers/gpu/drm/sti/sti_drv.c               |  9 +++++++--
>   drivers/gpu/drm/tilcdc/tilcdc_external.c    |  9 +++++++--
>   7 files changed, 55 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index b987c63ba8d6..bbde48c4f550 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = {
>   	.unbind		= hdlcd_drm_unbind,
>   };
>
> -static int compare_dev(struct device *dev, void *data)
> +static int compare_of(struct device *dev, void *data)
>   {
>   	return dev->of_node == data;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}

Considering that there's 7 identical copies of this function in this 
patch alone, perhaps there's some mileage in defining it commonly as a 
static __maybe_unused default_release_of() in component.h or drm_of.h 
(and maybe default_compare_of() similarly)?

(Apologies if there's already been some strong argument against that 
which I've not seen, but it seems like a reasonable thing to do.)

Robin.

> +
>   static int hdlcd_probe(struct platform_device *pdev)
>   {
>   	struct device_node *port, *ep;
> @@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>   		return -EAGAIN;
>   	}
>
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	component_match_add_release(&pdev->dev, &match, release_of,
> +				    compare_of, port);
>
>   	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>   					       match);
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 439824a61aa5..6ca2aa36515e 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data)
>   	return dev->of_node == data;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   static int compare_dev_name(struct device *dev, void *data)
>   {
>   	const char *name = data;
> @@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev,
>   			continue;
>   		}
>
> -		component_match_add(dev, match, compare_of, remote);
> -		of_node_put(remote);
> +		component_match_add_release(dev, match, release_of,
> +					    compare_of, remote);
>   	}
>   }
>
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..5d183479d7d6 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>   #include <drm/drm_crtc.h>
>   #include <drm/drm_of.h>
>
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   /**
>    * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>    * @dev: DRM device
> @@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev,
>   			continue;
>   		}
>
> -		component_match_add(dev, &match, compare_of, port);
> -		of_node_put(port);
> +		component_match_add_release(dev, &match, drm_release_of,
> +					    compare_of, port);
>   	}
>
>   	if (i == 0) {
> @@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev,
>   				continue;
>   			}
>
> -			component_match_add(dev, &match, compare_of, remote);
> -			of_node_put(remote);
> +			component_match_add_release(dev, &match, drm_release_of,
> +						    compare_of, remote);
>   		}
>   		of_node_put(port);
>   	}
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 9c654092ef78..1f7de47d817e 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data)
>   	return dev->of_node == data;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   static int add_components(struct device *dev, struct component_match **matchptr,
>   		const char *name)
>   {
> @@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
>   		if (!node)
>   			break;
>
> -		component_match_add(dev, matchptr, compare_of, node);
> +		component_match_add_release(dev, matchptr, release_of,
> +					    compare_of, node);
>   	}
>
>   	return 0;
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index a409d1f703cb..f5a68fc031ed 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data)
>   	return dev->of_node == np;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   static void rockchip_add_endpoints(struct device *dev,
>   				   struct component_match **match,
>   				   struct device_node *port)
> @@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev,
>   			continue;
>   		}
>
> -		component_match_add(dev, match, compare_of, remote);
> -		of_node_put(remote);
> +		component_match_add_release(dev, match, release_of,
> +					    compare_of, remote);
>   	}
>   }
>
> @@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>   			is_support_iommu = false;
>   		}
>
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		of_node_get(port->parent);
> +		component_match_add_release(dev, &match, release_of,
> +					    compare_of, port->parent);
>   		of_node_put(port);
>   	}
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..4ee6fa4f1beb 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data)
>   	return dev->of_node == data;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   static int sti_bind(struct device *dev)
>   {
>   	return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>   	child_np = of_get_next_available_child(node, NULL);
>
>   	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		component_match_add_release(dev, &match, release_of,
> +					    compare_of, child_np);
>   		child_np = of_get_next_available_child(node, child_np);
>   	}
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 03acb4f99982..7e11b5ecdd4a 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data)
>   	return dev->of_node == data;
>   }
>
> +static void dev_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   int tilcdc_get_external_components(struct device *dev,
>   				   struct component_match **match)
>   {
> @@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
>
>   		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>   		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> -		of_node_put(node);
> +			component_match_add_release(dev, match, dev_release_of,
> +						    dev_match_of, node);
>   		count++;
>   	}
>
>

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03 10:56   ` Robin Murphy
  0 siblings, 0 replies; 56+ messages in thread
From: Robin Murphy @ 2016-06-03 10:56 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Russell,

On 03/06/16 08:58, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>   drivers/gpu/drm/arm/hdlcd_drv.c             | 10 ++++++++--
>   drivers/gpu/drm/armada/armada_drv.c         |  9 +++++++--
>   drivers/gpu/drm/drm_of.c                    | 13 +++++++++----
>   drivers/gpu/drm/msm/msm_drv.c               |  8 +++++++-
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++---
>   drivers/gpu/drm/sti/sti_drv.c               |  9 +++++++--
>   drivers/gpu/drm/tilcdc/tilcdc_external.c    |  9 +++++++--
>   7 files changed, 55 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index b987c63ba8d6..bbde48c4f550 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = {
>   	.unbind		= hdlcd_drm_unbind,
>   };
>
> -static int compare_dev(struct device *dev, void *data)
> +static int compare_of(struct device *dev, void *data)
>   {
>   	return dev->of_node == data;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}

Considering that there's 7 identical copies of this function in this 
patch alone, perhaps there's some mileage in defining it commonly as a 
static __maybe_unused default_release_of() in component.h or drm_of.h 
(and maybe default_compare_of() similarly)?

(Apologies if there's already been some strong argument against that 
which I've not seen, but it seems like a reasonable thing to do.)

Robin.

> +
>   static int hdlcd_probe(struct platform_device *pdev)
>   {
>   	struct device_node *port, *ep;
> @@ -474,7 +479,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>   		return -EAGAIN;
>   	}
>
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	component_match_add_release(&pdev->dev, &match, release_of,
> +				    compare_of, port);
>
>   	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>   					       match);
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 439824a61aa5..6ca2aa36515e 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -232,6 +232,11 @@ static int compare_of(struct device *dev, void *data)
>   	return dev->of_node == data;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   static int compare_dev_name(struct device *dev, void *data)
>   {
>   	const char *name = data;
> @@ -255,8 +260,8 @@ static void armada_add_endpoints(struct device *dev,
>   			continue;
>   		}
>
> -		component_match_add(dev, match, compare_of, remote);
> -		of_node_put(remote);
> +		component_match_add_release(dev, match, release_of,
> +					    compare_of, remote);
>   	}
>   }
>
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..5d183479d7d6 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>   #include <drm/drm_crtc.h>
>   #include <drm/drm_of.h>
>
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   /**
>    * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>    * @dev: DRM device
> @@ -101,8 +106,8 @@ int drm_of_component_probe(struct device *dev,
>   			continue;
>   		}
>
> -		component_match_add(dev, &match, compare_of, port);
> -		of_node_put(port);
> +		component_match_add_release(dev, &match, drm_release_of,
> +					    compare_of, port);
>   	}
>
>   	if (i == 0) {
> @@ -140,8 +145,8 @@ int drm_of_component_probe(struct device *dev,
>   				continue;
>   			}
>
> -			component_match_add(dev, &match, compare_of, remote);
> -			of_node_put(remote);
> +			component_match_add_release(dev, &match, drm_release_of,
> +						    compare_of, remote);
>   		}
>   		of_node_put(port);
>   	}
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 9c654092ef78..1f7de47d817e 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -805,6 +805,11 @@ static int compare_of(struct device *dev, void *data)
>   	return dev->of_node == data;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   static int add_components(struct device *dev, struct component_match **matchptr,
>   		const char *name)
>   {
> @@ -818,7 +823,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
>   		if (!node)
>   			break;
>
> -		component_match_add(dev, matchptr, compare_of, node);
> +		component_match_add_release(dev, matchptr, release_of,
> +					    compare_of, node);
>   	}
>
>   	return 0;
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index a409d1f703cb..f5a68fc031ed 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -421,6 +421,11 @@ static int compare_of(struct device *dev, void *data)
>   	return dev->of_node == np;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   static void rockchip_add_endpoints(struct device *dev,
>   				   struct component_match **match,
>   				   struct device_node *port)
> @@ -439,8 +444,8 @@ static void rockchip_add_endpoints(struct device *dev,
>   			continue;
>   		}
>
> -		component_match_add(dev, match, compare_of, remote);
> -		of_node_put(remote);
> +		component_match_add_release(dev, match, release_of,
> +					    compare_of, remote);
>   	}
>   }
>
> @@ -518,7 +523,9 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>   			is_support_iommu = false;
>   		}
>
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		of_node_get(port->parent);
> +		component_match_add_release(dev, &match, release_of,
> +					    compare_of, port->parent);
>   		of_node_put(port);
>   	}
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..4ee6fa4f1beb 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -346,6 +346,11 @@ static int compare_of(struct device *dev, void *data)
>   	return dev->of_node == data;
>   }
>
> +static void release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   static int sti_bind(struct device *dev)
>   {
>   	return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +380,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>   	child_np = of_get_next_available_child(node, NULL);
>
>   	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		component_match_add_release(dev, &match, release_of,
> +					    compare_of, child_np);
>   		child_np = of_get_next_available_child(node, child_np);
>   	}
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 03acb4f99982..7e11b5ecdd4a 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -135,6 +135,11 @@ static int dev_match_of(struct device *dev, void *data)
>   	return dev->of_node == data;
>   }
>
> +static void dev_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>   int tilcdc_get_external_components(struct device *dev,
>   				   struct component_match **match)
>   {
> @@ -152,8 +157,8 @@ int tilcdc_get_external_components(struct device *dev,
>
>   		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>   		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> -		of_node_put(node);
> +			component_match_add_release(dev, match, dev_release_of,
> +						    dev_match_of, node);
>   		count++;
>   	}
>
>

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-06-03 10:36     ` Russell King - ARM Linux
@ 2016-06-03 11:19       ` Liviu Dudau
  -1 siblings, 0 replies; 56+ messages in thread
From: Liviu Dudau @ 2016-06-03 11:19 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: David Airlie, Rob Clark, Mark Yao, Heiko Stuebner,
	Benjamin Gaignard, Vincent Abriou, dri-devel, linux-arm-msm,
	freedreno, linux-arm-kernel, linux-rockchip

On Fri, Jun 03, 2016 at 11:36:33AM +0100, Russell King - ARM Linux wrote:
> On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
> > On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
> > > Convert DT component matching to use component_match_add_release().
> > 
> > Hi Russell,
> > 
> > Any reason for not keeping the component_match_add() calls in the drivers?
> 
> Sorry, I don't understand your comment.

As in: component_match_add() already exists as a macro that calls
component_match_add_release(), but with a NULL release function. If it were
to be changed to pass a default release_of() function then most of the drivers
would not have to change, right? It is just one point of view and I was
curious if there was a reason not to choose it, as it would have (probably)
generated a smaller delta?

> 
> If we kept component_match_add() in these drivers, then this patch
> would not exist, because there wouldn't be any changes to the drivers.
> 
> > Planning to remove it?
> 
> Possibly in the longer term, but at the moment there are drivers where
> the match data that is passed does not need any release functionality
> eg, data allocated with devm_k*alloc(), or
> 
> 	component_match_add(dev->parent, match, dss_component_compare, dev);
> 
> There are some new cases that need converting which have cropped up
> during the last merge window, and I expect this to be an on-going
> educational point for driver authors, so I'm not too bothered about
> capturing all existing cases in this patch.

Understood. Using managed allocators is definitely a strong point in favor
of having the component_match_add() function with a NULL release() hook.

Best regards,
Liviu

> 
> -- 
> RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
> according to speedtest.net.
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03 11:19       ` Liviu Dudau
  0 siblings, 0 replies; 56+ messages in thread
From: Liviu Dudau @ 2016-06-03 11:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 11:36:33AM +0100, Russell King - ARM Linux wrote:
> On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
> > On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
> > > Convert DT component matching to use component_match_add_release().
> > 
> > Hi Russell,
> > 
> > Any reason for not keeping the component_match_add() calls in the drivers?
> 
> Sorry, I don't understand your comment.

As in: component_match_add() already exists as a macro that calls
component_match_add_release(), but with a NULL release function. If it were
to be changed to pass a default release_of() function then most of the drivers
would not have to change, right? It is just one point of view and I was
curious if there was a reason not to choose it, as it would have (probably)
generated a smaller delta?

> 
> If we kept component_match_add() in these drivers, then this patch
> would not exist, because there wouldn't be any changes to the drivers.
> 
> > Planning to remove it?
> 
> Possibly in the longer term, but at the moment there are drivers where
> the match data that is passed does not need any release functionality
> eg, data allocated with devm_k*alloc(), or
> 
> 	component_match_add(dev->parent, match, dss_component_compare, dev);
> 
> There are some new cases that need converting which have cropped up
> during the last merge window, and I expect this to be an on-going
> educational point for driver authors, so I'm not too bothered about
> capturing all existing cases in this patch.

Understood. Using managed allocators is definitely a strong point in favor
of having the component_match_add() function with a NULL release() hook.

Best regards,
Liviu

> 
> -- 
> RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
> according to speedtest.net.
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ?\_(?)_/?

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-06-03 11:19       ` Liviu Dudau
@ 2016-06-03 11:48         ` Russell King - ARM Linux
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 11:48 UTC (permalink / raw)
  To: Liviu Dudau
  Cc: David Airlie, Rob Clark, Mark Yao, Heiko Stuebner,
	Benjamin Gaignard, Vincent Abriou, dri-devel, linux-arm-msm,
	freedreno, linux-arm-kernel, linux-rockchip

On Fri, Jun 03, 2016 at 12:19:41PM +0100, Liviu Dudau wrote:
> On Fri, Jun 03, 2016 at 11:36:33AM +0100, Russell King - ARM Linux wrote:
> > On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
> > > On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
> > > > Convert DT component matching to use component_match_add_release().
> > > 
> > > Hi Russell,
> > > 
> > > Any reason for not keeping the component_match_add() calls in the drivers?
> > 
> > Sorry, I don't understand your comment.
> 
> As in: component_match_add() already exists as a macro that calls
> component_match_add_release(), but with a NULL release function. If it
> were to be changed to pass a default release_of() function then most of
> the drivers would not have to change, right? It is just one point of
> view and I was curious if there was a reason not to choose it, as it
> would have (probably) generated a smaller delta?

And what should the calls that don't pass a DT node be called?
What happens to new users who aren't passing a DT node but use
component_match_add() ?

What you're suggesting sound totally insane to me: you're making
the change a flag-day: component_match_add() currently takes anything
as the data pointer and users can pass anything that their compare
function can handle - and changing that to a function which can only
take a device_node.  That means all non-DT users of that function
need to change at the same time.

Flag days are really bad news in kernel development (or any
distributed development project), and I won't generate a patch which
causes a flag day to occur - especially not one which impacts a large
number of users.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03 11:48         ` Russell King - ARM Linux
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 11:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 12:19:41PM +0100, Liviu Dudau wrote:
> On Fri, Jun 03, 2016 at 11:36:33AM +0100, Russell King - ARM Linux wrote:
> > On Fri, Jun 03, 2016 at 10:40:48AM +0100, Liviu Dudau wrote:
> > > On Fri, Jun 03, 2016 at 08:58:10AM +0100, Russell King wrote:
> > > > Convert DT component matching to use component_match_add_release().
> > > 
> > > Hi Russell,
> > > 
> > > Any reason for not keeping the component_match_add() calls in the drivers?
> > 
> > Sorry, I don't understand your comment.
> 
> As in: component_match_add() already exists as a macro that calls
> component_match_add_release(), but with a NULL release function. If it
> were to be changed to pass a default release_of() function then most of
> the drivers would not have to change, right? It is just one point of
> view and I was curious if there was a reason not to choose it, as it
> would have (probably) generated a smaller delta?

And what should the calls that don't pass a DT node be called?
What happens to new users who aren't passing a DT node but use
component_match_add() ?

What you're suggesting sound totally insane to me: you're making
the change a flag-day: component_match_add() currently takes anything
as the data pointer and users can pass anything that their compare
function can handle - and changing that to a function which can only
take a device_node.  That means all non-DT users of that function
need to change at the same time.

Flag days are really bad news in kernel development (or any
distributed development project), and I won't generate a patch which
causes a flag day to occur - especially not one which impacts a large
number of users.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-06-03 10:56   ` Robin Murphy
@ 2016-06-03 14:15     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 14:15 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Liviu Dudau, David Airlie, Rob Clark, Mark Yao, Heiko Stuebner,
	Benjamin Gaignard, Vincent Abriou, dri-devel, linux-arm-msm,
	freedreno, linux-arm-kernel, linux-rockchip

On Fri, Jun 03, 2016 at 11:56:40AM +0100, Robin Murphy wrote:
> Hi Russell,
> 
> On 03/06/16 08:58, Russell King wrote:
> >Convert DT component matching to use component_match_add_release().
> >
> >Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> >---
> >  drivers/gpu/drm/arm/hdlcd_drv.c             | 10 ++++++++--
> >  drivers/gpu/drm/armada/armada_drv.c         |  9 +++++++--
> >  drivers/gpu/drm/drm_of.c                    | 13 +++++++++----
> >  drivers/gpu/drm/msm/msm_drv.c               |  8 +++++++-
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++---
> >  drivers/gpu/drm/sti/sti_drv.c               |  9 +++++++--
> >  drivers/gpu/drm/tilcdc/tilcdc_external.c    |  9 +++++++--
> >  7 files changed, 55 insertions(+), 16 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> >index b987c63ba8d6..bbde48c4f550 100644
> >--- a/drivers/gpu/drm/arm/hdlcd_drv.c
> >+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> >@@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = {
> >  	.unbind		= hdlcd_drm_unbind,
> >  };
> >
> >-static int compare_dev(struct device *dev, void *data)
> >+static int compare_of(struct device *dev, void *data)
> >  {
> >  	return dev->of_node == data;
> >  }
> >
> >+static void release_of(struct device *dev, void *data)
> >+{
> >+	of_node_put(data);
> >+}
> 
> Considering that there's 7 identical copies of this function in this patch
> alone, perhaps there's some mileage in defining it commonly as a static
> __maybe_unused default_release_of() in component.h or drm_of.h (and maybe
> default_compare_of() similarly)?
> 
> (Apologies if there's already been some strong argument against that which
> I've not seen, but it seems like a reasonable thing to do.)

What we could do is extract out the common bits of OF-component matching
into drivers/of/of_component.c and make the whole thing a tad better.
I'll send a v2 series threaded to this message.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03 14:15     ` Russell King - ARM Linux
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 14:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 11:56:40AM +0100, Robin Murphy wrote:
> Hi Russell,
> 
> On 03/06/16 08:58, Russell King wrote:
> >Convert DT component matching to use component_match_add_release().
> >
> >Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> >---
> >  drivers/gpu/drm/arm/hdlcd_drv.c             | 10 ++++++++--
> >  drivers/gpu/drm/armada/armada_drv.c         |  9 +++++++--
> >  drivers/gpu/drm/drm_of.c                    | 13 +++++++++----
> >  drivers/gpu/drm/msm/msm_drv.c               |  8 +++++++-
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 13 ++++++++++---
> >  drivers/gpu/drm/sti/sti_drv.c               |  9 +++++++--
> >  drivers/gpu/drm/tilcdc/tilcdc_external.c    |  9 +++++++--
> >  7 files changed, 55 insertions(+), 16 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> >index b987c63ba8d6..bbde48c4f550 100644
> >--- a/drivers/gpu/drm/arm/hdlcd_drv.c
> >+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> >@@ -443,11 +443,16 @@ static const struct component_master_ops hdlcd_master_ops = {
> >  	.unbind		= hdlcd_drm_unbind,
> >  };
> >
> >-static int compare_dev(struct device *dev, void *data)
> >+static int compare_of(struct device *dev, void *data)
> >  {
> >  	return dev->of_node == data;
> >  }
> >
> >+static void release_of(struct device *dev, void *data)
> >+{
> >+	of_node_put(data);
> >+}
> 
> Considering that there's 7 identical copies of this function in this patch
> alone, perhaps there's some mileage in defining it commonly as a static
> __maybe_unused default_release_of() in component.h or drm_of.h (and maybe
> default_compare_of() similarly)?
> 
> (Apologies if there's already been some strong argument against that which
> I've not seen, but it seems like a reasonable thing to do.)

What we could do is extract out the common bits of OF-component matching
into drivers/of/of_component.c and make the whole thing a tad better.
I'll send a v2 series threaded to this message.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH v2 1/3] of: add common OF-based component functionality
  2016-06-03 14:15     ` Russell King - ARM Linux
@ 2016-06-03 14:21       ` Russell King
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-06-03 14:21 UTC (permalink / raw)
  To: devicetree, dri-devel, linux-arm-kernel, linux-arm-msm,
	linux-mediatek, linux-rockchip
  Cc: Rob Herring, Frank Rowand, Grant Likely

Add common OF-based component functionality for matching devices by
device node, and releasing the device node at the appropraite time.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/of/Makefile          |  2 +-
 drivers/of/of_component.c    | 41 +++++++++++++++++++++++++++++++++++++++++
 include/linux/of_component.h | 14 ++++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 drivers/of/of_component.c
 create mode 100644 include/linux/of_component.h

diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index d7efd9d458aa..6a4a5e2c0839 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -1,4 +1,4 @@
-obj-y = base.o device.o platform.o
+obj-y = base.o of_component.o device.o platform.o
 obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
 obj-$(CONFIG_OF_FLATTREE) += fdt.o
 obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o
diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c
new file mode 100644
index 000000000000..41e6e817d264
--- /dev/null
+++ b/drivers/of/of_component.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/component.h>
+#include <linux/device.h>
+#include <linux/of.h>
+#include <linux/of_component.h>
+#include <linux/of_graph.h>
+
+static void component_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
+void component_match_add_of_compare(struct device *master,
+	struct component_match **matchptr,
+	int (*compare)(struct device *, void *), struct device_node *node)
+{
+	of_node_get(node);
+	component_match_add_release(master, matchptr, component_release_of,
+				    compare, node);
+}
+EXPORT_SYMBOL_GPL(component_match_add_of_compare);
+
+static void component_compare_of(struct device *dev, void *data)
+{
+	return dev->of_node == data;
+}
+
+void component_match_add_of(struct device *master,
+	struct component_match **matchptr, struct device_node *node)
+{
+	of_node_get(node);
+	component_match_add_release(master, matchptr, component_release_of,
+				    component_compare_of, node);
+}
+EXPORT_SYMBOL_GPL(component_match_add_of);
diff --git a/include/linux/of_component.h b/include/linux/of_component.h
new file mode 100644
index 000000000000..a8170ba3b786
--- /dev/null
+++ b/include/linux/of_component.h
@@ -0,0 +1,14 @@
+#ifndef __LINUX_COMPONENT_OF_H
+#define __LINUX_COMPONENT_OF_H
+
+struct component_match;
+struct device;
+struct device_node;
+
+void component_match_add_of_compare(struct device *master,
+	struct component_match **matchptr,
+	int (*compare)(struct device *, void *), struct device_node *node);
+void component_match_add_of(struct device *master,
+	struct component_match **matchptr, struct device_node *node);
+
+#endif
-- 
2.1.0

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

* [PATCH v2 1/3] of: add common OF-based component functionality
@ 2016-06-03 14:21       ` Russell King
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-06-03 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

Add common OF-based component functionality for matching devices by
device node, and releasing the device node at the appropraite time.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/of/Makefile          |  2 +-
 drivers/of/of_component.c    | 41 +++++++++++++++++++++++++++++++++++++++++
 include/linux/of_component.h | 14 ++++++++++++++
 3 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 drivers/of/of_component.c
 create mode 100644 include/linux/of_component.h

diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index d7efd9d458aa..6a4a5e2c0839 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -1,4 +1,4 @@
-obj-y = base.o device.o platform.o
+obj-y = base.o of_component.o device.o platform.o
 obj-$(CONFIG_OF_DYNAMIC) += dynamic.o
 obj-$(CONFIG_OF_FLATTREE) += fdt.o
 obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o
diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c
new file mode 100644
index 000000000000..41e6e817d264
--- /dev/null
+++ b/drivers/of/of_component.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2016 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/component.h>
+#include <linux/device.h>
+#include <linux/of.h>
+#include <linux/of_component.h>
+#include <linux/of_graph.h>
+
+static void component_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
+void component_match_add_of_compare(struct device *master,
+	struct component_match **matchptr,
+	int (*compare)(struct device *, void *), struct device_node *node)
+{
+	of_node_get(node);
+	component_match_add_release(master, matchptr, component_release_of,
+				    compare, node);
+}
+EXPORT_SYMBOL_GPL(component_match_add_of_compare);
+
+static void component_compare_of(struct device *dev, void *data)
+{
+	return dev->of_node == data;
+}
+
+void component_match_add_of(struct device *master,
+	struct component_match **matchptr, struct device_node *node)
+{
+	of_node_get(node);
+	component_match_add_release(master, matchptr, component_release_of,
+				    component_compare_of, node);
+}
+EXPORT_SYMBOL_GPL(component_match_add_of);
diff --git a/include/linux/of_component.h b/include/linux/of_component.h
new file mode 100644
index 000000000000..a8170ba3b786
--- /dev/null
+++ b/include/linux/of_component.h
@@ -0,0 +1,14 @@
+#ifndef __LINUX_COMPONENT_OF_H
+#define __LINUX_COMPONENT_OF_H
+
+struct component_match;
+struct device;
+struct device_node;
+
+void component_match_add_of_compare(struct device *master,
+	struct component_match **matchptr,
+	int (*compare)(struct device *, void *), struct device_node *node);
+void component_match_add_of(struct device *master,
+	struct component_match **matchptr, struct device_node *node);
+
+#endif
-- 
2.1.0

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

* [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()
  2016-06-03 14:15     ` Russell King - ARM Linux
@ 2016-06-03 14:21       ` Russell King
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-06-03 14:21 UTC (permalink / raw)
  To: devicetree, dri-devel, linux-arm-kernel, linux-arm-msm,
	linux-mediatek, linux-rockchip
  Cc: Liviu Dudau, David Airlie, Lucas Stach, Christian Gmeiner,
	Rob Clark, Mark Yao, Heiko Stuebner, Benjamin Gaignard,
	Vincent Abriou, freedreno

Convert DT component matching to use component_match_add_release().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/gpu/drm/arm/hdlcd_drv.c             |  9 +++------
 drivers/gpu/drm/armada/armada_drv.c         |  8 ++------
 drivers/gpu/drm/drm_of.c                    |  6 ++++--
 drivers/gpu/drm/etnaviv/etnaviv_drv.c       | 11 ++---------
 drivers/gpu/drm/msm/msm_drv.c               |  8 ++------
 drivers/gpu/drm/msm/msm_drv.h               |  1 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++---------
 drivers/gpu/drm/sti/sti_drv.c               |  9 ++-------
 drivers/gpu/drm/tilcdc/tilcdc_external.c    |  8 ++------
 9 files changed, 21 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index b987c63ba8d6..f00845c25795 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -14,6 +14,7 @@
 #include <linux/clk.h>
 #include <linux/component.h>
 #include <linux/list.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/pm_runtime.h>
@@ -443,11 +444,6 @@ static const struct component_master_ops hdlcd_master_ops = {
 	.unbind		= hdlcd_drm_unbind,
 };
 
-static int compare_dev(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int hdlcd_probe(struct platform_device *pdev)
 {
 	struct device_node *port, *ep;
@@ -474,7 +470,8 @@ static int hdlcd_probe(struct platform_device *pdev)
 		return -EAGAIN;
 	}
 
-	component_match_add(&pdev->dev, &match, compare_dev, port);
+	component_match_add_of(&pdev->dev, &match, port);
+	of_node_put(port);
 
 	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
 					       match);
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 439824a61aa5..f2716d20c257 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -9,6 +9,7 @@
 #include <linux/component.h>
 #include <linux/module.h>
 #include <linux/of_graph.h>
+#include <linux/of_component.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_of.h>
@@ -227,11 +228,6 @@ static void armada_drm_unbind(struct device *dev)
 	drm_put_dev(dev_get_drvdata(dev));
 }
 
-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;
@@ -255,7 +251,7 @@ static void armada_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
+		component_match_add_of(dev, match, remote);
 		of_node_put(remote);
 	}
 }
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index bc98bb94264d..d13fc633aeea 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -1,6 +1,7 @@
 #include <linux/component.h>
 #include <linux/export.h>
 #include <linux/list.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
@@ -101,7 +102,7 @@ int drm_of_component_probe(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, &match, compare_of, port);
+		component_match_add_of(dev, &match, compare_of, port);
 		of_node_put(port);
 	}
 
@@ -140,7 +141,8 @@ int drm_of_component_probe(struct device *dev,
 				continue;
 			}
 
-			component_match_add(dev, &match, compare_of, remote);
+			component_match_add_of_compare(dev, &match, compare_of,
+						       remote);
 			of_node_put(remote);
 		}
 		of_node_put(port);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 3d4f56df8359..a0e0764a6269 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -15,6 +15,7 @@
  */
 
 #include <linux/component.h>
+#include <linux/of_component.h>
 #include <linux/of_platform.h>
 
 #include "etnaviv_drv.h"
@@ -606,13 +607,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);
@@ -635,8 +629,7 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
 			if (!core_node)
 				break;
 
-			component_match_add(&pdev->dev, &match, compare_of,
-					    core_node);
+			component_match_add_of(&pdev->dev, &match, core_node);
 			of_node_put(core_node);
 		}
 	} else if (dev->platform_data) {
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 9c654092ef78..5293aa775c5a 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -800,11 +800,6 @@ static const struct dev_pm_ops msm_pm_ops = {
  * 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;
-}
-
 static int add_components(struct device *dev, struct component_match **matchptr,
 		const char *name)
 {
@@ -818,7 +813,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
 		if (!node)
 			break;
 
-		component_match_add(dev, matchptr, compare_of, node);
+		component_match_add_of(dev, matchptr, node);
+		of_node_put(node);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 5b2963f32291..66dafecaf115 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -30,6 +30,7 @@
 #include <linux/list.h>
 #include <linux/iommu.h>
 #include <linux/types.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 #include <linux/of_device.h>
 #include <asm/sizes.h>
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index a409d1f703cb..84c50f6770c3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -22,6 +22,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/pm_runtime.h>
 #include <linux/module.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 #include <linux/component.h>
 
@@ -414,13 +415,6 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
 				rockchip_drm_sys_resume)
 };
 
-static int compare_of(struct device *dev, void *data)
-{
-	struct device_node *np = data;
-
-	return dev->of_node == np;
-}
-
 static void rockchip_add_endpoints(struct device *dev,
 				   struct component_match **match,
 				   struct device_node *port)
@@ -439,7 +433,7 @@ static void rockchip_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
+		component_match_add_of(dev, match, remote);
 		of_node_put(remote);
 	}
 }
@@ -518,7 +512,7 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
 			is_support_iommu = false;
 		}
 
-		component_match_add(dev, &match, compare_of, port->parent);
+		component_match_add_of(dev, &match, port->parent);
 		of_node_put(port);
 	}
 
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 872495e72294..aeb2787c9bd4 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -10,6 +10,7 @@
 #include <linux/debugfs.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_component.h>
 #include <linux/of_platform.h>
 
 #include <drm/drm_atomic.h>
@@ -341,11 +342,6 @@ static 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_bind(struct device *dev)
 {
 	return drm_platform_init(&sti_driver, to_platform_device(dev));
@@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev)
 	child_np = of_get_next_available_child(node, NULL);
 
 	while (child_np) {
-		component_match_add(dev, &match, compare_of, child_np);
-		of_node_put(child_np);
+		component_match_add_of(dev, &match, child_np);
 		child_np = of_get_next_available_child(node, child_np);
 	}
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 03acb4f99982..1b3fd9fa4bef 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/component.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 
 #include "tilcdc_drv.h"
@@ -130,11 +131,6 @@ void tilcdc_remove_external_encoders(struct drm_device *dev)
 						 priv->connector_funcs[i]);
 }
 
-static int dev_match_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 int tilcdc_get_external_components(struct device *dev,
 				   struct component_match **match)
 {
@@ -152,7 +148,7 @@ int tilcdc_get_external_components(struct device *dev,
 
 		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
 		if (match)
-			component_match_add(dev, match, dev_match_of, node);
+			component_match_add_of(dev, match, node);
 		of_node_put(node);
 		count++;
 	}
-- 
2.1.0

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

* [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03 14:21       ` Russell King
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-06-03 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

Convert DT component matching to use component_match_add_release().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/gpu/drm/arm/hdlcd_drv.c             |  9 +++------
 drivers/gpu/drm/armada/armada_drv.c         |  8 ++------
 drivers/gpu/drm/drm_of.c                    |  6 ++++--
 drivers/gpu/drm/etnaviv/etnaviv_drv.c       | 11 ++---------
 drivers/gpu/drm/msm/msm_drv.c               |  8 ++------
 drivers/gpu/drm/msm/msm_drv.h               |  1 +
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++---------
 drivers/gpu/drm/sti/sti_drv.c               |  9 ++-------
 drivers/gpu/drm/tilcdc/tilcdc_external.c    |  8 ++------
 9 files changed, 21 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index b987c63ba8d6..f00845c25795 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -14,6 +14,7 @@
 #include <linux/clk.h>
 #include <linux/component.h>
 #include <linux/list.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 #include <linux/of_reserved_mem.h>
 #include <linux/pm_runtime.h>
@@ -443,11 +444,6 @@ static const struct component_master_ops hdlcd_master_ops = {
 	.unbind		= hdlcd_drm_unbind,
 };
 
-static int compare_dev(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int hdlcd_probe(struct platform_device *pdev)
 {
 	struct device_node *port, *ep;
@@ -474,7 +470,8 @@ static int hdlcd_probe(struct platform_device *pdev)
 		return -EAGAIN;
 	}
 
-	component_match_add(&pdev->dev, &match, compare_dev, port);
+	component_match_add_of(&pdev->dev, &match, port);
+	of_node_put(port);
 
 	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
 					       match);
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 439824a61aa5..f2716d20c257 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -9,6 +9,7 @@
 #include <linux/component.h>
 #include <linux/module.h>
 #include <linux/of_graph.h>
+#include <linux/of_component.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_of.h>
@@ -227,11 +228,6 @@ static void armada_drm_unbind(struct device *dev)
 	drm_put_dev(dev_get_drvdata(dev));
 }
 
-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;
@@ -255,7 +251,7 @@ static void armada_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
+		component_match_add_of(dev, match, remote);
 		of_node_put(remote);
 	}
 }
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index bc98bb94264d..d13fc633aeea 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -1,6 +1,7 @@
 #include <linux/component.h>
 #include <linux/export.h>
 #include <linux/list.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
@@ -101,7 +102,7 @@ int drm_of_component_probe(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, &match, compare_of, port);
+		component_match_add_of(dev, &match, compare_of, port);
 		of_node_put(port);
 	}
 
@@ -140,7 +141,8 @@ int drm_of_component_probe(struct device *dev,
 				continue;
 			}
 
-			component_match_add(dev, &match, compare_of, remote);
+			component_match_add_of_compare(dev, &match, compare_of,
+						       remote);
 			of_node_put(remote);
 		}
 		of_node_put(port);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 3d4f56df8359..a0e0764a6269 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -15,6 +15,7 @@
  */
 
 #include <linux/component.h>
+#include <linux/of_component.h>
 #include <linux/of_platform.h>
 
 #include "etnaviv_drv.h"
@@ -606,13 +607,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);
@@ -635,8 +629,7 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
 			if (!core_node)
 				break;
 
-			component_match_add(&pdev->dev, &match, compare_of,
-					    core_node);
+			component_match_add_of(&pdev->dev, &match, core_node);
 			of_node_put(core_node);
 		}
 	} else if (dev->platform_data) {
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 9c654092ef78..5293aa775c5a 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -800,11 +800,6 @@ static const struct dev_pm_ops msm_pm_ops = {
  * 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;
-}
-
 static int add_components(struct device *dev, struct component_match **matchptr,
 		const char *name)
 {
@@ -818,7 +813,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
 		if (!node)
 			break;
 
-		component_match_add(dev, matchptr, compare_of, node);
+		component_match_add_of(dev, matchptr, node);
+		of_node_put(node);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 5b2963f32291..66dafecaf115 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -30,6 +30,7 @@
 #include <linux/list.h>
 #include <linux/iommu.h>
 #include <linux/types.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 #include <linux/of_device.h>
 #include <asm/sizes.h>
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index a409d1f703cb..84c50f6770c3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -22,6 +22,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/pm_runtime.h>
 #include <linux/module.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 #include <linux/component.h>
 
@@ -414,13 +415,6 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
 				rockchip_drm_sys_resume)
 };
 
-static int compare_of(struct device *dev, void *data)
-{
-	struct device_node *np = data;
-
-	return dev->of_node == np;
-}
-
 static void rockchip_add_endpoints(struct device *dev,
 				   struct component_match **match,
 				   struct device_node *port)
@@ -439,7 +433,7 @@ static void rockchip_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
+		component_match_add_of(dev, match, remote);
 		of_node_put(remote);
 	}
 }
@@ -518,7 +512,7 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
 			is_support_iommu = false;
 		}
 
-		component_match_add(dev, &match, compare_of, port->parent);
+		component_match_add_of(dev, &match, port->parent);
 		of_node_put(port);
 	}
 
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 872495e72294..aeb2787c9bd4 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -10,6 +10,7 @@
 #include <linux/debugfs.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_component.h>
 #include <linux/of_platform.h>
 
 #include <drm/drm_atomic.h>
@@ -341,11 +342,6 @@ static 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_bind(struct device *dev)
 {
 	return drm_platform_init(&sti_driver, to_platform_device(dev));
@@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev)
 	child_np = of_get_next_available_child(node, NULL);
 
 	while (child_np) {
-		component_match_add(dev, &match, compare_of, child_np);
-		of_node_put(child_np);
+		component_match_add_of(dev, &match, child_np);
 		child_np = of_get_next_available_child(node, child_np);
 	}
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 03acb4f99982..1b3fd9fa4bef 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/component.h>
+#include <linux/of_component.h>
 #include <linux/of_graph.h>
 
 #include "tilcdc_drv.h"
@@ -130,11 +131,6 @@ void tilcdc_remove_external_encoders(struct drm_device *dev)
 						 priv->connector_funcs[i]);
 }
 
-static int dev_match_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 int tilcdc_get_external_components(struct device *dev,
 				   struct component_match **match)
 {
@@ -152,7 +148,7 @@ int tilcdc_get_external_components(struct device *dev,
 
 		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
 		if (match)
-			component_match_add(dev, match, dev_match_of, node);
+			component_match_add_of(dev, match, node);
 		of_node_put(node);
 		count++;
 	}
-- 
2.1.0

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

* [PATCH v2 3/3] iommu: convert DT component matching to component_match_add_release()
  2016-06-03 14:15     ` Russell King - ARM Linux
@ 2016-06-03 14:21       ` Russell King
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-06-03 14:21 UTC (permalink / raw)
  To: devicetree, dri-devel, linux-arm-kernel, linux-arm-msm,
	linux-mediatek, linux-rockchip
  Cc: Joerg Roedel, Matthias Brugger, iommu

Convert DT component matching to use component_match_add_release().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/iommu/mtk_iommu.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index c3043d8754e3..71cf62af4e24 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -24,6 +24,7 @@
 #include <linux/iopoll.h>
 #include <linux/list.h>
 #include <linux/of_address.h>
+#include <linux/of_component.h>
 #include <linux/of_iommu.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
@@ -552,11 +553,6 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
 	return 0;
 }
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int mtk_iommu_bind(struct device *dev)
 {
 	struct mtk_iommu_data *data = dev_get_drvdata(dev);
@@ -630,17 +626,19 @@ static int mtk_iommu_probe(struct platform_device *pdev)
 			continue;
 
 		plarbdev = of_find_device_by_node(larbnode);
-		of_node_put(larbnode);
 		if (!plarbdev) {
 			plarbdev = of_platform_device_create(
 						larbnode, NULL,
 						platform_bus_type.dev_root);
-			if (!plarbdev)
+			if (!plarbdev) {
+				of_node_put(larbnode);
 				return -EPROBE_DEFER;
+			}
 		}
 		data->smi_imu.larb_imu[i].dev = &plarbdev->dev;
 
-		component_match_add(dev, &match, compare_of, larbnode);
+		component_match_add_of(dev, &match, larbnode);
+		of_node_put(larbnode);
 	}
 
 	platform_set_drvdata(pdev, data);
-- 
2.1.0

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

* [PATCH v2 3/3] iommu: convert DT component matching to component_match_add_release()
@ 2016-06-03 14:21       ` Russell King
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-06-03 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

Convert DT component matching to use component_match_add_release().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/iommu/mtk_iommu.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index c3043d8754e3..71cf62af4e24 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -24,6 +24,7 @@
 #include <linux/iopoll.h>
 #include <linux/list.h>
 #include <linux/of_address.h>
+#include <linux/of_component.h>
 #include <linux/of_iommu.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
@@ -552,11 +553,6 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
 	return 0;
 }
 
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
 static int mtk_iommu_bind(struct device *dev)
 {
 	struct mtk_iommu_data *data = dev_get_drvdata(dev);
@@ -630,17 +626,19 @@ static int mtk_iommu_probe(struct platform_device *pdev)
 			continue;
 
 		plarbdev = of_find_device_by_node(larbnode);
-		of_node_put(larbnode);
 		if (!plarbdev) {
 			plarbdev = of_platform_device_create(
 						larbnode, NULL,
 						platform_bus_type.dev_root);
-			if (!plarbdev)
+			if (!plarbdev) {
+				of_node_put(larbnode);
 				return -EPROBE_DEFER;
+			}
 		}
 		data->smi_imu.larb_imu[i].dev = &plarbdev->dev;
 
-		component_match_add(dev, &match, compare_of, larbnode);
+		component_match_add_of(dev, &match, larbnode);
+		of_node_put(larbnode);
 	}
 
 	platform_set_drvdata(pdev, data);
-- 
2.1.0

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

* Re: [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()
  2016-06-03 14:21       ` Russell King
@ 2016-06-03 15:10         ` Lucas Stach
  -1 siblings, 0 replies; 56+ messages in thread
From: Lucas Stach @ 2016-06-03 15:10 UTC (permalink / raw)
  To: Russell King
  Cc: devicetree, linux-arm-msm, Liviu Dudau, dri-devel,
	linux-rockchip, linux-mediatek, freedreno, Vincent Abriou,
	linux-arm-kernel

Am Freitag, den 03.06.2016, 15:21 +0100 schrieb Russell King:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c             |  9 +++------
>  drivers/gpu/drm/armada/armada_drv.c         |  8 ++------
>  drivers/gpu/drm/drm_of.c                    |  6 ++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c       | 11 ++---------

For the etnaviv part:

Acked-by: Lucas Stach <l.stach@pengutronix.de>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()
@ 2016-06-03 15:10         ` Lucas Stach
  0 siblings, 0 replies; 56+ messages in thread
From: Lucas Stach @ 2016-06-03 15:10 UTC (permalink / raw)
  To: linux-arm-kernel

Am Freitag, den 03.06.2016, 15:21 +0100 schrieb Russell King:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c             |  9 +++------
>  drivers/gpu/drm/armada/armada_drv.c         |  8 ++------
>  drivers/gpu/drm/drm_of.c                    |  6 ++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c       | 11 ++---------

For the etnaviv part:

Acked-by: Lucas Stach <l.stach@pengutronix.de>

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

* Re: [PATCH v2 3/3] iommu: convert DT component matching to component_match_add_release()
  2016-06-03 14:21       ` Russell King
@ 2016-06-03 15:20         ` Matthias Brugger
  -1 siblings, 0 replies; 56+ messages in thread
From: Matthias Brugger @ 2016-06-03 15:20 UTC (permalink / raw)
  To: Russell King, devicetree, dri-devel, linux-arm-kernel,
	linux-arm-msm, linux-mediatek, linux-rockchip
  Cc: Joerg Roedel, iommu



On 03/06/16 16:21, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>


Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
>   drivers/iommu/mtk_iommu.c | 14 ++++++--------
>   1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index c3043d8754e3..71cf62af4e24 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -24,6 +24,7 @@
>   #include <linux/iopoll.h>
>   #include <linux/list.h>
>   #include <linux/of_address.h>
> +#include <linux/of_component.h>
>   #include <linux/of_iommu.h>
>   #include <linux/of_irq.h>
>   #include <linux/of_platform.h>
> @@ -552,11 +553,6 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
>   	return 0;
>   }
>
> -static int compare_of(struct device *dev, void *data)
> -{
> -	return dev->of_node == data;
> -}
> -
>   static int mtk_iommu_bind(struct device *dev)
>   {
>   	struct mtk_iommu_data *data = dev_get_drvdata(dev);
> @@ -630,17 +626,19 @@ static int mtk_iommu_probe(struct platform_device *pdev)
>   			continue;
>
>   		plarbdev = of_find_device_by_node(larbnode);
> -		of_node_put(larbnode);
>   		if (!plarbdev) {
>   			plarbdev = of_platform_device_create(
>   						larbnode, NULL,
>   						platform_bus_type.dev_root);
> -			if (!plarbdev)
> +			if (!plarbdev) {
> +				of_node_put(larbnode);
>   				return -EPROBE_DEFER;
> +			}
>   		}
>   		data->smi_imu.larb_imu[i].dev = &plarbdev->dev;
>
> -		component_match_add(dev, &match, compare_of, larbnode);
> +		component_match_add_of(dev, &match, larbnode);
> +		of_node_put(larbnode);
>   	}
>
>   	platform_set_drvdata(pdev, data);
>

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

* [PATCH v2 3/3] iommu: convert DT component matching to component_match_add_release()
@ 2016-06-03 15:20         ` Matthias Brugger
  0 siblings, 0 replies; 56+ messages in thread
From: Matthias Brugger @ 2016-06-03 15:20 UTC (permalink / raw)
  To: linux-arm-kernel



On 03/06/16 16:21, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>


Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
>   drivers/iommu/mtk_iommu.c | 14 ++++++--------
>   1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index c3043d8754e3..71cf62af4e24 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -24,6 +24,7 @@
>   #include <linux/iopoll.h>
>   #include <linux/list.h>
>   #include <linux/of_address.h>
> +#include <linux/of_component.h>
>   #include <linux/of_iommu.h>
>   #include <linux/of_irq.h>
>   #include <linux/of_platform.h>
> @@ -552,11 +553,6 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)
>   	return 0;
>   }
>
> -static int compare_of(struct device *dev, void *data)
> -{
> -	return dev->of_node == data;
> -}
> -
>   static int mtk_iommu_bind(struct device *dev)
>   {
>   	struct mtk_iommu_data *data = dev_get_drvdata(dev);
> @@ -630,17 +626,19 @@ static int mtk_iommu_probe(struct platform_device *pdev)
>   			continue;
>
>   		plarbdev = of_find_device_by_node(larbnode);
> -		of_node_put(larbnode);
>   		if (!plarbdev) {
>   			plarbdev = of_platform_device_create(
>   						larbnode, NULL,
>   						platform_bus_type.dev_root);
> -			if (!plarbdev)
> +			if (!plarbdev) {
> +				of_node_put(larbnode);
>   				return -EPROBE_DEFER;
> +			}
>   		}
>   		data->smi_imu.larb_imu[i].dev = &plarbdev->dev;
>
> -		component_match_add(dev, &match, compare_of, larbnode);
> +		component_match_add_of(dev, &match, larbnode);
> +		of_node_put(larbnode);
>   	}
>
>   	platform_set_drvdata(pdev, data);
>

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

* Re: [PATCH v2 1/3] of: add common OF-based component functionality
  2016-06-03 14:21       ` Russell King
@ 2016-06-03 15:29           ` Rob Herring
  -1 siblings, 0 replies; 56+ messages in thread
From: Rob Herring @ 2016-06-03 15:29 UTC (permalink / raw)
  To: Russell King
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, dri-devel,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-arm-msm,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	open list:ARM/Rockchip SoC...,
	Frank Rowand, Grant Likely

On Fri, Jun 3, 2016 at 9:21 AM, Russell King <rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org> wrote:
> Add common OF-based component functionality for matching devices by
> device node, and releasing the device node at the appropraite time.
>
> Signed-off-by: Russell King <rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>
> ---
>  drivers/of/Makefile          |  2 +-
>  drivers/of/of_component.c    | 41 +++++++++++++++++++++++++++++++++++++++++
>  include/linux/of_component.h | 14 ++++++++++++++

I'd prefer this to go into drivers/base/component.c. That's the
general direction we've been moving.

I'd expect this would cause some build failures unless the cases you
converted all depend on CONFIG_OF.

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 1/3] of: add common OF-based component functionality
@ 2016-06-03 15:29           ` Rob Herring
  0 siblings, 0 replies; 56+ messages in thread
From: Rob Herring @ 2016-06-03 15:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 3, 2016 at 9:21 AM, Russell King <rmk+kernel@armlinux.org.uk> wrote:
> Add common OF-based component functionality for matching devices by
> device node, and releasing the device node at the appropraite time.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/of/Makefile          |  2 +-
>  drivers/of/of_component.c    | 41 +++++++++++++++++++++++++++++++++++++++++
>  include/linux/of_component.h | 14 ++++++++++++++

I'd prefer this to go into drivers/base/component.c. That's the
general direction we've been moving.

I'd expect this would cause some build failures unless the cases you
converted all depend on CONFIG_OF.

Rob

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

* Re: [PATCH v2 1/3] of: add common OF-based component functionality
  2016-06-03 15:29           ` Rob Herring
@ 2016-06-03 15:36             ` Russell King - ARM Linux
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 15:36 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, dri-devel, linux-arm-kernel, linux-arm-msm,
	linux-mediatek, open list:ARM/Rockchip SoC...,
	Frank Rowand, Grant Likely

On Fri, Jun 03, 2016 at 10:29:40AM -0500, Rob Herring wrote:
> On Fri, Jun 3, 2016 at 9:21 AM, Russell King <rmk+kernel@armlinux.org.uk> wrote:
> > Add common OF-based component functionality for matching devices by
> > device node, and releasing the device node at the appropraite time.
> >
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> >  drivers/of/Makefile          |  2 +-
> >  drivers/of/of_component.c    | 41 +++++++++++++++++++++++++++++++++++++++++
> >  include/linux/of_component.h | 14 ++++++++++++++
> 
> I'd prefer this to go into drivers/base/component.c. That's the
> general direction we've been moving.

I'd prefer not to, I don't want to turn the component helpers into
something OF specific.  They aren't OF specific.

> I'd expect this would cause some build failures unless the cases you
> converted all depend on CONFIG_OF.

Okay, I'll stick with v1 then, and the duplication that v1 involves.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH v2 1/3] of: add common OF-based component functionality
@ 2016-06-03 15:36             ` Russell King - ARM Linux
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 15:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 10:29:40AM -0500, Rob Herring wrote:
> On Fri, Jun 3, 2016 at 9:21 AM, Russell King <rmk+kernel@armlinux.org.uk> wrote:
> > Add common OF-based component functionality for matching devices by
> > device node, and releasing the device node at the appropraite time.
> >
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> >  drivers/of/Makefile          |  2 +-
> >  drivers/of/of_component.c    | 41 +++++++++++++++++++++++++++++++++++++++++
> >  include/linux/of_component.h | 14 ++++++++++++++
> 
> I'd prefer this to go into drivers/base/component.c. That's the
> general direction we've been moving.

I'd prefer not to, I don't want to turn the component helpers into
something OF specific.  They aren't OF specific.

> I'd expect this would cause some build failures unless the cases you
> converted all depend on CONFIG_OF.

Okay, I'll stick with v1 then, and the duplication that v1 involves.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH v2 1/3] of: add common OF-based component functionality
  2016-06-03 14:21       ` Russell King
@ 2016-06-03 15:44           ` Thierry Reding
  -1 siblings, 0 replies; 56+ messages in thread
From: Thierry Reding @ 2016-06-03 15:44 UTC (permalink / raw)
  To: Russell King
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Grant Likely,
	Rob Herring, Frank Rowand

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

On Fri, Jun 03, 2016 at 03:21:19PM +0100, Russell King wrote:
[...]
> diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c
[...]
> +static void component_compare_of(struct device *dev, void *data)
> +{
> +	return dev->of_node == data;
> +}

The return statement here doesn't match the return value. Didn't GCC
complain about this?

Thierry

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

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

* [PATCH v2 1/3] of: add common OF-based component functionality
@ 2016-06-03 15:44           ` Thierry Reding
  0 siblings, 0 replies; 56+ messages in thread
From: Thierry Reding @ 2016-06-03 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 03:21:19PM +0100, Russell King wrote:
[...]
> diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c
[...]
> +static void component_compare_of(struct device *dev, void *data)
> +{
> +	return dev->of_node == data;
> +}

The return statement here doesn't match the return value. Didn't GCC
complain about this?

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

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

* Re: [PATCH v2 1/3] of: add common OF-based component functionality
  2016-06-03 15:44           ` Thierry Reding
@ 2016-06-03 16:11             ` Russell King - ARM Linux
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 16:11 UTC (permalink / raw)
  To: Thierry Reding
  Cc: devicetree, dri-devel, linux-arm-kernel, linux-arm-msm,
	linux-mediatek, linux-rockchip, Grant Likely, Rob Herring,
	Frank Rowand

On Fri, Jun 03, 2016 at 05:44:30PM +0200, Thierry Reding wrote:
> On Fri, Jun 03, 2016 at 03:21:19PM +0100, Russell King wrote:
> [...]
> > diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c
> [...]
> > +static void component_compare_of(struct device *dev, void *data)
> > +{
> > +	return dev->of_node == data;
> > +}
> 
> The return statement here doesn't match the return value. Didn't GCC
> complain about this?

I didn't build-test it, because I wanted people's opinions on it first
(building means rebuilding my entire tree...)

Anyway, the patch series is dead because I'm not prepared to make the
changes which Rob mentioned, so we're back to v1 instead.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH v2 1/3] of: add common OF-based component functionality
@ 2016-06-03 16:11             ` Russell King - ARM Linux
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-06-03 16:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 05:44:30PM +0200, Thierry Reding wrote:
> On Fri, Jun 03, 2016 at 03:21:19PM +0100, Russell King wrote:
> [...]
> > diff --git a/drivers/of/of_component.c b/drivers/of/of_component.c
> [...]
> > +static void component_compare_of(struct device *dev, void *data)
> > +{
> > +	return dev->of_node == data;
> > +}
> 
> The return statement here doesn't match the return value. Didn't GCC
> complain about this?

I didn't build-test it, because I wanted people's opinions on it first
(building means rebuilding my entire tree...)

Anyway, the patch series is dead because I'm not prepared to make the
changes which Rob mentioned, so we're back to v1 instead.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH v2 1/3] of: add common OF-based component functionality
  2016-06-03 15:36             ` Russell King - ARM Linux
@ 2016-06-03 19:52               ` Rob Herring
  -1 siblings, 0 replies; 56+ messages in thread
From: Rob Herring @ 2016-06-03 19:52 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: devicetree, linux-arm-msm, dri-devel,
	open list:ARM/Rockchip SoC...,
	linux-mediatek, Grant Likely, Frank Rowand, linux-arm-kernel

On Fri, Jun 3, 2016 at 10:36 AM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Fri, Jun 03, 2016 at 10:29:40AM -0500, Rob Herring wrote:
>> On Fri, Jun 3, 2016 at 9:21 AM, Russell King <rmk+kernel@armlinux.org.uk> wrote:
>> > Add common OF-based component functionality for matching devices by
>> > device node, and releasing the device node at the appropraite time.
>> >
>> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
>> > ---
>> >  drivers/of/Makefile          |  2 +-
>> >  drivers/of/of_component.c    | 41 +++++++++++++++++++++++++++++++++++++++++
>> >  include/linux/of_component.h | 14 ++++++++++++++
>>
>> I'd prefer this to go into drivers/base/component.c. That's the
>> general direction we've been moving.
>
> I'd prefer not to, I don't want to turn the component helpers into
> something OF specific.  They aren't OF specific.

Fine, not enough code to argue about...

>> I'd expect this would cause some build failures unless the cases you
>> converted all depend on CONFIG_OF.
>
> Okay, I'll stick with v1 then, and the duplication that v1 involves.

Why? You don't want to add empty functions? Seems like good clean-up.

Rob

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

* [PATCH v2 1/3] of: add common OF-based component functionality
@ 2016-06-03 19:52               ` Rob Herring
  0 siblings, 0 replies; 56+ messages in thread
From: Rob Herring @ 2016-06-03 19:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 3, 2016 at 10:36 AM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Fri, Jun 03, 2016 at 10:29:40AM -0500, Rob Herring wrote:
>> On Fri, Jun 3, 2016 at 9:21 AM, Russell King <rmk+kernel@armlinux.org.uk> wrote:
>> > Add common OF-based component functionality for matching devices by
>> > device node, and releasing the device node at the appropraite time.
>> >
>> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
>> > ---
>> >  drivers/of/Makefile          |  2 +-
>> >  drivers/of/of_component.c    | 41 +++++++++++++++++++++++++++++++++++++++++
>> >  include/linux/of_component.h | 14 ++++++++++++++
>>
>> I'd prefer this to go into drivers/base/component.c. That's the
>> general direction we've been moving.
>
> I'd prefer not to, I don't want to turn the component helpers into
> something OF specific.  They aren't OF specific.

Fine, not enough code to argue about...

>> I'd expect this would cause some build failures unless the cases you
>> converted all depend on CONFIG_OF.
>
> Okay, I'll stick with v1 then, and the duplication that v1 involves.

Why? You don't want to add empty functions? Seems like good clean-up.

Rob

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

* Re: [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()
  2016-06-03 14:21       ` Russell King
@ 2016-06-07 13:39           ` Liviu Dudau
  -1 siblings, 0 replies; 56+ messages in thread
From: Liviu Dudau @ 2016-06-07 13:39 UTC (permalink / raw)
  To: Russell King
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, David Airlie,
	Lucas Stach, Christian Gmeiner, Rob Clark, Mark Yao,
	Heiko Stuebner, Benjamin Gaignard, Vincent Abriou,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Fri, Jun 03, 2016 at 03:21:25PM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>
> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c             |  9 +++------
>  drivers/gpu/drm/armada/armada_drv.c         |  8 ++------
>  drivers/gpu/drm/drm_of.c                    |  6 ++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c       | 11 ++---------
>  drivers/gpu/drm/msm/msm_drv.c               |  8 ++------
>  drivers/gpu/drm/msm/msm_drv.h               |  1 +
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++---------
>  drivers/gpu/drm/sti/sti_drv.c               |  9 ++-------
>  drivers/gpu/drm/tilcdc/tilcdc_external.c    |  8 ++------
>  9 files changed, 21 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index b987c63ba8d6..f00845c25795 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -14,6 +14,7 @@
>  #include <linux/clk.h>
>  #include <linux/component.h>
>  #include <linux/list.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  #include <linux/of_reserved_mem.h>
>  #include <linux/pm_runtime.h>
> @@ -443,11 +444,6 @@ static const struct component_master_ops hdlcd_master_ops = {
>  	.unbind		= hdlcd_drm_unbind,
>  };
>  
> -static int compare_dev(struct device *dev, void *data)
> -{
> -	return dev->of_node == data;
> -}
> -
>  static int hdlcd_probe(struct platform_device *pdev)
>  {
>  	struct device_node *port, *ep;
> @@ -474,7 +470,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	component_match_add_of(&pdev->dev, &match, port);
> +	of_node_put(port);
>  
>  	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  					       match);

For the HDLCD part of v2:

Acked-by: Liviu Dudau <Liviu.Dudau-5wv7dgnIgG8@public.gmane.org>


> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 439824a61aa5..f2716d20c257 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -9,6 +9,7 @@
>  #include <linux/component.h>
>  #include <linux/module.h>
>  #include <linux/of_graph.h>
> +#include <linux/of_component.h>
>  #include <drm/drmP.h>
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_of.h>
> @@ -227,11 +228,6 @@ static void armada_drm_unbind(struct device *dev)
>  	drm_put_dev(dev_get_drvdata(dev));
>  }
>  
> -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;
> @@ -255,7 +251,7 @@ static void armada_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		component_match_add_of(dev, match, remote);
>  		of_node_put(remote);
>  	}
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..d13fc633aeea 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -1,6 +1,7 @@
>  #include <linux/component.h>
>  #include <linux/export.h>
>  #include <linux/list.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  #include <drm/drmP.h>
>  #include <drm/drm_crtc.h>
> @@ -101,7 +102,7 @@ int drm_of_component_probe(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port);
> +		component_match_add_of(dev, &match, compare_of, port);
>  		of_node_put(port);
>  	}
>  
> @@ -140,7 +141,8 @@ int drm_of_component_probe(struct device *dev,
>  				continue;
>  			}
>  
> -			component_match_add(dev, &match, compare_of, remote);
> +			component_match_add_of_compare(dev, &match, compare_of,
> +						       remote);
>  			of_node_put(remote);
>  		}
>  		of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index 3d4f56df8359..a0e0764a6269 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -15,6 +15,7 @@
>   */
>  
>  #include <linux/component.h>
> +#include <linux/of_component.h>
>  #include <linux/of_platform.h>
>  
>  #include "etnaviv_drv.h"
> @@ -606,13 +607,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);
> @@ -635,8 +629,7 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>  			if (!core_node)
>  				break;
>  
> -			component_match_add(&pdev->dev, &match, compare_of,
> -					    core_node);
> +			component_match_add_of(&pdev->dev, &match, core_node);
>  			of_node_put(core_node);
>  		}
>  	} else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 9c654092ef78..5293aa775c5a 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -800,11 +800,6 @@ static const struct dev_pm_ops msm_pm_ops = {
>   * 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;
> -}
> -
>  static int add_components(struct device *dev, struct component_match **matchptr,
>  		const char *name)
>  {
> @@ -818,7 +813,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
>  		if (!node)
>  			break;
>  
> -		component_match_add(dev, matchptr, compare_of, node);
> +		component_match_add_of(dev, matchptr, node);
> +		of_node_put(node);
>  	}
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
> index 5b2963f32291..66dafecaf115 100644
> --- a/drivers/gpu/drm/msm/msm_drv.h
> +++ b/drivers/gpu/drm/msm/msm_drv.h
> @@ -30,6 +30,7 @@
>  #include <linux/list.h>
>  #include <linux/iommu.h>
>  #include <linux/types.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  #include <linux/of_device.h>
>  #include <asm/sizes.h>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index a409d1f703cb..84c50f6770c3 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -22,6 +22,7 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  #include <linux/component.h>
>  
> @@ -414,13 +415,6 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
>  				rockchip_drm_sys_resume)
>  };
>  
> -static int compare_of(struct device *dev, void *data)
> -{
> -	struct device_node *np = data;
> -
> -	return dev->of_node == np;
> -}
> -
>  static void rockchip_add_endpoints(struct device *dev,
>  				   struct component_match **match,
>  				   struct device_node *port)
> @@ -439,7 +433,7 @@ static void rockchip_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		component_match_add_of(dev, match, remote);
>  		of_node_put(remote);
>  	}
>  }
> @@ -518,7 +512,7 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>  			is_support_iommu = false;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		component_match_add_of(dev, &match, port->parent);
>  		of_node_put(port);
>  	}
>  
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..aeb2787c9bd4 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -10,6 +10,7 @@
>  #include <linux/debugfs.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/of_component.h>
>  #include <linux/of_platform.h>
>  
>  #include <drm/drm_atomic.h>
> @@ -341,11 +342,6 @@ static 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_bind(struct device *dev)
>  {
>  	return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev)
>  	child_np = of_get_next_available_child(node, NULL);
>  
>  	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		component_match_add_of(dev, &match, child_np);
>  		child_np = of_get_next_available_child(node, child_np);
>  	}
>  
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 03acb4f99982..1b3fd9fa4bef 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -9,6 +9,7 @@
>   */
>  
>  #include <linux/component.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  
>  #include "tilcdc_drv.h"
> @@ -130,11 +131,6 @@ void tilcdc_remove_external_encoders(struct drm_device *dev)
>  						 priv->connector_funcs[i]);
>  }
>  
> -static int dev_match_of(struct device *dev, void *data)
> -{
> -	return dev->of_node == data;
> -}
> -
>  int tilcdc_get_external_components(struct device *dev,
>  				   struct component_match **match)
>  {
> @@ -152,7 +148,7 @@ int tilcdc_get_external_components(struct device *dev,
>  
>  		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>  		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> +			component_match_add_of(dev, match, node);
>  		of_node_put(node);
>  		count++;
>  	}
> -- 
> 2.1.0
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()
@ 2016-06-07 13:39           ` Liviu Dudau
  0 siblings, 0 replies; 56+ messages in thread
From: Liviu Dudau @ 2016-06-07 13:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 03:21:25PM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/gpu/drm/arm/hdlcd_drv.c             |  9 +++------
>  drivers/gpu/drm/armada/armada_drv.c         |  8 ++------
>  drivers/gpu/drm/drm_of.c                    |  6 ++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c       | 11 ++---------
>  drivers/gpu/drm/msm/msm_drv.c               |  8 ++------
>  drivers/gpu/drm/msm/msm_drv.h               |  1 +
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++---------
>  drivers/gpu/drm/sti/sti_drv.c               |  9 ++-------
>  drivers/gpu/drm/tilcdc/tilcdc_external.c    |  8 ++------
>  9 files changed, 21 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index b987c63ba8d6..f00845c25795 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -14,6 +14,7 @@
>  #include <linux/clk.h>
>  #include <linux/component.h>
>  #include <linux/list.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  #include <linux/of_reserved_mem.h>
>  #include <linux/pm_runtime.h>
> @@ -443,11 +444,6 @@ static const struct component_master_ops hdlcd_master_ops = {
>  	.unbind		= hdlcd_drm_unbind,
>  };
>  
> -static int compare_dev(struct device *dev, void *data)
> -{
> -	return dev->of_node == data;
> -}
> -
>  static int hdlcd_probe(struct platform_device *pdev)
>  {
>  	struct device_node *port, *ep;
> @@ -474,7 +470,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	component_match_add_of(&pdev->dev, &match, port);
> +	of_node_put(port);
>  
>  	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  					       match);

For the HDLCD part of v2:

Acked-by: Liviu Dudau <Liviu.Dudau@arm.com>


> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 439824a61aa5..f2716d20c257 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -9,6 +9,7 @@
>  #include <linux/component.h>
>  #include <linux/module.h>
>  #include <linux/of_graph.h>
> +#include <linux/of_component.h>
>  #include <drm/drmP.h>
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_of.h>
> @@ -227,11 +228,6 @@ static void armada_drm_unbind(struct device *dev)
>  	drm_put_dev(dev_get_drvdata(dev));
>  }
>  
> -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;
> @@ -255,7 +251,7 @@ static void armada_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		component_match_add_of(dev, match, remote);
>  		of_node_put(remote);
>  	}
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..d13fc633aeea 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -1,6 +1,7 @@
>  #include <linux/component.h>
>  #include <linux/export.h>
>  #include <linux/list.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  #include <drm/drmP.h>
>  #include <drm/drm_crtc.h>
> @@ -101,7 +102,7 @@ int drm_of_component_probe(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port);
> +		component_match_add_of(dev, &match, compare_of, port);
>  		of_node_put(port);
>  	}
>  
> @@ -140,7 +141,8 @@ int drm_of_component_probe(struct device *dev,
>  				continue;
>  			}
>  
> -			component_match_add(dev, &match, compare_of, remote);
> +			component_match_add_of_compare(dev, &match, compare_of,
> +						       remote);
>  			of_node_put(remote);
>  		}
>  		of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index 3d4f56df8359..a0e0764a6269 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -15,6 +15,7 @@
>   */
>  
>  #include <linux/component.h>
> +#include <linux/of_component.h>
>  #include <linux/of_platform.h>
>  
>  #include "etnaviv_drv.h"
> @@ -606,13 +607,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);
> @@ -635,8 +629,7 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>  			if (!core_node)
>  				break;
>  
> -			component_match_add(&pdev->dev, &match, compare_of,
> -					    core_node);
> +			component_match_add_of(&pdev->dev, &match, core_node);
>  			of_node_put(core_node);
>  		}
>  	} else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 9c654092ef78..5293aa775c5a 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -800,11 +800,6 @@ static const struct dev_pm_ops msm_pm_ops = {
>   * 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;
> -}
> -
>  static int add_components(struct device *dev, struct component_match **matchptr,
>  		const char *name)
>  {
> @@ -818,7 +813,8 @@ static int add_components(struct device *dev, struct component_match **matchptr,
>  		if (!node)
>  			break;
>  
> -		component_match_add(dev, matchptr, compare_of, node);
> +		component_match_add_of(dev, matchptr, node);
> +		of_node_put(node);
>  	}
>  
>  	return 0;
> diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
> index 5b2963f32291..66dafecaf115 100644
> --- a/drivers/gpu/drm/msm/msm_drv.h
> +++ b/drivers/gpu/drm/msm/msm_drv.h
> @@ -30,6 +30,7 @@
>  #include <linux/list.h>
>  #include <linux/iommu.h>
>  #include <linux/types.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  #include <linux/of_device.h>
>  #include <asm/sizes.h>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index a409d1f703cb..84c50f6770c3 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -22,6 +22,7 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  #include <linux/component.h>
>  
> @@ -414,13 +415,6 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
>  				rockchip_drm_sys_resume)
>  };
>  
> -static int compare_of(struct device *dev, void *data)
> -{
> -	struct device_node *np = data;
> -
> -	return dev->of_node == np;
> -}
> -
>  static void rockchip_add_endpoints(struct device *dev,
>  				   struct component_match **match,
>  				   struct device_node *port)
> @@ -439,7 +433,7 @@ static void rockchip_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		component_match_add_of(dev, match, remote);
>  		of_node_put(remote);
>  	}
>  }
> @@ -518,7 +512,7 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>  			is_support_iommu = false;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		component_match_add_of(dev, &match, port->parent);
>  		of_node_put(port);
>  	}
>  
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..aeb2787c9bd4 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -10,6 +10,7 @@
>  #include <linux/debugfs.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/of_component.h>
>  #include <linux/of_platform.h>
>  
>  #include <drm/drm_atomic.h>
> @@ -341,11 +342,6 @@ static 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_bind(struct device *dev)
>  {
>  	return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev)
>  	child_np = of_get_next_available_child(node, NULL);
>  
>  	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		component_match_add_of(dev, &match, child_np);
>  		child_np = of_get_next_available_child(node, child_np);
>  	}
>  
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 03acb4f99982..1b3fd9fa4bef 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -9,6 +9,7 @@
>   */
>  
>  #include <linux/component.h>
> +#include <linux/of_component.h>
>  #include <linux/of_graph.h>
>  
>  #include "tilcdc_drv.h"
> @@ -130,11 +131,6 @@ void tilcdc_remove_external_encoders(struct drm_device *dev)
>  						 priv->connector_funcs[i]);
>  }
>  
> -static int dev_match_of(struct device *dev, void *data)
> -{
> -	return dev->of_node == data;
> -}
> -
>  int tilcdc_get_external_components(struct device *dev,
>  				   struct component_match **match)
>  {
> @@ -152,7 +148,7 @@ int tilcdc_get_external_components(struct device *dev,
>  
>  		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>  		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> +			component_match_add_of(dev, match, node);
>  		of_node_put(node);
>  		count++;
>  	}
> -- 
> 2.1.0
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ?\_(?)_/?

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

* Re: [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()
  2016-06-03 14:21       ` Russell King
@ 2016-06-07 14:26           ` Vincent ABRIOU
  -1 siblings, 0 replies; 56+ messages in thread
From: Vincent ABRIOU @ 2016-06-07 14:26 UTC (permalink / raw)
  To: Russell King, devicetree-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
  Cc: Heiko Stuebner, David Airlie, Liviu Dudau, Rob Clark,
	Christian Gmeiner, Benjamin Gaignard, Lucas Stach,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Mark Yao



On 06/03/2016 04:21 PM, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>
> ---
>   drivers/gpu/drm/arm/hdlcd_drv.c             |  9 +++------
>   drivers/gpu/drm/armada/armada_drv.c         |  8 ++------
>   drivers/gpu/drm/drm_of.c                    |  6 ++++--
>   drivers/gpu/drm/etnaviv/etnaviv_drv.c       | 11 ++---------
>   drivers/gpu/drm/msm/msm_drv.c               |  8 ++------
>   drivers/gpu/drm/msm/msm_drv.h               |  1 +
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++---------
>   drivers/gpu/drm/sti/sti_drv.c               |  9 ++-------
>   drivers/gpu/drm/tilcdc/tilcdc_external.c    |  8 ++------
>   9 files changed, 21 insertions(+), 51 deletions(-)
>
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..aeb2787c9bd4 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -10,6 +10,7 @@
>   #include <linux/debugfs.h>
>   #include <linux/kernel.h>
>   #include <linux/module.h>
> +#include <linux/of_component.h>
>   #include <linux/of_platform.h>
>
>   #include <drm/drm_atomic.h>
> @@ -341,11 +342,6 @@ static 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_bind(struct device *dev)
>   {
>   	return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev)
>   	child_np = of_get_next_available_child(node, NULL);
>
>   	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		component_match_add_of(dev, &match, child_np);
>   		child_np = of_get_next_available_child(node, child_np);
>   	}
>

Hi Russel,

Ok for the sti driver.

Acked-by: Vincent Abriou <vincent.abriou-qxv4g6HH51o@public.gmane.org>

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

* [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release()
@ 2016-06-07 14:26           ` Vincent ABRIOU
  0 siblings, 0 replies; 56+ messages in thread
From: Vincent ABRIOU @ 2016-06-07 14:26 UTC (permalink / raw)
  To: linux-arm-kernel



On 06/03/2016 04:21 PM, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>   drivers/gpu/drm/arm/hdlcd_drv.c             |  9 +++------
>   drivers/gpu/drm/armada/armada_drv.c         |  8 ++------
>   drivers/gpu/drm/drm_of.c                    |  6 ++++--
>   drivers/gpu/drm/etnaviv/etnaviv_drv.c       | 11 ++---------
>   drivers/gpu/drm/msm/msm_drv.c               |  8 ++------
>   drivers/gpu/drm/msm/msm_drv.h               |  1 +
>   drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 12 +++---------
>   drivers/gpu/drm/sti/sti_drv.c               |  9 ++-------
>   drivers/gpu/drm/tilcdc/tilcdc_external.c    |  8 ++------
>   9 files changed, 21 insertions(+), 51 deletions(-)
>
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 872495e72294..aeb2787c9bd4 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -10,6 +10,7 @@
>   #include <linux/debugfs.h>
>   #include <linux/kernel.h>
>   #include <linux/module.h>
> +#include <linux/of_component.h>
>   #include <linux/of_platform.h>
>
>   #include <drm/drm_atomic.h>
> @@ -341,11 +342,6 @@ static 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_bind(struct device *dev)
>   {
>   	return drm_platform_init(&sti_driver, to_platform_device(dev));
> @@ -375,8 +371,7 @@ static int sti_platform_probe(struct platform_device *pdev)
>   	child_np = of_get_next_available_child(node, NULL);
>
>   	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		component_match_add_of(dev, &match, child_np);
>   		child_np = of_get_next_available_child(node, child_np);
>   	}
>

Hi Russel,

Ok for the sti driver.

Acked-by: Vincent Abriou <vincent.abriou@st.com>

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

* Re: [PATCH v2 3/3] iommu: convert DT component matching to component_match_add_release()
  2016-06-03 14:21       ` Russell King
@ 2016-06-15 13:31         ` Joerg Roedel
  -1 siblings, 0 replies; 56+ messages in thread
From: Joerg Roedel @ 2016-06-15 13:31 UTC (permalink / raw)
  To: Russell King
  Cc: devicetree, dri-devel, linux-arm-kernel, linux-arm-msm,
	linux-mediatek, linux-rockchip, Matthias Brugger, iommu

On Fri, Jun 03, 2016 at 03:21:30PM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/iommu/mtk_iommu.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)

Applied, thanks.

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

* [PATCH v2 3/3] iommu: convert DT component matching to component_match_add_release()
@ 2016-06-15 13:31         ` Joerg Roedel
  0 siblings, 0 replies; 56+ messages in thread
From: Joerg Roedel @ 2016-06-15 13:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 03, 2016 at 03:21:30PM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/iommu/mtk_iommu.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)

Applied, thanks.

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-10-19 10:28 ` Russell King
@ 2016-10-25 16:44   ` Sean Paul
  -1 siblings, 0 replies; 56+ messages in thread
From: Sean Paul @ 2016-10-25 16:44 UTC (permalink / raw)
  To: Russell King
  Cc: Liviu Dudau, dri-devel, Chen-Yu Tsai, Xinliang Liu,
	linux-rockchip, Tomi Valkeinen, Mali DP Maintainers, Chen Feng,
	linux-arm-msm, Jyri Sarha, linux-mediatek, Matthias Brugger,
	Vincent Abriou, Linux ARM Kernel, Maxime Ripard, freedreno

On Wed, Oct 19, 2016 at 6:28 AM, Russell King
<rmk+kernel@armlinux.org.uk> wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Applied to drm-misc, thanks!

Sean

> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.
>
>  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>  include/drm/drm_of.h                            | 12 +++++++++++
>  13 files changed, 73 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>                 return -EAGAIN;
>         }
>
> -       component_match_add(&pdev->dev, &match, compare_dev, port);
> +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> +       of_node_put(port);
>
>         return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>                                                match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>                 return -EAGAIN;
>         }
>
> -       component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> +       drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> +                                  port);
> +       of_node_put(port);
>         return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>                                                match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, match, compare_of, remote);
> +               drm_of_component_match_add(dev, match, compare_of, remote);
>                 of_node_put(remote);
>         }
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +       of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +                               struct component_match **matchptr,
> +                               int (*compare)(struct device *, void *),
> +                               struct device_node *node)
> +{
> +       of_node_get(node);
> +       component_match_add_release(master, matchptr, drm_release_of,
> +                                   compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, &match, compare_of, port);
> +               drm_of_component_match_add(dev, &match, compare_of, port);
>                 of_node_put(port);
>         }
>
> @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>                                 continue;
>                         }
>
> -                       component_match_add(dev, &match, compare_of, remote);
> +                       drm_of_component_match_add(dev, &match, compare_of,
> +                                                  remote);
>                         of_node_put(remote);
>                 }
>                 of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index aa687669e22b..0dee6acbd880 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -16,6 +16,7 @@
>
>  #include <linux/component.h>
>  #include <linux/of_platform.h>
> +#include <drm/drm_of.h>
>
>  #include "etnaviv_drv.h"
>  #include "etnaviv_gpu.h"
> @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>                         if (!core_node)
>                                 break;
>
> -                       component_match_add(&pdev->dev, &match, compare_of,
> -                                           core_node);
> +                       drm_of_component_match_add(&pdev->dev, &match,
> +                                                  compare_of, core_node);
>                         of_node_put(core_node);
>                 }
>         } else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 90377a609c98..e88fde18c946 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -24,6 +24,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "kirin_drm_drv.h"
>
> @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>                 DRM_ERROR("no valid endpoint node\n");
>                 return ERR_PTR(-ENODEV);
>         }
> -       of_node_put(endpoint);
>
>         remote = of_graph_get_remote_port_parent(endpoint);
> +       of_node_put(endpoint);
>         if (!remote) {
>                 DRM_ERROR("no valid remote node\n");
>                 return ERR_PTR(-ENODEV);
>         }
> -       of_node_put(remote);
>
>         if (!of_device_is_available(remote)) {
>                 DRM_ERROR("not available for remote node\n");
> @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>         if (IS_ERR(remote))
>                 return PTR_ERR(remote);
>
> -       component_match_add(dev, &match, compare_of, remote);
> +       drm_of_component_match_add(dev, &match, compare_of, remote);
> +       of_node_put(remote);
>
>         return component_master_add_with_match(dev, &kirin_drm_ops, match);
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cf83f6507ec8..9c5430fb82a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
>  #include <linux/of_address.h>
> @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>                     comp_type == MTK_DPI) {
>                         dev_info(dev, "Adding component match for %s\n",
>                                  node->full_name);
> -                       component_match_add(dev, &match, compare_of, node);
> +                       drm_of_component_match_add(dev, &match, compare_of,
> +                                                  node);
>                 } else {
>                         struct mtk_ddp_comp *comp;
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index fb5c0b0a7594..84d38eaea585 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include <drm/drm_of.h>
> +
>  #include "msm_drv.h"
>  #include "msm_debugfs.h"
>  #include "msm_fence.h"
> @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>                         continue;
>                 }
>
> -               component_match_add(master_dev, matchptr, compare_of, intf);
> -
> +               drm_of_component_match_add(master_dev, matchptr, compare_of,
> +                                          intf);
>                 of_node_put(intf);
>                 of_node_put(ep_node);
>         }
> @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>                 put_device(mdp_dev);
>
>                 /* add the MDP component itself */
> -               component_match_add(dev, matchptr, compare_of,
> -                                   mdp_dev->of_node);
> +               drm_of_component_match_add(dev, matchptr, compare_of,
> +                                          mdp_dev->of_node);
>         } else {
>                 /* MDP4 */
>                 mdp_dev = dev;
> @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>         if (!np)
>                 return 0;
>
> -       component_match_add(dev, matchptr, compare_of, np);
> +       drm_of_component_match_add(dev, matchptr, compare_of, np);
>
>         of_node_put(np);
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 8c8cbe837e61..6fe161192bb4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -20,6 +20,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, match, compare_of, remote);
> +               drm_of_component_match_add(dev, match, compare_of, remote);
>                 of_node_put(remote);
>         }
>  }
> @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>                 }
>
>                 of_node_put(iommu);
> -               component_match_add(dev, &match, compare_of, port->parent);
> +               drm_of_component_match_add(dev, &match, compare_of,
> +                                          port->parent);
>                 of_node_put(port);
>         }
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 2784919a7366..5e819876e642 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -17,6 +17,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "sti_crtc.h"
>  #include "sti_drv.h"
> @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>         child_np = of_get_next_available_child(node, NULL);
>
>         while (child_np) {
> -               component_match_add(dev, &match, compare_of, child_np);
> -               of_node_put(child_np);
> +               drm_of_component_match_add(dev, &match, compare_of,
> +                                          child_np);
>                 child_np = of_get_next_available_child(node, child_np);
>         }
>
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 0da9862ad8ed..b3c4ad605e81 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "sun4i_crtc.h"
>  #include "sun4i_drv.h"
> @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>                 /* Add current component */
>                 DRM_DEBUG_DRIVER("Adding component %s\n",
>                                  of_node_full_name(node));
> -               component_match_add(dev, match, compare_of, node);
> +               drm_of_component_match_add(dev, match, compare_of, node);
>                 count++;
>         }
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 68e895021005..06a4c584f3cb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -10,6 +10,7 @@
>
>  #include <linux/component.h>
>  #include <linux/of_graph.h>
> +#include <drm/drm_of.h>
>
>  #include "tilcdc_drv.h"
>  #include "tilcdc_external.h"
> @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>
>                 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>                 if (match)
> -                       component_match_add(dev, match, dev_match_of, node);
> +                       drm_of_component_match_add(dev, match, dev_match_of,
> +                                                  node);
>                 of_node_put(node);
>                 count++;
>         }
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 3fd87b386ed7..d6b4c5587bbe 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -4,6 +4,7 @@
>  #include <linux/of_graph.h>
>
>  struct component_master_ops;
> +struct component_match;
>  struct device;
>  struct drm_device;
>  struct drm_encoder;
> @@ -12,6 +13,10 @@ struct device_node;
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>                                            struct device_node *port);
> +extern void drm_of_component_match_add(struct device *master,
> +                                      struct component_match **matchptr,
> +                                      int (*compare)(struct device *, void *),
> +                                      struct device_node *node);
>  extern int drm_of_component_probe(struct device *dev,
>                                   int (*compare_of)(struct device *, void *),
>                                   const struct component_master_ops *m_ops);
> @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>         return 0;
>  }
>
> +static void drm_of_component_match_add(struct device *master,
> +                                      struct component_match **matchptr,
> +                                      int (*compare)(struct device *, void *),
> +                                      struct device_node *node)
> +{
> +}
> +
>  static inline int
>  drm_of_component_probe(struct device *dev,
>                        int (*compare_of)(struct device *, void *),
> --
> 2.1.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-25 16:44   ` Sean Paul
  0 siblings, 0 replies; 56+ messages in thread
From: Sean Paul @ 2016-10-25 16:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 19, 2016 at 6:28 AM, Russell King
<rmk+kernel@armlinux.org.uk> wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Applied to drm-misc, thanks!

Sean

> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.
>
>  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>  include/drm/drm_of.h                            | 12 +++++++++++
>  13 files changed, 73 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>                 return -EAGAIN;
>         }
>
> -       component_match_add(&pdev->dev, &match, compare_dev, port);
> +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> +       of_node_put(port);
>
>         return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>                                                match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>                 return -EAGAIN;
>         }
>
> -       component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> +       drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> +                                  port);
> +       of_node_put(port);
>         return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>                                                match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, match, compare_of, remote);
> +               drm_of_component_match_add(dev, match, compare_of, remote);
>                 of_node_put(remote);
>         }
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +       of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +                               struct component_match **matchptr,
> +                               int (*compare)(struct device *, void *),
> +                               struct device_node *node)
> +{
> +       of_node_get(node);
> +       component_match_add_release(master, matchptr, drm_release_of,
> +                                   compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, &match, compare_of, port);
> +               drm_of_component_match_add(dev, &match, compare_of, port);
>                 of_node_put(port);
>         }
>
> @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>                                 continue;
>                         }
>
> -                       component_match_add(dev, &match, compare_of, remote);
> +                       drm_of_component_match_add(dev, &match, compare_of,
> +                                                  remote);
>                         of_node_put(remote);
>                 }
>                 of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index aa687669e22b..0dee6acbd880 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -16,6 +16,7 @@
>
>  #include <linux/component.h>
>  #include <linux/of_platform.h>
> +#include <drm/drm_of.h>
>
>  #include "etnaviv_drv.h"
>  #include "etnaviv_gpu.h"
> @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>                         if (!core_node)
>                                 break;
>
> -                       component_match_add(&pdev->dev, &match, compare_of,
> -                                           core_node);
> +                       drm_of_component_match_add(&pdev->dev, &match,
> +                                                  compare_of, core_node);
>                         of_node_put(core_node);
>                 }
>         } else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 90377a609c98..e88fde18c946 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -24,6 +24,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "kirin_drm_drv.h"
>
> @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>                 DRM_ERROR("no valid endpoint node\n");
>                 return ERR_PTR(-ENODEV);
>         }
> -       of_node_put(endpoint);
>
>         remote = of_graph_get_remote_port_parent(endpoint);
> +       of_node_put(endpoint);
>         if (!remote) {
>                 DRM_ERROR("no valid remote node\n");
>                 return ERR_PTR(-ENODEV);
>         }
> -       of_node_put(remote);
>
>         if (!of_device_is_available(remote)) {
>                 DRM_ERROR("not available for remote node\n");
> @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>         if (IS_ERR(remote))
>                 return PTR_ERR(remote);
>
> -       component_match_add(dev, &match, compare_of, remote);
> +       drm_of_component_match_add(dev, &match, compare_of, remote);
> +       of_node_put(remote);
>
>         return component_master_add_with_match(dev, &kirin_drm_ops, match);
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cf83f6507ec8..9c5430fb82a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
>  #include <linux/of_address.h>
> @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>                     comp_type == MTK_DPI) {
>                         dev_info(dev, "Adding component match for %s\n",
>                                  node->full_name);
> -                       component_match_add(dev, &match, compare_of, node);
> +                       drm_of_component_match_add(dev, &match, compare_of,
> +                                                  node);
>                 } else {
>                         struct mtk_ddp_comp *comp;
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index fb5c0b0a7594..84d38eaea585 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include <drm/drm_of.h>
> +
>  #include "msm_drv.h"
>  #include "msm_debugfs.h"
>  #include "msm_fence.h"
> @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>                         continue;
>                 }
>
> -               component_match_add(master_dev, matchptr, compare_of, intf);
> -
> +               drm_of_component_match_add(master_dev, matchptr, compare_of,
> +                                          intf);
>                 of_node_put(intf);
>                 of_node_put(ep_node);
>         }
> @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>                 put_device(mdp_dev);
>
>                 /* add the MDP component itself */
> -               component_match_add(dev, matchptr, compare_of,
> -                                   mdp_dev->of_node);
> +               drm_of_component_match_add(dev, matchptr, compare_of,
> +                                          mdp_dev->of_node);
>         } else {
>                 /* MDP4 */
>                 mdp_dev = dev;
> @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>         if (!np)
>                 return 0;
>
> -       component_match_add(dev, matchptr, compare_of, np);
> +       drm_of_component_match_add(dev, matchptr, compare_of, np);
>
>         of_node_put(np);
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 8c8cbe837e61..6fe161192bb4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -20,6 +20,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, match, compare_of, remote);
> +               drm_of_component_match_add(dev, match, compare_of, remote);
>                 of_node_put(remote);
>         }
>  }
> @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>                 }
>
>                 of_node_put(iommu);
> -               component_match_add(dev, &match, compare_of, port->parent);
> +               drm_of_component_match_add(dev, &match, compare_of,
> +                                          port->parent);
>                 of_node_put(port);
>         }
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 2784919a7366..5e819876e642 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -17,6 +17,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "sti_crtc.h"
>  #include "sti_drv.h"
> @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>         child_np = of_get_next_available_child(node, NULL);
>
>         while (child_np) {
> -               component_match_add(dev, &match, compare_of, child_np);
> -               of_node_put(child_np);
> +               drm_of_component_match_add(dev, &match, compare_of,
> +                                          child_np);
>                 child_np = of_get_next_available_child(node, child_np);
>         }
>
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 0da9862ad8ed..b3c4ad605e81 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "sun4i_crtc.h"
>  #include "sun4i_drv.h"
> @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>                 /* Add current component */
>                 DRM_DEBUG_DRIVER("Adding component %s\n",
>                                  of_node_full_name(node));
> -               component_match_add(dev, match, compare_of, node);
> +               drm_of_component_match_add(dev, match, compare_of, node);
>                 count++;
>         }
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 68e895021005..06a4c584f3cb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -10,6 +10,7 @@
>
>  #include <linux/component.h>
>  #include <linux/of_graph.h>
> +#include <drm/drm_of.h>
>
>  #include "tilcdc_drv.h"
>  #include "tilcdc_external.h"
> @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>
>                 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>                 if (match)
> -                       component_match_add(dev, match, dev_match_of, node);
> +                       drm_of_component_match_add(dev, match, dev_match_of,
> +                                                  node);
>                 of_node_put(node);
>                 count++;
>         }
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 3fd87b386ed7..d6b4c5587bbe 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -4,6 +4,7 @@
>  #include <linux/of_graph.h>
>
>  struct component_master_ops;
> +struct component_match;
>  struct device;
>  struct drm_device;
>  struct drm_encoder;
> @@ -12,6 +13,10 @@ struct device_node;
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>                                            struct device_node *port);
> +extern void drm_of_component_match_add(struct device *master,
> +                                      struct component_match **matchptr,
> +                                      int (*compare)(struct device *, void *),
> +                                      struct device_node *node);
>  extern int drm_of_component_probe(struct device *dev,
>                                   int (*compare_of)(struct device *, void *),
>                                   const struct component_master_ops *m_ops);
> @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>         return 0;
>  }
>
> +static void drm_of_component_match_add(struct device *master,
> +                                      struct component_match **matchptr,
> +                                      int (*compare)(struct device *, void *),
> +                                      struct device_node *node)
> +{
> +}
> +
>  static inline int
>  drm_of_component_probe(struct device *dev,
>                        int (*compare_of)(struct device *, void *),
> --
> 2.1.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-10-19 10:28 ` Russell King
@ 2016-10-24 13:21   ` Jyri Sarha
  -1 siblings, 0 replies; 56+ messages in thread
From: Jyri Sarha @ 2016-10-24 13:21 UTC (permalink / raw)
  To: Russell King, dri-devel, David Airlie
  Cc: Liviu Dudau, Chen-Yu Tsai, Xinliang Liu, linux-rockchip,
	Tomi Valkeinen, Mali DP Maintainers, linux-arm-msm, Chen Feng,
	linux-mediatek, Matthias Brugger, Vincent Abriou,
	linux-arm-kernel, Maxime Ripard, freedreno

On 10/19/16 13:28, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Acked-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Jyri Sarha <jsarha@ti.com>

However, the patch description is a bit brief. It took me this mail
thread to fully understand why simple comparison of pointer values may
cause problems if the of_node ref count goes to zero.

BR,
Jyri

> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.
> 
>  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>  include/drm/drm_of.h                            | 12 +++++++++++
>  13 files changed, 73 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> +	of_node_put(port);
>  
>  	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  					       match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> +	drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> +				   port);
> +	of_node_put(port);
>  	return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>  					       match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		drm_of_component_match_add(dev, match, compare_of, remote);
>  		of_node_put(remote);
>  	}
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>  
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>  
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +				struct component_match **matchptr,
> +				int (*compare)(struct device *, void *),
> +				struct device_node *node)
> +{
> +	of_node_get(node);
> +	component_match_add_release(master, matchptr, drm_release_of,
> +				    compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port);
> +		drm_of_component_match_add(dev, &match, compare_of, port);
>  		of_node_put(port);
>  	}
>  
> @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>  				continue;
>  			}
>  
> -			component_match_add(dev, &match, compare_of, remote);
> +			drm_of_component_match_add(dev, &match, compare_of,
> +						   remote);
>  			of_node_put(remote);
>  		}
>  		of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index aa687669e22b..0dee6acbd880 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -16,6 +16,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/of_platform.h>
> +#include <drm/drm_of.h>
>  
>  #include "etnaviv_drv.h"
>  #include "etnaviv_gpu.h"
> @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>  			if (!core_node)
>  				break;
>  
> -			component_match_add(&pdev->dev, &match, compare_of,
> -					    core_node);
> +			drm_of_component_match_add(&pdev->dev, &match,
> +						   compare_of, core_node);
>  			of_node_put(core_node);
>  		}
>  	} else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 90377a609c98..e88fde18c946 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -24,6 +24,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "kirin_drm_drv.h"
>  
> @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>  		DRM_ERROR("no valid endpoint node\n");
>  		return ERR_PTR(-ENODEV);
>  	}
> -	of_node_put(endpoint);
>  
>  	remote = of_graph_get_remote_port_parent(endpoint);
> +	of_node_put(endpoint);
>  	if (!remote) {
>  		DRM_ERROR("no valid remote node\n");
>  		return ERR_PTR(-ENODEV);
>  	}
> -	of_node_put(remote);
>  
>  	if (!of_device_is_available(remote)) {
>  		DRM_ERROR("not available for remote node\n");
> @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>  	if (IS_ERR(remote))
>  		return PTR_ERR(remote);
>  
> -	component_match_add(dev, &match, compare_of, remote);
> +	drm_of_component_match_add(dev, &match, compare_of, remote);
> +	of_node_put(remote);
>  
>  	return component_master_add_with_match(dev, &kirin_drm_ops, match);
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cf83f6507ec8..9c5430fb82a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
>  #include <linux/of_address.h>
> @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>  		    comp_type == MTK_DPI) {
>  			dev_info(dev, "Adding component match for %s\n",
>  				 node->full_name);
> -			component_match_add(dev, &match, compare_of, node);
> +			drm_of_component_match_add(dev, &match, compare_of,
> +						   node);
>  		} else {
>  			struct mtk_ddp_comp *comp;
>  
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index fb5c0b0a7594..84d38eaea585 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> +#include <drm/drm_of.h>
> +
>  #include "msm_drv.h"
>  #include "msm_debugfs.h"
>  #include "msm_fence.h"
> @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>  			continue;
>  		}
>  
> -		component_match_add(master_dev, matchptr, compare_of, intf);
> -
> +		drm_of_component_match_add(master_dev, matchptr, compare_of,
> +					   intf);
>  		of_node_put(intf);
>  		of_node_put(ep_node);
>  	}
> @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>  		put_device(mdp_dev);
>  
>  		/* add the MDP component itself */
> -		component_match_add(dev, matchptr, compare_of,
> -				    mdp_dev->of_node);
> +		drm_of_component_match_add(dev, matchptr, compare_of,
> +					   mdp_dev->of_node);
>  	} else {
>  		/* MDP4 */
>  		mdp_dev = dev;
> @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>  	if (!np)
>  		return 0;
>  
> -	component_match_add(dev, matchptr, compare_of, np);
> +	drm_of_component_match_add(dev, matchptr, compare_of, np);
>  
>  	of_node_put(np);
>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 8c8cbe837e61..6fe161192bb4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -20,6 +20,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		drm_of_component_match_add(dev, match, compare_of, remote);
>  		of_node_put(remote);
>  	}
>  }
> @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>  		}
>  
>  		of_node_put(iommu);
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		drm_of_component_match_add(dev, &match, compare_of,
> +					   port->parent);
>  		of_node_put(port);
>  	}
>  
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 2784919a7366..5e819876e642 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -17,6 +17,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "sti_crtc.h"
>  #include "sti_drv.h"
> @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>  	child_np = of_get_next_available_child(node, NULL);
>  
>  	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		drm_of_component_match_add(dev, &match, compare_of,
> +					   child_np);
>  		child_np = of_get_next_available_child(node, child_np);
>  	}
>  
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 0da9862ad8ed..b3c4ad605e81 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "sun4i_crtc.h"
>  #include "sun4i_drv.h"
> @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>  		/* Add current component */
>  		DRM_DEBUG_DRIVER("Adding component %s\n",
>  				 of_node_full_name(node));
> -		component_match_add(dev, match, compare_of, node);
> +		drm_of_component_match_add(dev, match, compare_of, node);
>  		count++;
>  	}
>  
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 68e895021005..06a4c584f3cb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -10,6 +10,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/of_graph.h>
> +#include <drm/drm_of.h>
>  
>  #include "tilcdc_drv.h"
>  #include "tilcdc_external.h"
> @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>  
>  		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>  		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> +			drm_of_component_match_add(dev, match, dev_match_of,
> +						   node);
>  		of_node_put(node);
>  		count++;
>  	}
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 3fd87b386ed7..d6b4c5587bbe 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -4,6 +4,7 @@
>  #include <linux/of_graph.h>
>  
>  struct component_master_ops;
> +struct component_match;
>  struct device;
>  struct drm_device;
>  struct drm_encoder;
> @@ -12,6 +13,10 @@ struct device_node;
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  					   struct device_node *port);
> +extern void drm_of_component_match_add(struct device *master,
> +				       struct component_match **matchptr,
> +				       int (*compare)(struct device *, void *),
> +				       struct device_node *node);
>  extern int drm_of_component_probe(struct device *dev,
>  				  int (*compare_of)(struct device *, void *),
>  				  const struct component_master_ops *m_ops);
> @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  	return 0;
>  }
>  
> +static void drm_of_component_match_add(struct device *master,
> +				       struct component_match **matchptr,
> +				       int (*compare)(struct device *, void *),
> +				       struct device_node *node)
> +{
> +}
> +
>  static inline int
>  drm_of_component_probe(struct device *dev,
>  		       int (*compare_of)(struct device *, void *),
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-24 13:21   ` Jyri Sarha
  0 siblings, 0 replies; 56+ messages in thread
From: Jyri Sarha @ 2016-10-24 13:21 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/19/16 13:28, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Acked-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Jyri Sarha <jsarha@ti.com>

However, the patch description is a bit brief. It took me this mail
thread to fully understand why simple comparison of pointer values may
cause problems if the of_node ref count goes to zero.

BR,
Jyri

> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.
> 
>  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>  include/drm/drm_of.h                            | 12 +++++++++++
>  13 files changed, 73 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> +	of_node_put(port);
>  
>  	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  					       match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> +	drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> +				   port);
> +	of_node_put(port);
>  	return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>  					       match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		drm_of_component_match_add(dev, match, compare_of, remote);
>  		of_node_put(remote);
>  	}
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>  
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>  
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +				struct component_match **matchptr,
> +				int (*compare)(struct device *, void *),
> +				struct device_node *node)
> +{
> +	of_node_get(node);
> +	component_match_add_release(master, matchptr, drm_release_of,
> +				    compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port);
> +		drm_of_component_match_add(dev, &match, compare_of, port);
>  		of_node_put(port);
>  	}
>  
> @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>  				continue;
>  			}
>  
> -			component_match_add(dev, &match, compare_of, remote);
> +			drm_of_component_match_add(dev, &match, compare_of,
> +						   remote);
>  			of_node_put(remote);
>  		}
>  		of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index aa687669e22b..0dee6acbd880 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -16,6 +16,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/of_platform.h>
> +#include <drm/drm_of.h>
>  
>  #include "etnaviv_drv.h"
>  #include "etnaviv_gpu.h"
> @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>  			if (!core_node)
>  				break;
>  
> -			component_match_add(&pdev->dev, &match, compare_of,
> -					    core_node);
> +			drm_of_component_match_add(&pdev->dev, &match,
> +						   compare_of, core_node);
>  			of_node_put(core_node);
>  		}
>  	} else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 90377a609c98..e88fde18c946 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -24,6 +24,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "kirin_drm_drv.h"
>  
> @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>  		DRM_ERROR("no valid endpoint node\n");
>  		return ERR_PTR(-ENODEV);
>  	}
> -	of_node_put(endpoint);
>  
>  	remote = of_graph_get_remote_port_parent(endpoint);
> +	of_node_put(endpoint);
>  	if (!remote) {
>  		DRM_ERROR("no valid remote node\n");
>  		return ERR_PTR(-ENODEV);
>  	}
> -	of_node_put(remote);
>  
>  	if (!of_device_is_available(remote)) {
>  		DRM_ERROR("not available for remote node\n");
> @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>  	if (IS_ERR(remote))
>  		return PTR_ERR(remote);
>  
> -	component_match_add(dev, &match, compare_of, remote);
> +	drm_of_component_match_add(dev, &match, compare_of, remote);
> +	of_node_put(remote);
>  
>  	return component_master_add_with_match(dev, &kirin_drm_ops, match);
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cf83f6507ec8..9c5430fb82a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
>  #include <linux/of_address.h>
> @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>  		    comp_type == MTK_DPI) {
>  			dev_info(dev, "Adding component match for %s\n",
>  				 node->full_name);
> -			component_match_add(dev, &match, compare_of, node);
> +			drm_of_component_match_add(dev, &match, compare_of,
> +						   node);
>  		} else {
>  			struct mtk_ddp_comp *comp;
>  
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index fb5c0b0a7594..84d38eaea585 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> +#include <drm/drm_of.h>
> +
>  #include "msm_drv.h"
>  #include "msm_debugfs.h"
>  #include "msm_fence.h"
> @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>  			continue;
>  		}
>  
> -		component_match_add(master_dev, matchptr, compare_of, intf);
> -
> +		drm_of_component_match_add(master_dev, matchptr, compare_of,
> +					   intf);
>  		of_node_put(intf);
>  		of_node_put(ep_node);
>  	}
> @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>  		put_device(mdp_dev);
>  
>  		/* add the MDP component itself */
> -		component_match_add(dev, matchptr, compare_of,
> -				    mdp_dev->of_node);
> +		drm_of_component_match_add(dev, matchptr, compare_of,
> +					   mdp_dev->of_node);
>  	} else {
>  		/* MDP4 */
>  		mdp_dev = dev;
> @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>  	if (!np)
>  		return 0;
>  
> -	component_match_add(dev, matchptr, compare_of, np);
> +	drm_of_component_match_add(dev, matchptr, compare_of, np);
>  
>  	of_node_put(np);
>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 8c8cbe837e61..6fe161192bb4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -20,6 +20,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		drm_of_component_match_add(dev, match, compare_of, remote);
>  		of_node_put(remote);
>  	}
>  }
> @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>  		}
>  
>  		of_node_put(iommu);
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		drm_of_component_match_add(dev, &match, compare_of,
> +					   port->parent);
>  		of_node_put(port);
>  	}
>  
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 2784919a7366..5e819876e642 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -17,6 +17,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "sti_crtc.h"
>  #include "sti_drv.h"
> @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>  	child_np = of_get_next_available_child(node, NULL);
>  
>  	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		drm_of_component_match_add(dev, &match, compare_of,
> +					   child_np);
>  		child_np = of_get_next_available_child(node, child_np);
>  	}
>  
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 0da9862ad8ed..b3c4ad605e81 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "sun4i_crtc.h"
>  #include "sun4i_drv.h"
> @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>  		/* Add current component */
>  		DRM_DEBUG_DRIVER("Adding component %s\n",
>  				 of_node_full_name(node));
> -		component_match_add(dev, match, compare_of, node);
> +		drm_of_component_match_add(dev, match, compare_of, node);
>  		count++;
>  	}
>  
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 68e895021005..06a4c584f3cb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -10,6 +10,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/of_graph.h>
> +#include <drm/drm_of.h>
>  
>  #include "tilcdc_drv.h"
>  #include "tilcdc_external.h"
> @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>  
>  		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>  		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> +			drm_of_component_match_add(dev, match, dev_match_of,
> +						   node);
>  		of_node_put(node);
>  		count++;
>  	}
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 3fd87b386ed7..d6b4c5587bbe 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -4,6 +4,7 @@
>  #include <linux/of_graph.h>
>  
>  struct component_master_ops;
> +struct component_match;
>  struct device;
>  struct drm_device;
>  struct drm_encoder;
> @@ -12,6 +13,10 @@ struct device_node;
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  					   struct device_node *port);
> +extern void drm_of_component_match_add(struct device *master,
> +				       struct component_match **matchptr,
> +				       int (*compare)(struct device *, void *),
> +				       struct device_node *node);
>  extern int drm_of_component_probe(struct device *dev,
>  				  int (*compare_of)(struct device *, void *),
>  				  const struct component_master_ops *m_ops);
> @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  	return 0;
>  }
>  
> +static void drm_of_component_match_add(struct device *master,
> +				       struct component_match **matchptr,
> +				       int (*compare)(struct device *, void *),
> +				       struct device_node *node)
> +{
> +}
> +
>  static inline int
>  drm_of_component_probe(struct device *dev,
>  		       int (*compare_of)(struct device *, void *),
> 

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-10-20 23:15       ` Sean Paul
@ 2016-10-21 15:23           ` Russell King - ARM Linux
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-10-21 15:23 UTC (permalink / raw)
  To: Sean Paul
  Cc: Heiko Stuebner, David Airlie, Liviu Dudau, dri-devel,
	Benjamin Gaignard, Chen-Yu Tsai, Xinliang Liu,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Xinwei Kong,
	Tomi Valkeinen, Mali DP Maintainers, linux-arm-msm, CK Hu,
	Chen Feng, Jyri Sarha, Christian Gmeiner,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Matthias Brugger, Vincent Abriou, Linux ARM Kernel, Mark Yao,
	Rob Clark, Philipp

On Thu, Oct 20, 2016 at 07:15:56PM -0400, Sean Paul wrote:
> On Thu, Oct 20, 2016 at 5:50 PM, Russell King - ARM Linux
> <linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org> wrote:
> > On Thu, Oct 20, 2016 at 04:39:04PM -0400, Sean Paul wrote:
> >> On Wed, Oct 19, 2016 at 6:28 AM, Russell King
> >> <rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org> wrote:
> >> > Convert DT component matching to use component_match_add_release().
> >> >
> >> > Signed-off-by: Russell King <rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>
> >> > ---
> >> > Can we please get this patch from May merged into the drm-misc or
> >> > whatever trees so that we don't end up with conflicts?  I've no idea
> >> > who looks after drm-misc, as they have _still_ failed to add
> >> > themselves to MAINTAINERS.
> >>
> >> I think Daniel explained pretty clearly why this wasn't happening in
> >> the previous thread.
> >>
> >> Next time you send a v2, can you please mark it as such and include a
> >> "Changes in v2" section?
> >
> > Why - nothing's changed other than a rebase onto 4.9-rc1.  This isn't
> > a "I've changed it in XYZ way, so here's a new copy".
> 
> 
> Changes in v2: None
> 
> Is still useful since:
> a) the diffstat is different from v1, which necessitates me going
> through both versions to see what's changed from the previous reviews
> (only to find out myself that it's been rebased and a function has
> changed names)

Sorry, but I don't track in any fine detail what the changes are
between patches when I bring them forward: I have far too many patches
to do that (I have 300 right now) and I never know whether they're
going to result in a pull request or not.  It means finding some way
to manually attach a change log to each patch I send out, which will
be very time consuming.  I'd rather not send patches out than jump
through hoops like that, especially when the reason is that the
previous version was ignored.

> b) in June, you said you were going to roll a new version with the
> common OF bits extracted. it's nice to know at the outset that this
> has/hasn't happened

Now if you were following the rest of it, rather than just random parts
that suited you, you'd have noticed that I posted the new version, but
that caused more issues, so I publically said I was reverting back to
the original version.

> Also, prefacing the subject with [PATCH v2] or [PATCH RESEND] lets me
> know there is prior history with the change. Reading the previous
> version is helpful to see what reviewer's concerns were, and whether
> they've been addressed.

Yea, I'm very bad at changing the subject line in that way, and I'm
getting worse at it.  Sorry, I try my best, but I can't do better than
that.

> 
> 
> > It's being
> > posted in the hope that someone will finally either comment on it or
> > merge the damn thing, rather than ignoring it was done when it was
> > last posted.
> >
> >> >  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
> >> >  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
> >> >  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
> >> >  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
> >> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
> >> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
> >> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
> >> >  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
> >> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
> >> >  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
> >> >  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
> >> >  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
> >> >  include/drm/drm_of.h                            | 12 +++++++++++
> >> >  13 files changed, 73 insertions(+), 22 deletions(-)
> >> >
> >> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > index fb6a418ce6be..6477d1a65266 100644
> >> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
> >> >                 return -EAGAIN;
> >> >         }
> >> >
> >> > -       component_match_add(&pdev->dev, &match, compare_dev, port);
> >> > +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> >> > +       of_node_put(port);
> >>
> >> There's no mention in your commit message about fixing these node leaks.
> >
> > Isn't that kind-of the whole point of this patch?
> >
> 
> Not according to the commit msg, it isn't.
> 
> You could have just done the of_node_put adds/relocations without
> wrapping component_match_add_release.

No, adding the of_node_put() there without the other changes means that
the OF layer can drop the "port" device node, kfree() it, and reallocate
it as a different device node - which means that we can end up matching
some random other device rather than the intended one.  Hence, it is
_fundamentally_ a part of this patch and isn't an independent change.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-21 15:23           ` Russell King - ARM Linux
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-10-21 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 20, 2016 at 07:15:56PM -0400, Sean Paul wrote:
> On Thu, Oct 20, 2016 at 5:50 PM, Russell King - ARM Linux
> <linux@armlinux.org.uk> wrote:
> > On Thu, Oct 20, 2016 at 04:39:04PM -0400, Sean Paul wrote:
> >> On Wed, Oct 19, 2016 at 6:28 AM, Russell King
> >> <rmk+kernel@armlinux.org.uk> wrote:
> >> > Convert DT component matching to use component_match_add_release().
> >> >
> >> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> >> > ---
> >> > Can we please get this patch from May merged into the drm-misc or
> >> > whatever trees so that we don't end up with conflicts?  I've no idea
> >> > who looks after drm-misc, as they have _still_ failed to add
> >> > themselves to MAINTAINERS.
> >>
> >> I think Daniel explained pretty clearly why this wasn't happening in
> >> the previous thread.
> >>
> >> Next time you send a v2, can you please mark it as such and include a
> >> "Changes in v2" section?
> >
> > Why - nothing's changed other than a rebase onto 4.9-rc1.  This isn't
> > a "I've changed it in XYZ way, so here's a new copy".
> 
> 
> Changes in v2: None
> 
> Is still useful since:
> a) the diffstat is different from v1, which necessitates me going
> through both versions to see what's changed from the previous reviews
> (only to find out myself that it's been rebased and a function has
> changed names)

Sorry, but I don't track in any fine detail what the changes are
between patches when I bring them forward: I have far too many patches
to do that (I have 300 right now) and I never know whether they're
going to result in a pull request or not.  It means finding some way
to manually attach a change log to each patch I send out, which will
be very time consuming.  I'd rather not send patches out than jump
through hoops like that, especially when the reason is that the
previous version was ignored.

> b) in June, you said you were going to roll a new version with the
> common OF bits extracted. it's nice to know at the outset that this
> has/hasn't happened

Now if you were following the rest of it, rather than just random parts
that suited you, you'd have noticed that I posted the new version, but
that caused more issues, so I publically said I was reverting back to
the original version.

> Also, prefacing the subject with [PATCH v2] or [PATCH RESEND] lets me
> know there is prior history with the change. Reading the previous
> version is helpful to see what reviewer's concerns were, and whether
> they've been addressed.

Yea, I'm very bad at changing the subject line in that way, and I'm
getting worse at it.  Sorry, I try my best, but I can't do better than
that.

> 
> 
> > It's being
> > posted in the hope that someone will finally either comment on it or
> > merge the damn thing, rather than ignoring it was done when it was
> > last posted.
> >
> >> >  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
> >> >  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
> >> >  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
> >> >  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
> >> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
> >> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
> >> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
> >> >  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
> >> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
> >> >  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
> >> >  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
> >> >  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
> >> >  include/drm/drm_of.h                            | 12 +++++++++++
> >> >  13 files changed, 73 insertions(+), 22 deletions(-)
> >> >
> >> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > index fb6a418ce6be..6477d1a65266 100644
> >> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> >> > @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
> >> >                 return -EAGAIN;
> >> >         }
> >> >
> >> > -       component_match_add(&pdev->dev, &match, compare_dev, port);
> >> > +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> >> > +       of_node_put(port);
> >>
> >> There's no mention in your commit message about fixing these node leaks.
> >
> > Isn't that kind-of the whole point of this patch?
> >
> 
> Not according to the commit msg, it isn't.
> 
> You could have just done the of_node_put adds/relocations without
> wrapping component_match_add_release.

No, adding the of_node_put() there without the other changes means that
the OF layer can drop the "port" device node, kfree() it, and reallocate
it as a different device node - which means that we can end up matching
some random other device rather than the intended one.  Hence, it is
_fundamentally_ a part of this patch and isn't an independent change.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-10-20 21:50     ` Russell King - ARM Linux
@ 2016-10-20 23:15       ` Sean Paul
  -1 siblings, 0 replies; 56+ messages in thread
From: Sean Paul @ 2016-10-20 23:15 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Liviu Dudau, dri-devel, Chen-Yu Tsai, Xinliang Liu,
	linux-rockchip, Tomi Valkeinen, Mali DP Maintainers, Chen Feng,
	linux-arm-msm, Jyri Sarha, linux-mediatek, Matthias Brugger,
	Vincent Abriou, Linux ARM Kernel, Maxime Ripard, freedreno

On Thu, Oct 20, 2016 at 5:50 PM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Thu, Oct 20, 2016 at 04:39:04PM -0400, Sean Paul wrote:
>> On Wed, Oct 19, 2016 at 6:28 AM, Russell King
>> <rmk+kernel@armlinux.org.uk> wrote:
>> > Convert DT component matching to use component_match_add_release().
>> >
>> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
>> > ---
>> > Can we please get this patch from May merged into the drm-misc or
>> > whatever trees so that we don't end up with conflicts?  I've no idea
>> > who looks after drm-misc, as they have _still_ failed to add
>> > themselves to MAINTAINERS.
>>
>> I think Daniel explained pretty clearly why this wasn't happening in
>> the previous thread.
>>
>> Next time you send a v2, can you please mark it as such and include a
>> "Changes in v2" section?
>
> Why - nothing's changed other than a rebase onto 4.9-rc1.  This isn't
> a "I've changed it in XYZ way, so here's a new copy".


Changes in v2: None

Is still useful since:
a) the diffstat is different from v1, which necessitates me going
through both versions to see what's changed from the previous reviews
(only to find out myself that it's been rebased and a function has
changed names)
b) in June, you said you were going to roll a new version with the
common OF bits extracted. it's nice to know at the outset that this
has/hasn't happened

Also, prefacing the subject with [PATCH v2] or [PATCH RESEND] lets me
know there is prior history with the change. Reading the previous
version is helpful to see what reviewer's concerns were, and whether
they've been addressed.


> It's being
> posted in the hope that someone will finally either comment on it or
> merge the damn thing, rather than ignoring it was done when it was
> last posted.
>
>> >  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>> >  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>> >  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>> >  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>> >  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>> >  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>> >  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>> >  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>> >  include/drm/drm_of.h                            | 12 +++++++++++
>> >  13 files changed, 73 insertions(+), 22 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
>> > index fb6a418ce6be..6477d1a65266 100644
>> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
>> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
>> > @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>> >                 return -EAGAIN;
>> >         }
>> >
>> > -       component_match_add(&pdev->dev, &match, compare_dev, port);
>> > +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
>> > +       of_node_put(port);
>>
>> There's no mention in your commit message about fixing these node leaks.
>
> Isn't that kind-of the whole point of this patch?
>

Not according to the commit msg, it isn't.

You could have just done the of_node_put adds/relocations without
wrapping component_match_add_release.

Sean

>> >
>> >         return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>> >                                                match);
>> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
>> > index 9280358b8f15..9f4739452a25 100644
>> > --- a/drivers/gpu/drm/arm/malidp_drv.c
>> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
>> > @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>> >                 return -EAGAIN;
>> >         }
>> >
>> > -       component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
>> > +       drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
>> > +                                  port);
>> > +       of_node_put(port);
>> >         return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>> >                                                match);
>> >  }
>> > diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
>> > index 1e0e68f608e4..94e46da9a758 100644
>> > --- a/drivers/gpu/drm/armada/armada_drv.c
>> > +++ b/drivers/gpu/drm/armada/armada_drv.c
>> > @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>> >                         continue;
>> >                 }
>> >
>> > -               component_match_add(dev, match, compare_of, remote);
>> > +               drm_of_component_match_add(dev, match, compare_of, remote);
>> >                 of_node_put(remote);
>> >         }
>> >  }
>> > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
>> > index bc98bb94264d..47848ed8ca48 100644
>> > --- a/drivers/gpu/drm/drm_of.c
>> > +++ b/drivers/gpu/drm/drm_of.c
>> > @@ -6,6 +6,11 @@
>> >  #include <drm/drm_crtc.h>
>> >  #include <drm/drm_of.h>
>> >
>> > +static void drm_release_of(struct device *dev, void *data)
>> > +{
>> > +       of_node_put(data);
>> > +}
>> > +
>> >  /**
>> >   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>> >   * @dev: DRM device
>> > @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>> >  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>> >
>> >  /**
>> > + * drm_of_component_match_add - Add a component helper OF node match rule
>> > + * @master: master device
>> > + * @matchptr: component match pointer
>> > + * @compare: compare function used for matching component
>> > + * @node: of_node
>> > + */
>> > +void drm_of_component_match_add(struct device *master,
>> > +                               struct component_match **matchptr,
>> > +                               int (*compare)(struct device *, void *),
>> > +                               struct device_node *node)
>> > +{
>> > +       of_node_get(node);
>> > +       component_match_add_release(master, matchptr, drm_release_of,
>> > +                                   compare, node);
>> > +}
>> > +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
>> > +
>> > +/**
>> >   * drm_of_component_probe - Generic probe function for a component based master
>> >   * @dev: master device containing the OF node
>> >   * @compare_of: compare function used for matching components
>> > @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>> >                         continue;
>> >                 }
>> >
>> > -               component_match_add(dev, &match, compare_of, port);
>> > +               drm_of_component_match_add(dev, &match, compare_of, port);
>> >                 of_node_put(port);
>> >         }
>> >
>> > @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>> >                                 continue;
>> >                         }
>> >
>> > -                       component_match_add(dev, &match, compare_of, remote);
>> > +                       drm_of_component_match_add(dev, &match, compare_of,
>> > +                                                  remote);
>> >                         of_node_put(remote);
>> >                 }
>> >                 of_node_put(port);
>> > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
>> > index aa687669e22b..0dee6acbd880 100644
>> > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
>> > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
>> > @@ -16,6 +16,7 @@
>> >
>> >  #include <linux/component.h>
>> >  #include <linux/of_platform.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "etnaviv_drv.h"
>> >  #include "etnaviv_gpu.h"
>> > @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>> >                         if (!core_node)
>> >                                 break;
>> >
>> > -                       component_match_add(&pdev->dev, &match, compare_of,
>> > -                                           core_node);
>> > +                       drm_of_component_match_add(&pdev->dev, &match,
>> > +                                                  compare_of, core_node);
>> >                         of_node_put(core_node);
>> >                 }
>> >         } else if (dev->platform_data) {
>> > diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> > index 90377a609c98..e88fde18c946 100644
>> > --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> > +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> > @@ -24,6 +24,7 @@
>> >  #include <drm/drm_fb_cma_helper.h>
>> >  #include <drm/drm_atomic_helper.h>
>> >  #include <drm/drm_crtc_helper.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "kirin_drm_drv.h"
>> >
>> > @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>> >                 DRM_ERROR("no valid endpoint node\n");
>> >                 return ERR_PTR(-ENODEV);
>> >         }
>> > -       of_node_put(endpoint);
>> >
>> >         remote = of_graph_get_remote_port_parent(endpoint);
>> > +       of_node_put(endpoint);
>>
>> Another bug that's being fixed without mention in the commit.
>>
>> >         if (!remote) {
>> >                 DRM_ERROR("no valid remote node\n");
>> >                 return ERR_PTR(-ENODEV);
>> >         }
>> > -       of_node_put(remote);
>> >
>> >         if (!of_device_is_available(remote)) {
>> >                 DRM_ERROR("not available for remote node\n");
>> > @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>> >         if (IS_ERR(remote))
>> >                 return PTR_ERR(remote);
>> >
>> > -       component_match_add(dev, &match, compare_of, remote);
>> > +       drm_of_component_match_add(dev, &match, compare_of, remote);
>> > +       of_node_put(remote);
>> >
>> >         return component_master_add_with_match(dev, &kirin_drm_ops, match);
>> >
>> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> > index cf83f6507ec8..9c5430fb82a2 100644
>> > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> > @@ -18,6 +18,7 @@
>> >  #include <drm/drm_crtc_helper.h>
>> >  #include <drm/drm_gem.h>
>> >  #include <drm/drm_gem_cma_helper.h>
>> > +#include <drm/drm_of.h>
>> >  #include <linux/component.h>
>> >  #include <linux/iommu.h>
>> >  #include <linux/of_address.h>
>> > @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>> >                     comp_type == MTK_DPI) {
>> >                         dev_info(dev, "Adding component match for %s\n",
>> >                                  node->full_name);
>> > -                       component_match_add(dev, &match, compare_of, node);
>> > +                       drm_of_component_match_add(dev, &match, compare_of,
>> > +                                                  node);
>> >                 } else {
>> >                         struct mtk_ddp_comp *comp;
>> >
>> > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
>> > index fb5c0b0a7594..84d38eaea585 100644
>> > --- a/drivers/gpu/drm/msm/msm_drv.c
>> > +++ b/drivers/gpu/drm/msm/msm_drv.c
>> > @@ -15,6 +15,8 @@
>> >   * this program.  If not, see <http://www.gnu.org/licenses/>.
>> >   */
>> >
>> > +#include <drm/drm_of.h>
>> > +
>> >  #include "msm_drv.h"
>> >  #include "msm_debugfs.h"
>> >  #include "msm_fence.h"
>> > @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>> >                         continue;
>> >                 }
>> >
>> > -               component_match_add(master_dev, matchptr, compare_of, intf);
>> > -
>> > +               drm_of_component_match_add(master_dev, matchptr, compare_of,
>> > +                                          intf);
>> >                 of_node_put(intf);
>> >                 of_node_put(ep_node);
>> >         }
>> > @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>> >                 put_device(mdp_dev);
>> >
>> >                 /* add the MDP component itself */
>> > -               component_match_add(dev, matchptr, compare_of,
>> > -                                   mdp_dev->of_node);
>> > +               drm_of_component_match_add(dev, matchptr, compare_of,
>> > +                                          mdp_dev->of_node);
>> >         } else {
>> >                 /* MDP4 */
>> >                 mdp_dev = dev;
>> > @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>> >         if (!np)
>> >                 return 0;
>> >
>> > -       component_match_add(dev, matchptr, compare_of, np);
>> > +       drm_of_component_match_add(dev, matchptr, compare_of, np);
>> >
>> >         of_node_put(np);
>> >
>> > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> > index 8c8cbe837e61..6fe161192bb4 100644
>> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> > @@ -20,6 +20,7 @@
>> >  #include <drm/drm_crtc_helper.h>
>> >  #include <drm/drm_fb_helper.h>
>> >  #include <drm/drm_gem_cma_helper.h>
>> > +#include <drm/drm_of.h>
>> >  #include <linux/dma-mapping.h>
>> >  #include <linux/pm_runtime.h>
>> >  #include <linux/module.h>
>> > @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>> >                         continue;
>> >                 }
>> >
>> > -               component_match_add(dev, match, compare_of, remote);
>> > +               drm_of_component_match_add(dev, match, compare_of, remote);
>> >                 of_node_put(remote);
>> >         }
>> >  }
>> > @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>> >                 }
>> >
>> >                 of_node_put(iommu);
>> > -               component_match_add(dev, &match, compare_of, port->parent);
>> > +               drm_of_component_match_add(dev, &match, compare_of,
>> > +                                          port->parent);
>> >                 of_node_put(port);
>> >         }
>> >
>> > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
>> > index 2784919a7366..5e819876e642 100644
>> > --- a/drivers/gpu/drm/sti/sti_drv.c
>> > +++ b/drivers/gpu/drm/sti/sti_drv.c
>> > @@ -17,6 +17,7 @@
>> >  #include <drm/drm_crtc_helper.h>
>> >  #include <drm/drm_gem_cma_helper.h>
>> >  #include <drm/drm_fb_cma_helper.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "sti_crtc.h"
>> >  #include "sti_drv.h"
>> > @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>> >         child_np = of_get_next_available_child(node, NULL);
>> >
>> >         while (child_np) {
>> > -               component_match_add(dev, &match, compare_of, child_np);
>> > -               of_node_put(child_np);
>> > +               drm_of_component_match_add(dev, &match, compare_of,
>> > +                                          child_np);
>> >                 child_np = of_get_next_available_child(node, child_np);
>> >         }
>> >
>> > diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
>> > index 0da9862ad8ed..b3c4ad605e81 100644
>> > --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
>> > +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
>> > @@ -18,6 +18,7 @@
>> >  #include <drm/drm_fb_cma_helper.h>
>> >  #include <drm/drm_gem_cma_helper.h>
>> >  #include <drm/drm_fb_helper.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "sun4i_crtc.h"
>> >  #include "sun4i_drv.h"
>> > @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>> >                 /* Add current component */
>> >                 DRM_DEBUG_DRIVER("Adding component %s\n",
>> >                                  of_node_full_name(node));
>> > -               component_match_add(dev, match, compare_of, node);
>> > +               drm_of_component_match_add(dev, match, compare_of, node);
>> >                 count++;
>> >         }
>> >
>> > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
>> > index 68e895021005..06a4c584f3cb 100644
>> > --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
>> > +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
>> > @@ -10,6 +10,7 @@
>> >
>> >  #include <linux/component.h>
>> >  #include <linux/of_graph.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "tilcdc_drv.h"
>> >  #include "tilcdc_external.h"
>> > @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>> >
>> >                 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>> >                 if (match)
>> > -                       component_match_add(dev, match, dev_match_of, node);
>> > +                       drm_of_component_match_add(dev, match, dev_match_of,
>> > +                                                  node);
>> >                 of_node_put(node);
>> >                 count++;
>> >         }
>> > diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
>> > index 3fd87b386ed7..d6b4c5587bbe 100644
>> > --- a/include/drm/drm_of.h
>> > +++ b/include/drm/drm_of.h
>> > @@ -4,6 +4,7 @@
>> >  #include <linux/of_graph.h>
>> >
>> >  struct component_master_ops;
>> > +struct component_match;
>> >  struct device;
>> >  struct drm_device;
>> >  struct drm_encoder;
>> > @@ -12,6 +13,10 @@ struct device_node;
>> >  #ifdef CONFIG_OF
>> >  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>> >                                            struct device_node *port);
>> > +extern void drm_of_component_match_add(struct device *master,
>> > +                                      struct component_match **matchptr,
>> > +                                      int (*compare)(struct device *, void *),
>> > +                                      struct device_node *node);
>> >  extern int drm_of_component_probe(struct device *dev,
>> >                                   int (*compare_of)(struct device *, void *),
>> >                                   const struct component_master_ops *m_ops);
>> > @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>> >         return 0;
>> >  }
>> >
>> > +static void drm_of_component_match_add(struct device *master,
>> > +                                      struct component_match **matchptr,
>> > +                                      int (*compare)(struct device *, void *),
>> > +                                      struct device_node *node)
>> > +{
>> > +}
>> > +
>> >  static inline int
>> >  drm_of_component_probe(struct device *dev,
>> >                        int (*compare_of)(struct device *, void *),
>> > --
>> > 2.1.0
>> >
>> >
>> > _______________________________________________
>> > linux-arm-kernel mailing list
>> > linux-arm-kernel@lists.infradead.org
>> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
> --
> RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
> according to speedtest.net.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-20 23:15       ` Sean Paul
  0 siblings, 0 replies; 56+ messages in thread
From: Sean Paul @ 2016-10-20 23:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 20, 2016 at 5:50 PM, Russell King - ARM Linux
<linux@armlinux.org.uk> wrote:
> On Thu, Oct 20, 2016 at 04:39:04PM -0400, Sean Paul wrote:
>> On Wed, Oct 19, 2016 at 6:28 AM, Russell King
>> <rmk+kernel@armlinux.org.uk> wrote:
>> > Convert DT component matching to use component_match_add_release().
>> >
>> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
>> > ---
>> > Can we please get this patch from May merged into the drm-misc or
>> > whatever trees so that we don't end up with conflicts?  I've no idea
>> > who looks after drm-misc, as they have _still_ failed to add
>> > themselves to MAINTAINERS.
>>
>> I think Daniel explained pretty clearly why this wasn't happening in
>> the previous thread.
>>
>> Next time you send a v2, can you please mark it as such and include a
>> "Changes in v2" section?
>
> Why - nothing's changed other than a rebase onto 4.9-rc1.  This isn't
> a "I've changed it in XYZ way, so here's a new copy".


Changes in v2: None

Is still useful since:
a) the diffstat is different from v1, which necessitates me going
through both versions to see what's changed from the previous reviews
(only to find out myself that it's been rebased and a function has
changed names)
b) in June, you said you were going to roll a new version with the
common OF bits extracted. it's nice to know at the outset that this
has/hasn't happened

Also, prefacing the subject with [PATCH v2] or [PATCH RESEND] lets me
know there is prior history with the change. Reading the previous
version is helpful to see what reviewer's concerns were, and whether
they've been addressed.


> It's being
> posted in the hope that someone will finally either comment on it or
> merge the damn thing, rather than ignoring it was done when it was
> last posted.
>
>> >  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>> >  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>> >  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>> >  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>> >  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>> >  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>> >  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>> >  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>> >  include/drm/drm_of.h                            | 12 +++++++++++
>> >  13 files changed, 73 insertions(+), 22 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
>> > index fb6a418ce6be..6477d1a65266 100644
>> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
>> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
>> > @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>> >                 return -EAGAIN;
>> >         }
>> >
>> > -       component_match_add(&pdev->dev, &match, compare_dev, port);
>> > +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
>> > +       of_node_put(port);
>>
>> There's no mention in your commit message about fixing these node leaks.
>
> Isn't that kind-of the whole point of this patch?
>

Not according to the commit msg, it isn't.

You could have just done the of_node_put adds/relocations without
wrapping component_match_add_release.

Sean

>> >
>> >         return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>> >                                                match);
>> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
>> > index 9280358b8f15..9f4739452a25 100644
>> > --- a/drivers/gpu/drm/arm/malidp_drv.c
>> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
>> > @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>> >                 return -EAGAIN;
>> >         }
>> >
>> > -       component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
>> > +       drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
>> > +                                  port);
>> > +       of_node_put(port);
>> >         return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>> >                                                match);
>> >  }
>> > diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
>> > index 1e0e68f608e4..94e46da9a758 100644
>> > --- a/drivers/gpu/drm/armada/armada_drv.c
>> > +++ b/drivers/gpu/drm/armada/armada_drv.c
>> > @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>> >                         continue;
>> >                 }
>> >
>> > -               component_match_add(dev, match, compare_of, remote);
>> > +               drm_of_component_match_add(dev, match, compare_of, remote);
>> >                 of_node_put(remote);
>> >         }
>> >  }
>> > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
>> > index bc98bb94264d..47848ed8ca48 100644
>> > --- a/drivers/gpu/drm/drm_of.c
>> > +++ b/drivers/gpu/drm/drm_of.c
>> > @@ -6,6 +6,11 @@
>> >  #include <drm/drm_crtc.h>
>> >  #include <drm/drm_of.h>
>> >
>> > +static void drm_release_of(struct device *dev, void *data)
>> > +{
>> > +       of_node_put(data);
>> > +}
>> > +
>> >  /**
>> >   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>> >   * @dev: DRM device
>> > @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>> >  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>> >
>> >  /**
>> > + * drm_of_component_match_add - Add a component helper OF node match rule
>> > + * @master: master device
>> > + * @matchptr: component match pointer
>> > + * @compare: compare function used for matching component
>> > + * @node: of_node
>> > + */
>> > +void drm_of_component_match_add(struct device *master,
>> > +                               struct component_match **matchptr,
>> > +                               int (*compare)(struct device *, void *),
>> > +                               struct device_node *node)
>> > +{
>> > +       of_node_get(node);
>> > +       component_match_add_release(master, matchptr, drm_release_of,
>> > +                                   compare, node);
>> > +}
>> > +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
>> > +
>> > +/**
>> >   * drm_of_component_probe - Generic probe function for a component based master
>> >   * @dev: master device containing the OF node
>> >   * @compare_of: compare function used for matching components
>> > @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>> >                         continue;
>> >                 }
>> >
>> > -               component_match_add(dev, &match, compare_of, port);
>> > +               drm_of_component_match_add(dev, &match, compare_of, port);
>> >                 of_node_put(port);
>> >         }
>> >
>> > @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>> >                                 continue;
>> >                         }
>> >
>> > -                       component_match_add(dev, &match, compare_of, remote);
>> > +                       drm_of_component_match_add(dev, &match, compare_of,
>> > +                                                  remote);
>> >                         of_node_put(remote);
>> >                 }
>> >                 of_node_put(port);
>> > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
>> > index aa687669e22b..0dee6acbd880 100644
>> > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
>> > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
>> > @@ -16,6 +16,7 @@
>> >
>> >  #include <linux/component.h>
>> >  #include <linux/of_platform.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "etnaviv_drv.h"
>> >  #include "etnaviv_gpu.h"
>> > @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>> >                         if (!core_node)
>> >                                 break;
>> >
>> > -                       component_match_add(&pdev->dev, &match, compare_of,
>> > -                                           core_node);
>> > +                       drm_of_component_match_add(&pdev->dev, &match,
>> > +                                                  compare_of, core_node);
>> >                         of_node_put(core_node);
>> >                 }
>> >         } else if (dev->platform_data) {
>> > diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> > index 90377a609c98..e88fde18c946 100644
>> > --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> > +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
>> > @@ -24,6 +24,7 @@
>> >  #include <drm/drm_fb_cma_helper.h>
>> >  #include <drm/drm_atomic_helper.h>
>> >  #include <drm/drm_crtc_helper.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "kirin_drm_drv.h"
>> >
>> > @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>> >                 DRM_ERROR("no valid endpoint node\n");
>> >                 return ERR_PTR(-ENODEV);
>> >         }
>> > -       of_node_put(endpoint);
>> >
>> >         remote = of_graph_get_remote_port_parent(endpoint);
>> > +       of_node_put(endpoint);
>>
>> Another bug that's being fixed without mention in the commit.
>>
>> >         if (!remote) {
>> >                 DRM_ERROR("no valid remote node\n");
>> >                 return ERR_PTR(-ENODEV);
>> >         }
>> > -       of_node_put(remote);
>> >
>> >         if (!of_device_is_available(remote)) {
>> >                 DRM_ERROR("not available for remote node\n");
>> > @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>> >         if (IS_ERR(remote))
>> >                 return PTR_ERR(remote);
>> >
>> > -       component_match_add(dev, &match, compare_of, remote);
>> > +       drm_of_component_match_add(dev, &match, compare_of, remote);
>> > +       of_node_put(remote);
>> >
>> >         return component_master_add_with_match(dev, &kirin_drm_ops, match);
>> >
>> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> > index cf83f6507ec8..9c5430fb82a2 100644
>> > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> > @@ -18,6 +18,7 @@
>> >  #include <drm/drm_crtc_helper.h>
>> >  #include <drm/drm_gem.h>
>> >  #include <drm/drm_gem_cma_helper.h>
>> > +#include <drm/drm_of.h>
>> >  #include <linux/component.h>
>> >  #include <linux/iommu.h>
>> >  #include <linux/of_address.h>
>> > @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>> >                     comp_type == MTK_DPI) {
>> >                         dev_info(dev, "Adding component match for %s\n",
>> >                                  node->full_name);
>> > -                       component_match_add(dev, &match, compare_of, node);
>> > +                       drm_of_component_match_add(dev, &match, compare_of,
>> > +                                                  node);
>> >                 } else {
>> >                         struct mtk_ddp_comp *comp;
>> >
>> > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
>> > index fb5c0b0a7594..84d38eaea585 100644
>> > --- a/drivers/gpu/drm/msm/msm_drv.c
>> > +++ b/drivers/gpu/drm/msm/msm_drv.c
>> > @@ -15,6 +15,8 @@
>> >   * this program.  If not, see <http://www.gnu.org/licenses/>.
>> >   */
>> >
>> > +#include <drm/drm_of.h>
>> > +
>> >  #include "msm_drv.h"
>> >  #include "msm_debugfs.h"
>> >  #include "msm_fence.h"
>> > @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>> >                         continue;
>> >                 }
>> >
>> > -               component_match_add(master_dev, matchptr, compare_of, intf);
>> > -
>> > +               drm_of_component_match_add(master_dev, matchptr, compare_of,
>> > +                                          intf);
>> >                 of_node_put(intf);
>> >                 of_node_put(ep_node);
>> >         }
>> > @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>> >                 put_device(mdp_dev);
>> >
>> >                 /* add the MDP component itself */
>> > -               component_match_add(dev, matchptr, compare_of,
>> > -                                   mdp_dev->of_node);
>> > +               drm_of_component_match_add(dev, matchptr, compare_of,
>> > +                                          mdp_dev->of_node);
>> >         } else {
>> >                 /* MDP4 */
>> >                 mdp_dev = dev;
>> > @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>> >         if (!np)
>> >                 return 0;
>> >
>> > -       component_match_add(dev, matchptr, compare_of, np);
>> > +       drm_of_component_match_add(dev, matchptr, compare_of, np);
>> >
>> >         of_node_put(np);
>> >
>> > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> > index 8c8cbe837e61..6fe161192bb4 100644
>> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
>> > @@ -20,6 +20,7 @@
>> >  #include <drm/drm_crtc_helper.h>
>> >  #include <drm/drm_fb_helper.h>
>> >  #include <drm/drm_gem_cma_helper.h>
>> > +#include <drm/drm_of.h>
>> >  #include <linux/dma-mapping.h>
>> >  #include <linux/pm_runtime.h>
>> >  #include <linux/module.h>
>> > @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>> >                         continue;
>> >                 }
>> >
>> > -               component_match_add(dev, match, compare_of, remote);
>> > +               drm_of_component_match_add(dev, match, compare_of, remote);
>> >                 of_node_put(remote);
>> >         }
>> >  }
>> > @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>> >                 }
>> >
>> >                 of_node_put(iommu);
>> > -               component_match_add(dev, &match, compare_of, port->parent);
>> > +               drm_of_component_match_add(dev, &match, compare_of,
>> > +                                          port->parent);
>> >                 of_node_put(port);
>> >         }
>> >
>> > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
>> > index 2784919a7366..5e819876e642 100644
>> > --- a/drivers/gpu/drm/sti/sti_drv.c
>> > +++ b/drivers/gpu/drm/sti/sti_drv.c
>> > @@ -17,6 +17,7 @@
>> >  #include <drm/drm_crtc_helper.h>
>> >  #include <drm/drm_gem_cma_helper.h>
>> >  #include <drm/drm_fb_cma_helper.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "sti_crtc.h"
>> >  #include "sti_drv.h"
>> > @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>> >         child_np = of_get_next_available_child(node, NULL);
>> >
>> >         while (child_np) {
>> > -               component_match_add(dev, &match, compare_of, child_np);
>> > -               of_node_put(child_np);
>> > +               drm_of_component_match_add(dev, &match, compare_of,
>> > +                                          child_np);
>> >                 child_np = of_get_next_available_child(node, child_np);
>> >         }
>> >
>> > diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
>> > index 0da9862ad8ed..b3c4ad605e81 100644
>> > --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
>> > +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
>> > @@ -18,6 +18,7 @@
>> >  #include <drm/drm_fb_cma_helper.h>
>> >  #include <drm/drm_gem_cma_helper.h>
>> >  #include <drm/drm_fb_helper.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "sun4i_crtc.h"
>> >  #include "sun4i_drv.h"
>> > @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>> >                 /* Add current component */
>> >                 DRM_DEBUG_DRIVER("Adding component %s\n",
>> >                                  of_node_full_name(node));
>> > -               component_match_add(dev, match, compare_of, node);
>> > +               drm_of_component_match_add(dev, match, compare_of, node);
>> >                 count++;
>> >         }
>> >
>> > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
>> > index 68e895021005..06a4c584f3cb 100644
>> > --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
>> > +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
>> > @@ -10,6 +10,7 @@
>> >
>> >  #include <linux/component.h>
>> >  #include <linux/of_graph.h>
>> > +#include <drm/drm_of.h>
>> >
>> >  #include "tilcdc_drv.h"
>> >  #include "tilcdc_external.h"
>> > @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>> >
>> >                 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>> >                 if (match)
>> > -                       component_match_add(dev, match, dev_match_of, node);
>> > +                       drm_of_component_match_add(dev, match, dev_match_of,
>> > +                                                  node);
>> >                 of_node_put(node);
>> >                 count++;
>> >         }
>> > diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
>> > index 3fd87b386ed7..d6b4c5587bbe 100644
>> > --- a/include/drm/drm_of.h
>> > +++ b/include/drm/drm_of.h
>> > @@ -4,6 +4,7 @@
>> >  #include <linux/of_graph.h>
>> >
>> >  struct component_master_ops;
>> > +struct component_match;
>> >  struct device;
>> >  struct drm_device;
>> >  struct drm_encoder;
>> > @@ -12,6 +13,10 @@ struct device_node;
>> >  #ifdef CONFIG_OF
>> >  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>> >                                            struct device_node *port);
>> > +extern void drm_of_component_match_add(struct device *master,
>> > +                                      struct component_match **matchptr,
>> > +                                      int (*compare)(struct device *, void *),
>> > +                                      struct device_node *node);
>> >  extern int drm_of_component_probe(struct device *dev,
>> >                                   int (*compare_of)(struct device *, void *),
>> >                                   const struct component_master_ops *m_ops);
>> > @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>> >         return 0;
>> >  }
>> >
>> > +static void drm_of_component_match_add(struct device *master,
>> > +                                      struct component_match **matchptr,
>> > +                                      int (*compare)(struct device *, void *),
>> > +                                      struct device_node *node)
>> > +{
>> > +}
>> > +
>> >  static inline int
>> >  drm_of_component_probe(struct device *dev,
>> >                        int (*compare_of)(struct device *, void *),
>> > --
>> > 2.1.0
>> >
>> >
>> > _______________________________________________
>> > linux-arm-kernel mailing list
>> > linux-arm-kernel at lists.infradead.org
>> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
> --
> RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
> FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
> according to speedtest.net.

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-10-20 20:39   ` Sean Paul
@ 2016-10-20 21:50     ` Russell King - ARM Linux
  -1 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-10-20 21:50 UTC (permalink / raw)
  To: Sean Paul
  Cc: dri-devel, David Airlie, Heiko Stuebner, Liviu Dudau,
	Benjamin Gaignard, Chen-Yu Tsai, Xinliang Liu, linux-rockchip,
	Xinwei Kong, Tomi Valkeinen, Mali DP Maintainers, linux-arm-msm,
	CK Hu, Chen Feng, Jyri Sarha, Christian Gmeiner, linux-mediatek,
	Matthias Brugger, Vincent Abriou

On Thu, Oct 20, 2016 at 04:39:04PM -0400, Sean Paul wrote:
> On Wed, Oct 19, 2016 at 6:28 AM, Russell King
> <rmk+kernel@armlinux.org.uk> wrote:
> > Convert DT component matching to use component_match_add_release().
> >
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> > Can we please get this patch from May merged into the drm-misc or
> > whatever trees so that we don't end up with conflicts?  I've no idea
> > who looks after drm-misc, as they have _still_ failed to add
> > themselves to MAINTAINERS.
> 
> I think Daniel explained pretty clearly why this wasn't happening in
> the previous thread.
> 
> Next time you send a v2, can you please mark it as such and include a
> "Changes in v2" section?

Why - nothing's changed other than a rebase onto 4.9-rc1.  This isn't
a "I've changed it in XYZ way, so here's a new copy".  It's being
posted in the hope that someone will finally either comment on it or
merge the damn thing, rather than ignoring it was done when it was
last posted.

> >  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
> >  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
> >  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
> >  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
> >  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
> >  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
> >  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
> >  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
> >  include/drm/drm_of.h                            | 12 +++++++++++
> >  13 files changed, 73 insertions(+), 22 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> > index fb6a418ce6be..6477d1a65266 100644
> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> > @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
> >                 return -EAGAIN;
> >         }
> >
> > -       component_match_add(&pdev->dev, &match, compare_dev, port);
> > +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> > +       of_node_put(port);
> 
> There's no mention in your commit message about fixing these node leaks.

Isn't that kind-of the whole point of this patch?

> >
> >         return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
> >                                                match);
> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> > index 9280358b8f15..9f4739452a25 100644
> > --- a/drivers/gpu/drm/arm/malidp_drv.c
> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
> > @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
> >                 return -EAGAIN;
> >         }
> >
> > -       component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> > +       drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> > +                                  port);
> > +       of_node_put(port);
> >         return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
> >                                                match);
> >  }
> > diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> > index 1e0e68f608e4..94e46da9a758 100644
> > --- a/drivers/gpu/drm/armada/armada_drv.c
> > +++ b/drivers/gpu/drm/armada/armada_drv.c
> > @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
> >                         continue;
> >                 }
> >
> > -               component_match_add(dev, match, compare_of, remote);
> > +               drm_of_component_match_add(dev, match, compare_of, remote);
> >                 of_node_put(remote);
> >         }
> >  }
> > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> > index bc98bb94264d..47848ed8ca48 100644
> > --- a/drivers/gpu/drm/drm_of.c
> > +++ b/drivers/gpu/drm/drm_of.c
> > @@ -6,6 +6,11 @@
> >  #include <drm/drm_crtc.h>
> >  #include <drm/drm_of.h>
> >
> > +static void drm_release_of(struct device *dev, void *data)
> > +{
> > +       of_node_put(data);
> > +}
> > +
> >  /**
> >   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
> >   * @dev: DRM device
> > @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
> >  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
> >
> >  /**
> > + * drm_of_component_match_add - Add a component helper OF node match rule
> > + * @master: master device
> > + * @matchptr: component match pointer
> > + * @compare: compare function used for matching component
> > + * @node: of_node
> > + */
> > +void drm_of_component_match_add(struct device *master,
> > +                               struct component_match **matchptr,
> > +                               int (*compare)(struct device *, void *),
> > +                               struct device_node *node)
> > +{
> > +       of_node_get(node);
> > +       component_match_add_release(master, matchptr, drm_release_of,
> > +                                   compare, node);
> > +}
> > +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> > +
> > +/**
> >   * drm_of_component_probe - Generic probe function for a component based master
> >   * @dev: master device containing the OF node
> >   * @compare_of: compare function used for matching components
> > @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
> >                         continue;
> >                 }
> >
> > -               component_match_add(dev, &match, compare_of, port);
> > +               drm_of_component_match_add(dev, &match, compare_of, port);
> >                 of_node_put(port);
> >         }
> >
> > @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
> >                                 continue;
> >                         }
> >
> > -                       component_match_add(dev, &match, compare_of, remote);
> > +                       drm_of_component_match_add(dev, &match, compare_of,
> > +                                                  remote);
> >                         of_node_put(remote);
> >                 }
> >                 of_node_put(port);
> > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > index aa687669e22b..0dee6acbd880 100644
> > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > @@ -16,6 +16,7 @@
> >
> >  #include <linux/component.h>
> >  #include <linux/of_platform.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "etnaviv_drv.h"
> >  #include "etnaviv_gpu.h"
> > @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
> >                         if (!core_node)
> >                                 break;
> >
> > -                       component_match_add(&pdev->dev, &match, compare_of,
> > -                                           core_node);
> > +                       drm_of_component_match_add(&pdev->dev, &match,
> > +                                                  compare_of, core_node);
> >                         of_node_put(core_node);
> >                 }
> >         } else if (dev->platform_data) {
> > diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > index 90377a609c98..e88fde18c946 100644
> > --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > @@ -24,6 +24,7 @@
> >  #include <drm/drm_fb_cma_helper.h>
> >  #include <drm/drm_atomic_helper.h>
> >  #include <drm/drm_crtc_helper.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "kirin_drm_drv.h"
> >
> > @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
> >                 DRM_ERROR("no valid endpoint node\n");
> >                 return ERR_PTR(-ENODEV);
> >         }
> > -       of_node_put(endpoint);
> >
> >         remote = of_graph_get_remote_port_parent(endpoint);
> > +       of_node_put(endpoint);
> 
> Another bug that's being fixed without mention in the commit.
> 
> >         if (!remote) {
> >                 DRM_ERROR("no valid remote node\n");
> >                 return ERR_PTR(-ENODEV);
> >         }
> > -       of_node_put(remote);
> >
> >         if (!of_device_is_available(remote)) {
> >                 DRM_ERROR("not available for remote node\n");
> > @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
> >         if (IS_ERR(remote))
> >                 return PTR_ERR(remote);
> >
> > -       component_match_add(dev, &match, compare_of, remote);
> > +       drm_of_component_match_add(dev, &match, compare_of, remote);
> > +       of_node_put(remote);
> >
> >         return component_master_add_with_match(dev, &kirin_drm_ops, match);
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > index cf83f6507ec8..9c5430fb82a2 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > @@ -18,6 +18,7 @@
> >  #include <drm/drm_crtc_helper.h>
> >  #include <drm/drm_gem.h>
> >  #include <drm/drm_gem_cma_helper.h>
> > +#include <drm/drm_of.h>
> >  #include <linux/component.h>
> >  #include <linux/iommu.h>
> >  #include <linux/of_address.h>
> > @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
> >                     comp_type == MTK_DPI) {
> >                         dev_info(dev, "Adding component match for %s\n",
> >                                  node->full_name);
> > -                       component_match_add(dev, &match, compare_of, node);
> > +                       drm_of_component_match_add(dev, &match, compare_of,
> > +                                                  node);
> >                 } else {
> >                         struct mtk_ddp_comp *comp;
> >
> > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> > index fb5c0b0a7594..84d38eaea585 100644
> > --- a/drivers/gpu/drm/msm/msm_drv.c
> > +++ b/drivers/gpu/drm/msm/msm_drv.c
> > @@ -15,6 +15,8 @@
> >   * this program.  If not, see <http://www.gnu.org/licenses/>.
> >   */
> >
> > +#include <drm/drm_of.h>
> > +
> >  #include "msm_drv.h"
> >  #include "msm_debugfs.h"
> >  #include "msm_fence.h"
> > @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
> >                         continue;
> >                 }
> >
> > -               component_match_add(master_dev, matchptr, compare_of, intf);
> > -
> > +               drm_of_component_match_add(master_dev, matchptr, compare_of,
> > +                                          intf);
> >                 of_node_put(intf);
> >                 of_node_put(ep_node);
> >         }
> > @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
> >                 put_device(mdp_dev);
> >
> >                 /* add the MDP component itself */
> > -               component_match_add(dev, matchptr, compare_of,
> > -                                   mdp_dev->of_node);
> > +               drm_of_component_match_add(dev, matchptr, compare_of,
> > +                                          mdp_dev->of_node);
> >         } else {
> >                 /* MDP4 */
> >                 mdp_dev = dev;
> > @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
> >         if (!np)
> >                 return 0;
> >
> > -       component_match_add(dev, matchptr, compare_of, np);
> > +       drm_of_component_match_add(dev, matchptr, compare_of, np);
> >
> >         of_node_put(np);
> >
> > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> > index 8c8cbe837e61..6fe161192bb4 100644
> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> > @@ -20,6 +20,7 @@
> >  #include <drm/drm_crtc_helper.h>
> >  #include <drm/drm_fb_helper.h>
> >  #include <drm/drm_gem_cma_helper.h>
> > +#include <drm/drm_of.h>
> >  #include <linux/dma-mapping.h>
> >  #include <linux/pm_runtime.h>
> >  #include <linux/module.h>
> > @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
> >                         continue;
> >                 }
> >
> > -               component_match_add(dev, match, compare_of, remote);
> > +               drm_of_component_match_add(dev, match, compare_of, remote);
> >                 of_node_put(remote);
> >         }
> >  }
> > @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
> >                 }
> >
> >                 of_node_put(iommu);
> > -               component_match_add(dev, &match, compare_of, port->parent);
> > +               drm_of_component_match_add(dev, &match, compare_of,
> > +                                          port->parent);
> >                 of_node_put(port);
> >         }
> >
> > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> > index 2784919a7366..5e819876e642 100644
> > --- a/drivers/gpu/drm/sti/sti_drv.c
> > +++ b/drivers/gpu/drm/sti/sti_drv.c
> > @@ -17,6 +17,7 @@
> >  #include <drm/drm_crtc_helper.h>
> >  #include <drm/drm_gem_cma_helper.h>
> >  #include <drm/drm_fb_cma_helper.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "sti_crtc.h"
> >  #include "sti_drv.h"
> > @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
> >         child_np = of_get_next_available_child(node, NULL);
> >
> >         while (child_np) {
> > -               component_match_add(dev, &match, compare_of, child_np);
> > -               of_node_put(child_np);
> > +               drm_of_component_match_add(dev, &match, compare_of,
> > +                                          child_np);
> >                 child_np = of_get_next_available_child(node, child_np);
> >         }
> >
> > diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> > index 0da9862ad8ed..b3c4ad605e81 100644
> > --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> > +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> > @@ -18,6 +18,7 @@
> >  #include <drm/drm_fb_cma_helper.h>
> >  #include <drm/drm_gem_cma_helper.h>
> >  #include <drm/drm_fb_helper.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "sun4i_crtc.h"
> >  #include "sun4i_drv.h"
> > @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
> >                 /* Add current component */
> >                 DRM_DEBUG_DRIVER("Adding component %s\n",
> >                                  of_node_full_name(node));
> > -               component_match_add(dev, match, compare_of, node);
> > +               drm_of_component_match_add(dev, match, compare_of, node);
> >                 count++;
> >         }
> >
> > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> > index 68e895021005..06a4c584f3cb 100644
> > --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> > +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> > @@ -10,6 +10,7 @@
> >
> >  #include <linux/component.h>
> >  #include <linux/of_graph.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "tilcdc_drv.h"
> >  #include "tilcdc_external.h"
> > @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
> >
> >                 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
> >                 if (match)
> > -                       component_match_add(dev, match, dev_match_of, node);
> > +                       drm_of_component_match_add(dev, match, dev_match_of,
> > +                                                  node);
> >                 of_node_put(node);
> >                 count++;
> >         }
> > diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> > index 3fd87b386ed7..d6b4c5587bbe 100644
> > --- a/include/drm/drm_of.h
> > +++ b/include/drm/drm_of.h
> > @@ -4,6 +4,7 @@
> >  #include <linux/of_graph.h>
> >
> >  struct component_master_ops;
> > +struct component_match;
> >  struct device;
> >  struct drm_device;
> >  struct drm_encoder;
> > @@ -12,6 +13,10 @@ struct device_node;
> >  #ifdef CONFIG_OF
> >  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
> >                                            struct device_node *port);
> > +extern void drm_of_component_match_add(struct device *master,
> > +                                      struct component_match **matchptr,
> > +                                      int (*compare)(struct device *, void *),
> > +                                      struct device_node *node);
> >  extern int drm_of_component_probe(struct device *dev,
> >                                   int (*compare_of)(struct device *, void *),
> >                                   const struct component_master_ops *m_ops);
> > @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
> >         return 0;
> >  }
> >
> > +static void drm_of_component_match_add(struct device *master,
> > +                                      struct component_match **matchptr,
> > +                                      int (*compare)(struct device *, void *),
> > +                                      struct device_node *node)
> > +{
> > +}
> > +
> >  static inline int
> >  drm_of_component_probe(struct device *dev,
> >                        int (*compare_of)(struct device *, void *),
> > --
> > 2.1.0
> >
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-20 21:50     ` Russell King - ARM Linux
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King - ARM Linux @ 2016-10-20 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 20, 2016 at 04:39:04PM -0400, Sean Paul wrote:
> On Wed, Oct 19, 2016 at 6:28 AM, Russell King
> <rmk+kernel@armlinux.org.uk> wrote:
> > Convert DT component matching to use component_match_add_release().
> >
> > Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> > ---
> > Can we please get this patch from May merged into the drm-misc or
> > whatever trees so that we don't end up with conflicts?  I've no idea
> > who looks after drm-misc, as they have _still_ failed to add
> > themselves to MAINTAINERS.
> 
> I think Daniel explained pretty clearly why this wasn't happening in
> the previous thread.
> 
> Next time you send a v2, can you please mark it as such and include a
> "Changes in v2" section?

Why - nothing's changed other than a rebase onto 4.9-rc1.  This isn't
a "I've changed it in XYZ way, so here's a new copy".  It's being
posted in the hope that someone will finally either comment on it or
merge the damn thing, rather than ignoring it was done when it was
last posted.

> >  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
> >  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
> >  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
> >  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
> >  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
> >  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
> >  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
> >  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
> >  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
> >  include/drm/drm_of.h                            | 12 +++++++++++
> >  13 files changed, 73 insertions(+), 22 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> > index fb6a418ce6be..6477d1a65266 100644
> > --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> > +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> > @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
> >                 return -EAGAIN;
> >         }
> >
> > -       component_match_add(&pdev->dev, &match, compare_dev, port);
> > +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> > +       of_node_put(port);
> 
> There's no mention in your commit message about fixing these node leaks.

Isn't that kind-of the whole point of this patch?

> >
> >         return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
> >                                                match);
> > diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> > index 9280358b8f15..9f4739452a25 100644
> > --- a/drivers/gpu/drm/arm/malidp_drv.c
> > +++ b/drivers/gpu/drm/arm/malidp_drv.c
> > @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
> >                 return -EAGAIN;
> >         }
> >
> > -       component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> > +       drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> > +                                  port);
> > +       of_node_put(port);
> >         return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
> >                                                match);
> >  }
> > diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> > index 1e0e68f608e4..94e46da9a758 100644
> > --- a/drivers/gpu/drm/armada/armada_drv.c
> > +++ b/drivers/gpu/drm/armada/armada_drv.c
> > @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
> >                         continue;
> >                 }
> >
> > -               component_match_add(dev, match, compare_of, remote);
> > +               drm_of_component_match_add(dev, match, compare_of, remote);
> >                 of_node_put(remote);
> >         }
> >  }
> > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> > index bc98bb94264d..47848ed8ca48 100644
> > --- a/drivers/gpu/drm/drm_of.c
> > +++ b/drivers/gpu/drm/drm_of.c
> > @@ -6,6 +6,11 @@
> >  #include <drm/drm_crtc.h>
> >  #include <drm/drm_of.h>
> >
> > +static void drm_release_of(struct device *dev, void *data)
> > +{
> > +       of_node_put(data);
> > +}
> > +
> >  /**
> >   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
> >   * @dev: DRM device
> > @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
> >  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
> >
> >  /**
> > + * drm_of_component_match_add - Add a component helper OF node match rule
> > + * @master: master device
> > + * @matchptr: component match pointer
> > + * @compare: compare function used for matching component
> > + * @node: of_node
> > + */
> > +void drm_of_component_match_add(struct device *master,
> > +                               struct component_match **matchptr,
> > +                               int (*compare)(struct device *, void *),
> > +                               struct device_node *node)
> > +{
> > +       of_node_get(node);
> > +       component_match_add_release(master, matchptr, drm_release_of,
> > +                                   compare, node);
> > +}
> > +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> > +
> > +/**
> >   * drm_of_component_probe - Generic probe function for a component based master
> >   * @dev: master device containing the OF node
> >   * @compare_of: compare function used for matching components
> > @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
> >                         continue;
> >                 }
> >
> > -               component_match_add(dev, &match, compare_of, port);
> > +               drm_of_component_match_add(dev, &match, compare_of, port);
> >                 of_node_put(port);
> >         }
> >
> > @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
> >                                 continue;
> >                         }
> >
> > -                       component_match_add(dev, &match, compare_of, remote);
> > +                       drm_of_component_match_add(dev, &match, compare_of,
> > +                                                  remote);
> >                         of_node_put(remote);
> >                 }
> >                 of_node_put(port);
> > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > index aa687669e22b..0dee6acbd880 100644
> > --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> > @@ -16,6 +16,7 @@
> >
> >  #include <linux/component.h>
> >  #include <linux/of_platform.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "etnaviv_drv.h"
> >  #include "etnaviv_gpu.h"
> > @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
> >                         if (!core_node)
> >                                 break;
> >
> > -                       component_match_add(&pdev->dev, &match, compare_of,
> > -                                           core_node);
> > +                       drm_of_component_match_add(&pdev->dev, &match,
> > +                                                  compare_of, core_node);
> >                         of_node_put(core_node);
> >                 }
> >         } else if (dev->platform_data) {
> > diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > index 90377a609c98..e88fde18c946 100644
> > --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> > @@ -24,6 +24,7 @@
> >  #include <drm/drm_fb_cma_helper.h>
> >  #include <drm/drm_atomic_helper.h>
> >  #include <drm/drm_crtc_helper.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "kirin_drm_drv.h"
> >
> > @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
> >                 DRM_ERROR("no valid endpoint node\n");
> >                 return ERR_PTR(-ENODEV);
> >         }
> > -       of_node_put(endpoint);
> >
> >         remote = of_graph_get_remote_port_parent(endpoint);
> > +       of_node_put(endpoint);
> 
> Another bug that's being fixed without mention in the commit.
> 
> >         if (!remote) {
> >                 DRM_ERROR("no valid remote node\n");
> >                 return ERR_PTR(-ENODEV);
> >         }
> > -       of_node_put(remote);
> >
> >         if (!of_device_is_available(remote)) {
> >                 DRM_ERROR("not available for remote node\n");
> > @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
> >         if (IS_ERR(remote))
> >                 return PTR_ERR(remote);
> >
> > -       component_match_add(dev, &match, compare_of, remote);
> > +       drm_of_component_match_add(dev, &match, compare_of, remote);
> > +       of_node_put(remote);
> >
> >         return component_master_add_with_match(dev, &kirin_drm_ops, match);
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > index cf83f6507ec8..9c5430fb82a2 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> > @@ -18,6 +18,7 @@
> >  #include <drm/drm_crtc_helper.h>
> >  #include <drm/drm_gem.h>
> >  #include <drm/drm_gem_cma_helper.h>
> > +#include <drm/drm_of.h>
> >  #include <linux/component.h>
> >  #include <linux/iommu.h>
> >  #include <linux/of_address.h>
> > @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
> >                     comp_type == MTK_DPI) {
> >                         dev_info(dev, "Adding component match for %s\n",
> >                                  node->full_name);
> > -                       component_match_add(dev, &match, compare_of, node);
> > +                       drm_of_component_match_add(dev, &match, compare_of,
> > +                                                  node);
> >                 } else {
> >                         struct mtk_ddp_comp *comp;
> >
> > diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> > index fb5c0b0a7594..84d38eaea585 100644
> > --- a/drivers/gpu/drm/msm/msm_drv.c
> > +++ b/drivers/gpu/drm/msm/msm_drv.c
> > @@ -15,6 +15,8 @@
> >   * this program.  If not, see <http://www.gnu.org/licenses/>.
> >   */
> >
> > +#include <drm/drm_of.h>
> > +
> >  #include "msm_drv.h"
> >  #include "msm_debugfs.h"
> >  #include "msm_fence.h"
> > @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
> >                         continue;
> >                 }
> >
> > -               component_match_add(master_dev, matchptr, compare_of, intf);
> > -
> > +               drm_of_component_match_add(master_dev, matchptr, compare_of,
> > +                                          intf);
> >                 of_node_put(intf);
> >                 of_node_put(ep_node);
> >         }
> > @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
> >                 put_device(mdp_dev);
> >
> >                 /* add the MDP component itself */
> > -               component_match_add(dev, matchptr, compare_of,
> > -                                   mdp_dev->of_node);
> > +               drm_of_component_match_add(dev, matchptr, compare_of,
> > +                                          mdp_dev->of_node);
> >         } else {
> >                 /* MDP4 */
> >                 mdp_dev = dev;
> > @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
> >         if (!np)
> >                 return 0;
> >
> > -       component_match_add(dev, matchptr, compare_of, np);
> > +       drm_of_component_match_add(dev, matchptr, compare_of, np);
> >
> >         of_node_put(np);
> >
> > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> > index 8c8cbe837e61..6fe161192bb4 100644
> > --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> > @@ -20,6 +20,7 @@
> >  #include <drm/drm_crtc_helper.h>
> >  #include <drm/drm_fb_helper.h>
> >  #include <drm/drm_gem_cma_helper.h>
> > +#include <drm/drm_of.h>
> >  #include <linux/dma-mapping.h>
> >  #include <linux/pm_runtime.h>
> >  #include <linux/module.h>
> > @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
> >                         continue;
> >                 }
> >
> > -               component_match_add(dev, match, compare_of, remote);
> > +               drm_of_component_match_add(dev, match, compare_of, remote);
> >                 of_node_put(remote);
> >         }
> >  }
> > @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
> >                 }
> >
> >                 of_node_put(iommu);
> > -               component_match_add(dev, &match, compare_of, port->parent);
> > +               drm_of_component_match_add(dev, &match, compare_of,
> > +                                          port->parent);
> >                 of_node_put(port);
> >         }
> >
> > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> > index 2784919a7366..5e819876e642 100644
> > --- a/drivers/gpu/drm/sti/sti_drv.c
> > +++ b/drivers/gpu/drm/sti/sti_drv.c
> > @@ -17,6 +17,7 @@
> >  #include <drm/drm_crtc_helper.h>
> >  #include <drm/drm_gem_cma_helper.h>
> >  #include <drm/drm_fb_cma_helper.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "sti_crtc.h"
> >  #include "sti_drv.h"
> > @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
> >         child_np = of_get_next_available_child(node, NULL);
> >
> >         while (child_np) {
> > -               component_match_add(dev, &match, compare_of, child_np);
> > -               of_node_put(child_np);
> > +               drm_of_component_match_add(dev, &match, compare_of,
> > +                                          child_np);
> >                 child_np = of_get_next_available_child(node, child_np);
> >         }
> >
> > diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> > index 0da9862ad8ed..b3c4ad605e81 100644
> > --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> > +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> > @@ -18,6 +18,7 @@
> >  #include <drm/drm_fb_cma_helper.h>
> >  #include <drm/drm_gem_cma_helper.h>
> >  #include <drm/drm_fb_helper.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "sun4i_crtc.h"
> >  #include "sun4i_drv.h"
> > @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
> >                 /* Add current component */
> >                 DRM_DEBUG_DRIVER("Adding component %s\n",
> >                                  of_node_full_name(node));
> > -               component_match_add(dev, match, compare_of, node);
> > +               drm_of_component_match_add(dev, match, compare_of, node);
> >                 count++;
> >         }
> >
> > diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> > index 68e895021005..06a4c584f3cb 100644
> > --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> > +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> > @@ -10,6 +10,7 @@
> >
> >  #include <linux/component.h>
> >  #include <linux/of_graph.h>
> > +#include <drm/drm_of.h>
> >
> >  #include "tilcdc_drv.h"
> >  #include "tilcdc_external.h"
> > @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
> >
> >                 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
> >                 if (match)
> > -                       component_match_add(dev, match, dev_match_of, node);
> > +                       drm_of_component_match_add(dev, match, dev_match_of,
> > +                                                  node);
> >                 of_node_put(node);
> >                 count++;
> >         }
> > diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> > index 3fd87b386ed7..d6b4c5587bbe 100644
> > --- a/include/drm/drm_of.h
> > +++ b/include/drm/drm_of.h
> > @@ -4,6 +4,7 @@
> >  #include <linux/of_graph.h>
> >
> >  struct component_master_ops;
> > +struct component_match;
> >  struct device;
> >  struct drm_device;
> >  struct drm_encoder;
> > @@ -12,6 +13,10 @@ struct device_node;
> >  #ifdef CONFIG_OF
> >  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
> >                                            struct device_node *port);
> > +extern void drm_of_component_match_add(struct device *master,
> > +                                      struct component_match **matchptr,
> > +                                      int (*compare)(struct device *, void *),
> > +                                      struct device_node *node);
> >  extern int drm_of_component_probe(struct device *dev,
> >                                   int (*compare_of)(struct device *, void *),
> >                                   const struct component_master_ops *m_ops);
> > @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
> >         return 0;
> >  }
> >
> > +static void drm_of_component_match_add(struct device *master,
> > +                                      struct component_match **matchptr,
> > +                                      int (*compare)(struct device *, void *),
> > +                                      struct device_node *node)
> > +{
> > +}
> > +
> >  static inline int
> >  drm_of_component_probe(struct device *dev,
> >                        int (*compare_of)(struct device *, void *),
> > --
> > 2.1.0
> >
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-10-19 10:28 ` Russell King
@ 2016-10-20 20:39   ` Sean Paul
  -1 siblings, 0 replies; 56+ messages in thread
From: Sean Paul @ 2016-10-20 20:39 UTC (permalink / raw)
  To: Russell King
  Cc: dri-devel, David Airlie, Heiko Stuebner, Liviu Dudau,
	Benjamin Gaignard, Chen-Yu Tsai, Xinliang Liu, linux-rockchip,
	Xinwei Kong, Tomi Valkeinen, Mali DP Maintainers, linux-arm-msm,
	CK Hu, Chen Feng, Jyri Sarha, Christian Gmeiner, linux-mediatek,
	Matthias Brugger, Vincent Abriou

On Wed, Oct 19, 2016 at 6:28 AM, Russell King
<rmk+kernel@armlinux.org.uk> wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.

I think Daniel explained pretty clearly why this wasn't happening in
the previous thread.

Next time you send a v2, can you please mark it as such and include a
"Changes in v2" section?

>
>  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>  include/drm/drm_of.h                            | 12 +++++++++++
>  13 files changed, 73 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>                 return -EAGAIN;
>         }
>
> -       component_match_add(&pdev->dev, &match, compare_dev, port);
> +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> +       of_node_put(port);

There's no mention in your commit message about fixing these node leaks.

>
>         return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>                                                match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>                 return -EAGAIN;
>         }
>
> -       component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> +       drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> +                                  port);
> +       of_node_put(port);
>         return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>                                                match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, match, compare_of, remote);
> +               drm_of_component_match_add(dev, match, compare_of, remote);
>                 of_node_put(remote);
>         }
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +       of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +                               struct component_match **matchptr,
> +                               int (*compare)(struct device *, void *),
> +                               struct device_node *node)
> +{
> +       of_node_get(node);
> +       component_match_add_release(master, matchptr, drm_release_of,
> +                                   compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, &match, compare_of, port);
> +               drm_of_component_match_add(dev, &match, compare_of, port);
>                 of_node_put(port);
>         }
>
> @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>                                 continue;
>                         }
>
> -                       component_match_add(dev, &match, compare_of, remote);
> +                       drm_of_component_match_add(dev, &match, compare_of,
> +                                                  remote);
>                         of_node_put(remote);
>                 }
>                 of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index aa687669e22b..0dee6acbd880 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -16,6 +16,7 @@
>
>  #include <linux/component.h>
>  #include <linux/of_platform.h>
> +#include <drm/drm_of.h>
>
>  #include "etnaviv_drv.h"
>  #include "etnaviv_gpu.h"
> @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>                         if (!core_node)
>                                 break;
>
> -                       component_match_add(&pdev->dev, &match, compare_of,
> -                                           core_node);
> +                       drm_of_component_match_add(&pdev->dev, &match,
> +                                                  compare_of, core_node);
>                         of_node_put(core_node);
>                 }
>         } else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 90377a609c98..e88fde18c946 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -24,6 +24,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "kirin_drm_drv.h"
>
> @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>                 DRM_ERROR("no valid endpoint node\n");
>                 return ERR_PTR(-ENODEV);
>         }
> -       of_node_put(endpoint);
>
>         remote = of_graph_get_remote_port_parent(endpoint);
> +       of_node_put(endpoint);

Another bug that's being fixed without mention in the commit.

>         if (!remote) {
>                 DRM_ERROR("no valid remote node\n");
>                 return ERR_PTR(-ENODEV);
>         }
> -       of_node_put(remote);
>
>         if (!of_device_is_available(remote)) {
>                 DRM_ERROR("not available for remote node\n");
> @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>         if (IS_ERR(remote))
>                 return PTR_ERR(remote);
>
> -       component_match_add(dev, &match, compare_of, remote);
> +       drm_of_component_match_add(dev, &match, compare_of, remote);
> +       of_node_put(remote);
>
>         return component_master_add_with_match(dev, &kirin_drm_ops, match);
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cf83f6507ec8..9c5430fb82a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
>  #include <linux/of_address.h>
> @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>                     comp_type == MTK_DPI) {
>                         dev_info(dev, "Adding component match for %s\n",
>                                  node->full_name);
> -                       component_match_add(dev, &match, compare_of, node);
> +                       drm_of_component_match_add(dev, &match, compare_of,
> +                                                  node);
>                 } else {
>                         struct mtk_ddp_comp *comp;
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index fb5c0b0a7594..84d38eaea585 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include <drm/drm_of.h>
> +
>  #include "msm_drv.h"
>  #include "msm_debugfs.h"
>  #include "msm_fence.h"
> @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>                         continue;
>                 }
>
> -               component_match_add(master_dev, matchptr, compare_of, intf);
> -
> +               drm_of_component_match_add(master_dev, matchptr, compare_of,
> +                                          intf);
>                 of_node_put(intf);
>                 of_node_put(ep_node);
>         }
> @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>                 put_device(mdp_dev);
>
>                 /* add the MDP component itself */
> -               component_match_add(dev, matchptr, compare_of,
> -                                   mdp_dev->of_node);
> +               drm_of_component_match_add(dev, matchptr, compare_of,
> +                                          mdp_dev->of_node);
>         } else {
>                 /* MDP4 */
>                 mdp_dev = dev;
> @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>         if (!np)
>                 return 0;
>
> -       component_match_add(dev, matchptr, compare_of, np);
> +       drm_of_component_match_add(dev, matchptr, compare_of, np);
>
>         of_node_put(np);
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 8c8cbe837e61..6fe161192bb4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -20,6 +20,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, match, compare_of, remote);
> +               drm_of_component_match_add(dev, match, compare_of, remote);
>                 of_node_put(remote);
>         }
>  }
> @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>                 }
>
>                 of_node_put(iommu);
> -               component_match_add(dev, &match, compare_of, port->parent);
> +               drm_of_component_match_add(dev, &match, compare_of,
> +                                          port->parent);
>                 of_node_put(port);
>         }
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 2784919a7366..5e819876e642 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -17,6 +17,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "sti_crtc.h"
>  #include "sti_drv.h"
> @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>         child_np = of_get_next_available_child(node, NULL);
>
>         while (child_np) {
> -               component_match_add(dev, &match, compare_of, child_np);
> -               of_node_put(child_np);
> +               drm_of_component_match_add(dev, &match, compare_of,
> +                                          child_np);
>                 child_np = of_get_next_available_child(node, child_np);
>         }
>
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 0da9862ad8ed..b3c4ad605e81 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "sun4i_crtc.h"
>  #include "sun4i_drv.h"
> @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>                 /* Add current component */
>                 DRM_DEBUG_DRIVER("Adding component %s\n",
>                                  of_node_full_name(node));
> -               component_match_add(dev, match, compare_of, node);
> +               drm_of_component_match_add(dev, match, compare_of, node);
>                 count++;
>         }
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 68e895021005..06a4c584f3cb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -10,6 +10,7 @@
>
>  #include <linux/component.h>
>  #include <linux/of_graph.h>
> +#include <drm/drm_of.h>
>
>  #include "tilcdc_drv.h"
>  #include "tilcdc_external.h"
> @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>
>                 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>                 if (match)
> -                       component_match_add(dev, match, dev_match_of, node);
> +                       drm_of_component_match_add(dev, match, dev_match_of,
> +                                                  node);
>                 of_node_put(node);
>                 count++;
>         }
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 3fd87b386ed7..d6b4c5587bbe 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -4,6 +4,7 @@
>  #include <linux/of_graph.h>
>
>  struct component_master_ops;
> +struct component_match;
>  struct device;
>  struct drm_device;
>  struct drm_encoder;
> @@ -12,6 +13,10 @@ struct device_node;
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>                                            struct device_node *port);
> +extern void drm_of_component_match_add(struct device *master,
> +                                      struct component_match **matchptr,
> +                                      int (*compare)(struct device *, void *),
> +                                      struct device_node *node);
>  extern int drm_of_component_probe(struct device *dev,
>                                   int (*compare_of)(struct device *, void *),
>                                   const struct component_master_ops *m_ops);
> @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>         return 0;
>  }
>
> +static void drm_of_component_match_add(struct device *master,
> +                                      struct component_match **matchptr,
> +                                      int (*compare)(struct device *, void *),
> +                                      struct device_node *node)
> +{
> +}
> +
>  static inline int
>  drm_of_component_probe(struct device *dev,
>                        int (*compare_of)(struct device *, void *),
> --
> 2.1.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-20 20:39   ` Sean Paul
  0 siblings, 0 replies; 56+ messages in thread
From: Sean Paul @ 2016-10-20 20:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 19, 2016 at 6:28 AM, Russell King
<rmk+kernel@armlinux.org.uk> wrote:
> Convert DT component matching to use component_match_add_release().
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.

I think Daniel explained pretty clearly why this wasn't happening in
the previous thread.

Next time you send a v2, can you please mark it as such and include a
"Changes in v2" section?

>
>  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>  include/drm/drm_of.h                            | 12 +++++++++++
>  13 files changed, 73 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>                 return -EAGAIN;
>         }
>
> -       component_match_add(&pdev->dev, &match, compare_dev, port);
> +       drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> +       of_node_put(port);

There's no mention in your commit message about fixing these node leaks.

>
>         return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>                                                match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>                 return -EAGAIN;
>         }
>
> -       component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> +       drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> +                                  port);
> +       of_node_put(port);
>         return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>                                                match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, match, compare_of, remote);
> +               drm_of_component_match_add(dev, match, compare_of, remote);
>                 of_node_put(remote);
>         }
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +       of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +                               struct component_match **matchptr,
> +                               int (*compare)(struct device *, void *),
> +                               struct device_node *node)
> +{
> +       of_node_get(node);
> +       component_match_add_release(master, matchptr, drm_release_of,
> +                                   compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, &match, compare_of, port);
> +               drm_of_component_match_add(dev, &match, compare_of, port);
>                 of_node_put(port);
>         }
>
> @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>                                 continue;
>                         }
>
> -                       component_match_add(dev, &match, compare_of, remote);
> +                       drm_of_component_match_add(dev, &match, compare_of,
> +                                                  remote);
>                         of_node_put(remote);
>                 }
>                 of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index aa687669e22b..0dee6acbd880 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -16,6 +16,7 @@
>
>  #include <linux/component.h>
>  #include <linux/of_platform.h>
> +#include <drm/drm_of.h>
>
>  #include "etnaviv_drv.h"
>  #include "etnaviv_gpu.h"
> @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>                         if (!core_node)
>                                 break;
>
> -                       component_match_add(&pdev->dev, &match, compare_of,
> -                                           core_node);
> +                       drm_of_component_match_add(&pdev->dev, &match,
> +                                                  compare_of, core_node);
>                         of_node_put(core_node);
>                 }
>         } else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 90377a609c98..e88fde18c946 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -24,6 +24,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "kirin_drm_drv.h"
>
> @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>                 DRM_ERROR("no valid endpoint node\n");
>                 return ERR_PTR(-ENODEV);
>         }
> -       of_node_put(endpoint);
>
>         remote = of_graph_get_remote_port_parent(endpoint);
> +       of_node_put(endpoint);

Another bug that's being fixed without mention in the commit.

>         if (!remote) {
>                 DRM_ERROR("no valid remote node\n");
>                 return ERR_PTR(-ENODEV);
>         }
> -       of_node_put(remote);
>
>         if (!of_device_is_available(remote)) {
>                 DRM_ERROR("not available for remote node\n");
> @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>         if (IS_ERR(remote))
>                 return PTR_ERR(remote);
>
> -       component_match_add(dev, &match, compare_of, remote);
> +       drm_of_component_match_add(dev, &match, compare_of, remote);
> +       of_node_put(remote);
>
>         return component_master_add_with_match(dev, &kirin_drm_ops, match);
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cf83f6507ec8..9c5430fb82a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
>  #include <linux/of_address.h>
> @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>                     comp_type == MTK_DPI) {
>                         dev_info(dev, "Adding component match for %s\n",
>                                  node->full_name);
> -                       component_match_add(dev, &match, compare_of, node);
> +                       drm_of_component_match_add(dev, &match, compare_of,
> +                                                  node);
>                 } else {
>                         struct mtk_ddp_comp *comp;
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index fb5c0b0a7594..84d38eaea585 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include <drm/drm_of.h>
> +
>  #include "msm_drv.h"
>  #include "msm_debugfs.h"
>  #include "msm_fence.h"
> @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>                         continue;
>                 }
>
> -               component_match_add(master_dev, matchptr, compare_of, intf);
> -
> +               drm_of_component_match_add(master_dev, matchptr, compare_of,
> +                                          intf);
>                 of_node_put(intf);
>                 of_node_put(ep_node);
>         }
> @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>                 put_device(mdp_dev);
>
>                 /* add the MDP component itself */
> -               component_match_add(dev, matchptr, compare_of,
> -                                   mdp_dev->of_node);
> +               drm_of_component_match_add(dev, matchptr, compare_of,
> +                                          mdp_dev->of_node);
>         } else {
>                 /* MDP4 */
>                 mdp_dev = dev;
> @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>         if (!np)
>                 return 0;
>
> -       component_match_add(dev, matchptr, compare_of, np);
> +       drm_of_component_match_add(dev, matchptr, compare_of, np);
>
>         of_node_put(np);
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 8c8cbe837e61..6fe161192bb4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -20,6 +20,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>                         continue;
>                 }
>
> -               component_match_add(dev, match, compare_of, remote);
> +               drm_of_component_match_add(dev, match, compare_of, remote);
>                 of_node_put(remote);
>         }
>  }
> @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>                 }
>
>                 of_node_put(iommu);
> -               component_match_add(dev, &match, compare_of, port->parent);
> +               drm_of_component_match_add(dev, &match, compare_of,
> +                                          port->parent);
>                 of_node_put(port);
>         }
>
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 2784919a7366..5e819876e642 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -17,6 +17,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "sti_crtc.h"
>  #include "sti_drv.h"
> @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>         child_np = of_get_next_available_child(node, NULL);
>
>         while (child_np) {
> -               component_match_add(dev, &match, compare_of, child_np);
> -               of_node_put(child_np);
> +               drm_of_component_match_add(dev, &match, compare_of,
> +                                          child_np);
>                 child_np = of_get_next_available_child(node, child_np);
>         }
>
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 0da9862ad8ed..b3c4ad605e81 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_of.h>
>
>  #include "sun4i_crtc.h"
>  #include "sun4i_drv.h"
> @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>                 /* Add current component */
>                 DRM_DEBUG_DRIVER("Adding component %s\n",
>                                  of_node_full_name(node));
> -               component_match_add(dev, match, compare_of, node);
> +               drm_of_component_match_add(dev, match, compare_of, node);
>                 count++;
>         }
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 68e895021005..06a4c584f3cb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -10,6 +10,7 @@
>
>  #include <linux/component.h>
>  #include <linux/of_graph.h>
> +#include <drm/drm_of.h>
>
>  #include "tilcdc_drv.h"
>  #include "tilcdc_external.h"
> @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>
>                 dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>                 if (match)
> -                       component_match_add(dev, match, dev_match_of, node);
> +                       drm_of_component_match_add(dev, match, dev_match_of,
> +                                                  node);
>                 of_node_put(node);
>                 count++;
>         }
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 3fd87b386ed7..d6b4c5587bbe 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -4,6 +4,7 @@
>  #include <linux/of_graph.h>
>
>  struct component_master_ops;
> +struct component_match;
>  struct device;
>  struct drm_device;
>  struct drm_encoder;
> @@ -12,6 +13,10 @@ struct device_node;
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>                                            struct device_node *port);
> +extern void drm_of_component_match_add(struct device *master,
> +                                      struct component_match **matchptr,
> +                                      int (*compare)(struct device *, void *),
> +                                      struct device_node *node);
>  extern int drm_of_component_probe(struct device *dev,
>                                   int (*compare_of)(struct device *, void *),
>                                   const struct component_master_ops *m_ops);
> @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>         return 0;
>  }
>
> +static void drm_of_component_match_add(struct device *master,
> +                                      struct component_match **matchptr,
> +                                      int (*compare)(struct device *, void *),
> +                                      struct device_node *node)
> +{
> +}
> +
>  static inline int
>  drm_of_component_probe(struct device *dev,
>                        int (*compare_of)(struct device *, void *),
> --
> 2.1.0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] drm: convert DT component matching to component_match_add_release()
  2016-10-19 10:28 ` Russell King
@ 2016-10-20  6:36   ` Daniel Vetter
  -1 siblings, 0 replies; 56+ messages in thread
From: Daniel Vetter @ 2016-10-20  6:36 UTC (permalink / raw)
  To: Russell King
  Cc: dri-devel, David Airlie, Liviu Dudau, Chen-Yu Tsai, Xinliang Liu,
	linux-rockchip, Tomi Valkeinen, Mali DP Maintainers,
	linux-arm-msm, Chen Feng, Jyri Sarha, linux-mediatek,
	Matthias Brugger, Vincent Abriou, linux-arm-kernel,
	Maxime Ripard, freedreno

On Wed, Oct 19, 2016 at 11:28:27AM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.

Can pick, once someone from the arm world smashes at least an ack on this.
But I have no clue about of/DT, so won't just merge it.

And yes drm-misc will get a MAINTAINERS entry, after ks, because there's
some things to discuss about what that one needs to look like.
-Daniel

> 
>  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>  include/drm/drm_of.h                            | 12 +++++++++++
>  13 files changed, 73 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> +	of_node_put(port);
>  
>  	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  					       match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> +	drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> +				   port);
> +	of_node_put(port);
>  	return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>  					       match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		drm_of_component_match_add(dev, match, compare_of, remote);
>  		of_node_put(remote);
>  	}
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>  
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>  
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +				struct component_match **matchptr,
> +				int (*compare)(struct device *, void *),
> +				struct device_node *node)
> +{
> +	of_node_get(node);
> +	component_match_add_release(master, matchptr, drm_release_of,
> +				    compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port);
> +		drm_of_component_match_add(dev, &match, compare_of, port);
>  		of_node_put(port);
>  	}
>  
> @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>  				continue;
>  			}
>  
> -			component_match_add(dev, &match, compare_of, remote);
> +			drm_of_component_match_add(dev, &match, compare_of,
> +						   remote);
>  			of_node_put(remote);
>  		}
>  		of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index aa687669e22b..0dee6acbd880 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -16,6 +16,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/of_platform.h>
> +#include <drm/drm_of.h>
>  
>  #include "etnaviv_drv.h"
>  #include "etnaviv_gpu.h"
> @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>  			if (!core_node)
>  				break;
>  
> -			component_match_add(&pdev->dev, &match, compare_of,
> -					    core_node);
> +			drm_of_component_match_add(&pdev->dev, &match,
> +						   compare_of, core_node);
>  			of_node_put(core_node);
>  		}
>  	} else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 90377a609c98..e88fde18c946 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -24,6 +24,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "kirin_drm_drv.h"
>  
> @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>  		DRM_ERROR("no valid endpoint node\n");
>  		return ERR_PTR(-ENODEV);
>  	}
> -	of_node_put(endpoint);
>  
>  	remote = of_graph_get_remote_port_parent(endpoint);
> +	of_node_put(endpoint);
>  	if (!remote) {
>  		DRM_ERROR("no valid remote node\n");
>  		return ERR_PTR(-ENODEV);
>  	}
> -	of_node_put(remote);
>  
>  	if (!of_device_is_available(remote)) {
>  		DRM_ERROR("not available for remote node\n");
> @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>  	if (IS_ERR(remote))
>  		return PTR_ERR(remote);
>  
> -	component_match_add(dev, &match, compare_of, remote);
> +	drm_of_component_match_add(dev, &match, compare_of, remote);
> +	of_node_put(remote);
>  
>  	return component_master_add_with_match(dev, &kirin_drm_ops, match);
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cf83f6507ec8..9c5430fb82a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
>  #include <linux/of_address.h>
> @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>  		    comp_type == MTK_DPI) {
>  			dev_info(dev, "Adding component match for %s\n",
>  				 node->full_name);
> -			component_match_add(dev, &match, compare_of, node);
> +			drm_of_component_match_add(dev, &match, compare_of,
> +						   node);
>  		} else {
>  			struct mtk_ddp_comp *comp;
>  
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index fb5c0b0a7594..84d38eaea585 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> +#include <drm/drm_of.h>
> +
>  #include "msm_drv.h"
>  #include "msm_debugfs.h"
>  #include "msm_fence.h"
> @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>  			continue;
>  		}
>  
> -		component_match_add(master_dev, matchptr, compare_of, intf);
> -
> +		drm_of_component_match_add(master_dev, matchptr, compare_of,
> +					   intf);
>  		of_node_put(intf);
>  		of_node_put(ep_node);
>  	}
> @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>  		put_device(mdp_dev);
>  
>  		/* add the MDP component itself */
> -		component_match_add(dev, matchptr, compare_of,
> -				    mdp_dev->of_node);
> +		drm_of_component_match_add(dev, matchptr, compare_of,
> +					   mdp_dev->of_node);
>  	} else {
>  		/* MDP4 */
>  		mdp_dev = dev;
> @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>  	if (!np)
>  		return 0;
>  
> -	component_match_add(dev, matchptr, compare_of, np);
> +	drm_of_component_match_add(dev, matchptr, compare_of, np);
>  
>  	of_node_put(np);
>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 8c8cbe837e61..6fe161192bb4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -20,6 +20,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		drm_of_component_match_add(dev, match, compare_of, remote);
>  		of_node_put(remote);
>  	}
>  }
> @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>  		}
>  
>  		of_node_put(iommu);
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		drm_of_component_match_add(dev, &match, compare_of,
> +					   port->parent);
>  		of_node_put(port);
>  	}
>  
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 2784919a7366..5e819876e642 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -17,6 +17,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "sti_crtc.h"
>  #include "sti_drv.h"
> @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>  	child_np = of_get_next_available_child(node, NULL);
>  
>  	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		drm_of_component_match_add(dev, &match, compare_of,
> +					   child_np);
>  		child_np = of_get_next_available_child(node, child_np);
>  	}
>  
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 0da9862ad8ed..b3c4ad605e81 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "sun4i_crtc.h"
>  #include "sun4i_drv.h"
> @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>  		/* Add current component */
>  		DRM_DEBUG_DRIVER("Adding component %s\n",
>  				 of_node_full_name(node));
> -		component_match_add(dev, match, compare_of, node);
> +		drm_of_component_match_add(dev, match, compare_of, node);
>  		count++;
>  	}
>  
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 68e895021005..06a4c584f3cb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -10,6 +10,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/of_graph.h>
> +#include <drm/drm_of.h>
>  
>  #include "tilcdc_drv.h"
>  #include "tilcdc_external.h"
> @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>  
>  		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>  		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> +			drm_of_component_match_add(dev, match, dev_match_of,
> +						   node);
>  		of_node_put(node);
>  		count++;
>  	}
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 3fd87b386ed7..d6b4c5587bbe 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -4,6 +4,7 @@
>  #include <linux/of_graph.h>
>  
>  struct component_master_ops;
> +struct component_match;
>  struct device;
>  struct drm_device;
>  struct drm_encoder;
> @@ -12,6 +13,10 @@ struct device_node;
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  					   struct device_node *port);
> +extern void drm_of_component_match_add(struct device *master,
> +				       struct component_match **matchptr,
> +				       int (*compare)(struct device *, void *),
> +				       struct device_node *node);
>  extern int drm_of_component_probe(struct device *dev,
>  				  int (*compare_of)(struct device *, void *),
>  				  const struct component_master_ops *m_ops);
> @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  	return 0;
>  }
>  
> +static void drm_of_component_match_add(struct device *master,
> +				       struct component_match **matchptr,
> +				       int (*compare)(struct device *, void *),
> +				       struct device_node *node)
> +{
> +}
> +
>  static inline int
>  drm_of_component_probe(struct device *dev,
>  		       int (*compare_of)(struct device *, void *),
> -- 
> 2.1.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-20  6:36   ` Daniel Vetter
  0 siblings, 0 replies; 56+ messages in thread
From: Daniel Vetter @ 2016-10-20  6:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 19, 2016 at 11:28:27AM +0100, Russell King wrote:
> Convert DT component matching to use component_match_add_release().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> ---
> Can we please get this patch from May merged into the drm-misc or
> whatever trees so that we don't end up with conflicts?  I've no idea
> who looks after drm-misc, as they have _still_ failed to add
> themselves to MAINTAINERS.

Can pick, once someone from the arm world smashes at least an ack on this.
But I have no clue about of/DT, so won't just merge it.

And yes drm-misc will get a MAINTAINERS entry, after ks, because there's
some things to discuss about what that one needs to look like.
-Daniel

> 
>  drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
>  drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
>  drivers/gpu/drm/armada/armada_drv.c             |  2 +-
>  drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
>  drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
>  drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
>  drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
>  drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
>  drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
>  drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
>  include/drm/drm_of.h                            | 12 +++++++++++
>  13 files changed, 73 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
> index fb6a418ce6be..6477d1a65266 100644
> --- a/drivers/gpu/drm/arm/hdlcd_drv.c
> +++ b/drivers/gpu/drm/arm/hdlcd_drv.c
> @@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, compare_dev, port);
> +	drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
> +	of_node_put(port);
>  
>  	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
>  					       match);
> diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
> index 9280358b8f15..9f4739452a25 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.c
> +++ b/drivers/gpu/drm/arm/malidp_drv.c
> @@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
>  		return -EAGAIN;
>  	}
>  
> -	component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
> +	drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
> +				   port);
> +	of_node_put(port);
>  	return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
>  					       match);
>  }
> diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
> index 1e0e68f608e4..94e46da9a758 100644
> --- a/drivers/gpu/drm/armada/armada_drv.c
> +++ b/drivers/gpu/drm/armada/armada_drv.c
> @@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		drm_of_component_match_add(dev, match, compare_of, remote);
>  		of_node_put(remote);
>  	}
>  }
> diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
> index bc98bb94264d..47848ed8ca48 100644
> --- a/drivers/gpu/drm/drm_of.c
> +++ b/drivers/gpu/drm/drm_of.c
> @@ -6,6 +6,11 @@
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_of.h>
>  
> +static void drm_release_of(struct device *dev, void *data)
> +{
> +	of_node_put(data);
> +}
> +
>  /**
>   * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
>   * @dev: DRM device
> @@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  EXPORT_SYMBOL(drm_of_find_possible_crtcs);
>  
>  /**
> + * drm_of_component_match_add - Add a component helper OF node match rule
> + * @master: master device
> + * @matchptr: component match pointer
> + * @compare: compare function used for matching component
> + * @node: of_node
> + */
> +void drm_of_component_match_add(struct device *master,
> +				struct component_match **matchptr,
> +				int (*compare)(struct device *, void *),
> +				struct device_node *node)
> +{
> +	of_node_get(node);
> +	component_match_add_release(master, matchptr, drm_release_of,
> +				    compare, node);
> +}
> +EXPORT_SYMBOL_GPL(drm_of_component_match_add);
> +
> +/**
>   * drm_of_component_probe - Generic probe function for a component based master
>   * @dev: master device containing the OF node
>   * @compare_of: compare function used for matching components
> @@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, &match, compare_of, port);
> +		drm_of_component_match_add(dev, &match, compare_of, port);
>  		of_node_put(port);
>  	}
>  
> @@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
>  				continue;
>  			}
>  
> -			component_match_add(dev, &match, compare_of, remote);
> +			drm_of_component_match_add(dev, &match, compare_of,
> +						   remote);
>  			of_node_put(remote);
>  		}
>  		of_node_put(port);
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> index aa687669e22b..0dee6acbd880 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> @@ -16,6 +16,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/of_platform.h>
> +#include <drm/drm_of.h>
>  
>  #include "etnaviv_drv.h"
>  #include "etnaviv_gpu.h"
> @@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
>  			if (!core_node)
>  				break;
>  
> -			component_match_add(&pdev->dev, &match, compare_of,
> -					    core_node);
> +			drm_of_component_match_add(&pdev->dev, &match,
> +						   compare_of, core_node);
>  			of_node_put(core_node);
>  		}
>  	} else if (dev->platform_data) {
> diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> index 90377a609c98..e88fde18c946 100644
> --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> @@ -24,6 +24,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_atomic_helper.h>
>  #include <drm/drm_crtc_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "kirin_drm_drv.h"
>  
> @@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
>  		DRM_ERROR("no valid endpoint node\n");
>  		return ERR_PTR(-ENODEV);
>  	}
> -	of_node_put(endpoint);
>  
>  	remote = of_graph_get_remote_port_parent(endpoint);
> +	of_node_put(endpoint);
>  	if (!remote) {
>  		DRM_ERROR("no valid remote node\n");
>  		return ERR_PTR(-ENODEV);
>  	}
> -	of_node_put(remote);
>  
>  	if (!of_device_is_available(remote)) {
>  		DRM_ERROR("not available for remote node\n");
> @@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
>  	if (IS_ERR(remote))
>  		return PTR_ERR(remote);
>  
> -	component_match_add(dev, &match, compare_of, remote);
> +	drm_of_component_match_add(dev, &match, compare_of, remote);
> +	of_node_put(remote);
>  
>  	return component_master_add_with_match(dev, &kirin_drm_ops, match);
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index cf83f6507ec8..9c5430fb82a2 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
>  #include <linux/of_address.h>
> @@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
>  		    comp_type == MTK_DPI) {
>  			dev_info(dev, "Adding component match for %s\n",
>  				 node->full_name);
> -			component_match_add(dev, &match, compare_of, node);
> +			drm_of_component_match_add(dev, &match, compare_of,
> +						   node);
>  		} else {
>  			struct mtk_ddp_comp *comp;
>  
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index fb5c0b0a7594..84d38eaea585 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -15,6 +15,8 @@
>   * this program.  If not, see <http://www.gnu.org/licenses/>.
>   */
>  
> +#include <drm/drm_of.h>
> +
>  #include "msm_drv.h"
>  #include "msm_debugfs.h"
>  #include "msm_fence.h"
> @@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
>  			continue;
>  		}
>  
> -		component_match_add(master_dev, matchptr, compare_of, intf);
> -
> +		drm_of_component_match_add(master_dev, matchptr, compare_of,
> +					   intf);
>  		of_node_put(intf);
>  		of_node_put(ep_node);
>  	}
> @@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
>  		put_device(mdp_dev);
>  
>  		/* add the MDP component itself */
> -		component_match_add(dev, matchptr, compare_of,
> -				    mdp_dev->of_node);
> +		drm_of_component_match_add(dev, matchptr, compare_of,
> +					   mdp_dev->of_node);
>  	} else {
>  		/* MDP4 */
>  		mdp_dev = dev;
> @@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
>  	if (!np)
>  		return 0;
>  
> -	component_match_add(dev, matchptr, compare_of, np);
> +	drm_of_component_match_add(dev, matchptr, compare_of, np);
>  
>  	of_node_put(np);
>  
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> index 8c8cbe837e61..6fe161192bb4 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
> @@ -20,6 +20,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_of.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/module.h>
> @@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
>  			continue;
>  		}
>  
> -		component_match_add(dev, match, compare_of, remote);
> +		drm_of_component_match_add(dev, match, compare_of, remote);
>  		of_node_put(remote);
>  	}
>  }
> @@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
>  		}
>  
>  		of_node_put(iommu);
> -		component_match_add(dev, &match, compare_of, port->parent);
> +		drm_of_component_match_add(dev, &match, compare_of,
> +					   port->parent);
>  		of_node_put(port);
>  	}
>  
> diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> index 2784919a7366..5e819876e642 100644
> --- a/drivers/gpu/drm/sti/sti_drv.c
> +++ b/drivers/gpu/drm/sti/sti_drv.c
> @@ -17,6 +17,7 @@
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "sti_crtc.h"
>  #include "sti_drv.h"
> @@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
>  	child_np = of_get_next_available_child(node, NULL);
>  
>  	while (child_np) {
> -		component_match_add(dev, &match, compare_of, child_np);
> -		of_node_put(child_np);
> +		drm_of_component_match_add(dev, &match, compare_of,
> +					   child_np);
>  		child_np = of_get_next_available_child(node, child_np);
>  	}
>  
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 0da9862ad8ed..b3c4ad605e81 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -18,6 +18,7 @@
>  #include <drm/drm_fb_cma_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_helper.h>
> +#include <drm/drm_of.h>
>  
>  #include "sun4i_crtc.h"
>  #include "sun4i_drv.h"
> @@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
>  		/* Add current component */
>  		DRM_DEBUG_DRIVER("Adding component %s\n",
>  				 of_node_full_name(node));
> -		component_match_add(dev, match, compare_of, node);
> +		drm_of_component_match_add(dev, match, compare_of, node);
>  		count++;
>  	}
>  
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 68e895021005..06a4c584f3cb 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -10,6 +10,7 @@
>  
>  #include <linux/component.h>
>  #include <linux/of_graph.h>
> +#include <drm/drm_of.h>
>  
>  #include "tilcdc_drv.h"
>  #include "tilcdc_external.h"
> @@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
>  
>  		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
>  		if (match)
> -			component_match_add(dev, match, dev_match_of, node);
> +			drm_of_component_match_add(dev, match, dev_match_of,
> +						   node);
>  		of_node_put(node);
>  		count++;
>  	}
> diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
> index 3fd87b386ed7..d6b4c5587bbe 100644
> --- a/include/drm/drm_of.h
> +++ b/include/drm/drm_of.h
> @@ -4,6 +4,7 @@
>  #include <linux/of_graph.h>
>  
>  struct component_master_ops;
> +struct component_match;
>  struct device;
>  struct drm_device;
>  struct drm_encoder;
> @@ -12,6 +13,10 @@ struct device_node;
>  #ifdef CONFIG_OF
>  extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  					   struct device_node *port);
> +extern void drm_of_component_match_add(struct device *master,
> +				       struct component_match **matchptr,
> +				       int (*compare)(struct device *, void *),
> +				       struct device_node *node);
>  extern int drm_of_component_probe(struct device *dev,
>  				  int (*compare_of)(struct device *, void *),
>  				  const struct component_master_ops *m_ops);
> @@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
>  	return 0;
>  }
>  
> +static void drm_of_component_match_add(struct device *master,
> +				       struct component_match **matchptr,
> +				       int (*compare)(struct device *, void *),
> +				       struct device_node *node)
> +{
> +}
> +
>  static inline int
>  drm_of_component_probe(struct device *dev,
>  		       int (*compare_of)(struct device *, void *),
> -- 
> 2.1.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-19 10:28 ` Russell King
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-10-19 10:28 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, David Airlie
  Cc: Heiko Stuebner, Liviu Dudau, Benjamin Gaignard, Chen-Yu Tsai,
	Xinliang Liu, linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Xinwei Kong, Tomi Valkeinen, Mali DP Maintainers,
	linux-arm-msm-u79uwXL29TY76Z2rM5mHXA, CK Hu, Chen Feng,
	Jyri Sarha, Christian Gmeiner,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	Matthias Brugger, Vincent Abriou,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Mark Yao,
	Rob Clark, Philipp Zabel, Maxime Ripard,
	freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Bria

Convert DT component matching to use component_match_add_release().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
Can we please get this patch from May merged into the drm-misc or
whatever trees so that we don't end up with conflicts?  I've no idea
who looks after drm-misc, as they have _still_ failed to add
themselves to MAINTAINERS.

 drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
 drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
 drivers/gpu/drm/armada/armada_drv.c             |  2 +-
 drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
 drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
 drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
 drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
 drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
 drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
 include/drm/drm_of.h                            | 12 +++++++++++
 13 files changed, 73 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index fb6a418ce6be..6477d1a65266 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
 		return -EAGAIN;
 	}
 
-	component_match_add(&pdev->dev, &match, compare_dev, port);
+	drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
+	of_node_put(port);
 
 	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
 					       match);
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 9280358b8f15..9f4739452a25 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
 		return -EAGAIN;
 	}
 
-	component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
+	drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
+				   port);
+	of_node_put(port);
 	return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
 					       match);
 }
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 1e0e68f608e4..94e46da9a758 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
+		drm_of_component_match_add(dev, match, compare_of, remote);
 		of_node_put(remote);
 	}
 }
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index bc98bb94264d..47848ed8ca48 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -6,6 +6,11 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_of.h>
 
+static void drm_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 /**
  * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
  * @dev: DRM device
@@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
 EXPORT_SYMBOL(drm_of_find_possible_crtcs);
 
 /**
+ * drm_of_component_match_add - Add a component helper OF node match rule
+ * @master: master device
+ * @matchptr: component match pointer
+ * @compare: compare function used for matching component
+ * @node: of_node
+ */
+void drm_of_component_match_add(struct device *master,
+				struct component_match **matchptr,
+				int (*compare)(struct device *, void *),
+				struct device_node *node)
+{
+	of_node_get(node);
+	component_match_add_release(master, matchptr, drm_release_of,
+				    compare, node);
+}
+EXPORT_SYMBOL_GPL(drm_of_component_match_add);
+
+/**
  * drm_of_component_probe - Generic probe function for a component based master
  * @dev: master device containing the OF node
  * @compare_of: compare function used for matching components
@@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, &match, compare_of, port);
+		drm_of_component_match_add(dev, &match, compare_of, port);
 		of_node_put(port);
 	}
 
@@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
 				continue;
 			}
 
-			component_match_add(dev, &match, compare_of, remote);
+			drm_of_component_match_add(dev, &match, compare_of,
+						   remote);
 			of_node_put(remote);
 		}
 		of_node_put(port);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index aa687669e22b..0dee6acbd880 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -16,6 +16,7 @@
 
 #include <linux/component.h>
 #include <linux/of_platform.h>
+#include <drm/drm_of.h>
 
 #include "etnaviv_drv.h"
 #include "etnaviv_gpu.h"
@@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
 			if (!core_node)
 				break;
 
-			component_match_add(&pdev->dev, &match, compare_of,
-					    core_node);
+			drm_of_component_match_add(&pdev->dev, &match,
+						   compare_of, core_node);
 			of_node_put(core_node);
 		}
 	} else if (dev->platform_data) {
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 90377a609c98..e88fde18c946 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -24,6 +24,7 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_of.h>
 
 #include "kirin_drm_drv.h"
 
@@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
 		DRM_ERROR("no valid endpoint node\n");
 		return ERR_PTR(-ENODEV);
 	}
-	of_node_put(endpoint);
 
 	remote = of_graph_get_remote_port_parent(endpoint);
+	of_node_put(endpoint);
 	if (!remote) {
 		DRM_ERROR("no valid remote node\n");
 		return ERR_PTR(-ENODEV);
 	}
-	of_node_put(remote);
 
 	if (!of_device_is_available(remote)) {
 		DRM_ERROR("not available for remote node\n");
@@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
 	if (IS_ERR(remote))
 		return PTR_ERR(remote);
 
-	component_match_add(dev, &match, compare_of, remote);
+	drm_of_component_match_add(dev, &match, compare_of, remote);
+	of_node_put(remote);
 
 	return component_master_add_with_match(dev, &kirin_drm_ops, match);
 
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index cf83f6507ec8..9c5430fb82a2 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -18,6 +18,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_of.h>
 #include <linux/component.h>
 #include <linux/iommu.h>
 #include <linux/of_address.h>
@@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
 		    comp_type == MTK_DPI) {
 			dev_info(dev, "Adding component match for %s\n",
 				 node->full_name);
-			component_match_add(dev, &match, compare_of, node);
+			drm_of_component_match_add(dev, &match, compare_of,
+						   node);
 		} else {
 			struct mtk_ddp_comp *comp;
 
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index fb5c0b0a7594..84d38eaea585 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -15,6 +15,8 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <drm/drm_of.h>
+
 #include "msm_drv.h"
 #include "msm_debugfs.h"
 #include "msm_fence.h"
@@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
 			continue;
 		}
 
-		component_match_add(master_dev, matchptr, compare_of, intf);
-
+		drm_of_component_match_add(master_dev, matchptr, compare_of,
+					   intf);
 		of_node_put(intf);
 		of_node_put(ep_node);
 	}
@@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
 		put_device(mdp_dev);
 
 		/* add the MDP component itself */
-		component_match_add(dev, matchptr, compare_of,
-				    mdp_dev->of_node);
+		drm_of_component_match_add(dev, matchptr, compare_of,
+					   mdp_dev->of_node);
 	} else {
 		/* MDP4 */
 		mdp_dev = dev;
@@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
 	if (!np)
 		return 0;
 
-	component_match_add(dev, matchptr, compare_of, np);
+	drm_of_component_match_add(dev, matchptr, compare_of, np);
 
 	of_node_put(np);
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 8c8cbe837e61..6fe161192bb4 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -20,6 +20,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_of.h>
 #include <linux/dma-mapping.h>
 #include <linux/pm_runtime.h>
 #include <linux/module.h>
@@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
+		drm_of_component_match_add(dev, match, compare_of, remote);
 		of_node_put(remote);
 	}
 }
@@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
 		}
 
 		of_node_put(iommu);
-		component_match_add(dev, &match, compare_of, port->parent);
+		drm_of_component_match_add(dev, &match, compare_of,
+					   port->parent);
 		of_node_put(port);
 	}
 
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 2784919a7366..5e819876e642 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -17,6 +17,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_of.h>
 
 #include "sti_crtc.h"
 #include "sti_drv.h"
@@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
 	child_np = of_get_next_available_child(node, NULL);
 
 	while (child_np) {
-		component_match_add(dev, &match, compare_of, child_np);
-		of_node_put(child_np);
+		drm_of_component_match_add(dev, &match, compare_of,
+					   child_np);
 		child_np = of_get_next_available_child(node, child_np);
 	}
 
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 0da9862ad8ed..b3c4ad605e81 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -18,6 +18,7 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_of.h>
 
 #include "sun4i_crtc.h"
 #include "sun4i_drv.h"
@@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
 		/* Add current component */
 		DRM_DEBUG_DRIVER("Adding component %s\n",
 				 of_node_full_name(node));
-		component_match_add(dev, match, compare_of, node);
+		drm_of_component_match_add(dev, match, compare_of, node);
 		count++;
 	}
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 68e895021005..06a4c584f3cb 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -10,6 +10,7 @@
 
 #include <linux/component.h>
 #include <linux/of_graph.h>
+#include <drm/drm_of.h>
 
 #include "tilcdc_drv.h"
 #include "tilcdc_external.h"
@@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
 
 		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
 		if (match)
-			component_match_add(dev, match, dev_match_of, node);
+			drm_of_component_match_add(dev, match, dev_match_of,
+						   node);
 		of_node_put(node);
 		count++;
 	}
diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
index 3fd87b386ed7..d6b4c5587bbe 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -4,6 +4,7 @@
 #include <linux/of_graph.h>
 
 struct component_master_ops;
+struct component_match;
 struct device;
 struct drm_device;
 struct drm_encoder;
@@ -12,6 +13,10 @@ struct device_node;
 #ifdef CONFIG_OF
 extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
 					   struct device_node *port);
+extern void drm_of_component_match_add(struct device *master,
+				       struct component_match **matchptr,
+				       int (*compare)(struct device *, void *),
+				       struct device_node *node);
 extern int drm_of_component_probe(struct device *dev,
 				  int (*compare_of)(struct device *, void *),
 				  const struct component_master_ops *m_ops);
@@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
 	return 0;
 }
 
+static void drm_of_component_match_add(struct device *master,
+				       struct component_match **matchptr,
+				       int (*compare)(struct device *, void *),
+				       struct device_node *node)
+{
+}
+
 static inline int
 drm_of_component_probe(struct device *dev,
 		       int (*compare_of)(struct device *, void *),
-- 
2.1.0

_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno

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

* [PATCH] drm: convert DT component matching to component_match_add_release()
@ 2016-10-19 10:28 ` Russell King
  0 siblings, 0 replies; 56+ messages in thread
From: Russell King @ 2016-10-19 10:28 UTC (permalink / raw)
  To: linux-arm-kernel

Convert DT component matching to use component_match_add_release().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
Can we please get this patch from May merged into the drm-misc or
whatever trees so that we don't end up with conflicts?  I've no idea
who looks after drm-misc, as they have _still_ failed to add
themselves to MAINTAINERS.

 drivers/gpu/drm/arm/hdlcd_drv.c                 |  3 ++-
 drivers/gpu/drm/arm/malidp_drv.c                |  4 +++-
 drivers/gpu/drm/armada/armada_drv.c             |  2 +-
 drivers/gpu/drm/drm_of.c                        | 28 +++++++++++++++++++++++--
 drivers/gpu/drm/etnaviv/etnaviv_drv.c           |  5 +++--
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c |  7 ++++---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c          |  4 +++-
 drivers/gpu/drm/msm/msm_drv.c                   | 12 ++++++-----
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c     |  6 ++++--
 drivers/gpu/drm/sti/sti_drv.c                   |  5 +++--
 drivers/gpu/drm/sun4i/sun4i_drv.c               |  3 ++-
 drivers/gpu/drm/tilcdc/tilcdc_external.c        |  4 +++-
 include/drm/drm_of.h                            | 12 +++++++++++
 13 files changed, 73 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index fb6a418ce6be..6477d1a65266 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -453,7 +453,8 @@ static int hdlcd_probe(struct platform_device *pdev)
 		return -EAGAIN;
 	}
 
-	component_match_add(&pdev->dev, &match, compare_dev, port);
+	drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
+	of_node_put(port);
 
 	return component_master_add_with_match(&pdev->dev, &hdlcd_master_ops,
 					       match);
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 9280358b8f15..9f4739452a25 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -493,7 +493,9 @@ static int malidp_platform_probe(struct platform_device *pdev)
 		return -EAGAIN;
 	}
 
-	component_match_add(&pdev->dev, &match, malidp_compare_dev, port);
+	drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
+				   port);
+	of_node_put(port);
 	return component_master_add_with_match(&pdev->dev, &malidp_master_ops,
 					       match);
 }
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index 1e0e68f608e4..94e46da9a758 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -254,7 +254,7 @@ static void armada_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
+		drm_of_component_match_add(dev, match, compare_of, remote);
 		of_node_put(remote);
 	}
 }
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index bc98bb94264d..47848ed8ca48 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -6,6 +6,11 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_of.h>
 
+static void drm_release_of(struct device *dev, void *data)
+{
+	of_node_put(data);
+}
+
 /**
  * drm_crtc_port_mask - find the mask of a registered CRTC by port OF node
  * @dev: DRM device
@@ -64,6 +69,24 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
 EXPORT_SYMBOL(drm_of_find_possible_crtcs);
 
 /**
+ * drm_of_component_match_add - Add a component helper OF node match rule
+ * @master: master device
+ * @matchptr: component match pointer
+ * @compare: compare function used for matching component
+ * @node: of_node
+ */
+void drm_of_component_match_add(struct device *master,
+				struct component_match **matchptr,
+				int (*compare)(struct device *, void *),
+				struct device_node *node)
+{
+	of_node_get(node);
+	component_match_add_release(master, matchptr, drm_release_of,
+				    compare, node);
+}
+EXPORT_SYMBOL_GPL(drm_of_component_match_add);
+
+/**
  * drm_of_component_probe - Generic probe function for a component based master
  * @dev: master device containing the OF node
  * @compare_of: compare function used for matching components
@@ -101,7 +124,7 @@ int drm_of_component_probe(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, &match, compare_of, port);
+		drm_of_component_match_add(dev, &match, compare_of, port);
 		of_node_put(port);
 	}
 
@@ -140,7 +163,8 @@ int drm_of_component_probe(struct device *dev,
 				continue;
 			}
 
-			component_match_add(dev, &match, compare_of, remote);
+			drm_of_component_match_add(dev, &match, compare_of,
+						   remote);
 			of_node_put(remote);
 		}
 		of_node_put(port);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index aa687669e22b..0dee6acbd880 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -16,6 +16,7 @@
 
 #include <linux/component.h>
 #include <linux/of_platform.h>
+#include <drm/drm_of.h>
 
 #include "etnaviv_drv.h"
 #include "etnaviv_gpu.h"
@@ -629,8 +630,8 @@ static int etnaviv_pdev_probe(struct platform_device *pdev)
 			if (!core_node)
 				break;
 
-			component_match_add(&pdev->dev, &match, compare_of,
-					    core_node);
+			drm_of_component_match_add(&pdev->dev, &match,
+						   compare_of, core_node);
 			of_node_put(core_node);
 		}
 	} else if (dev->platform_data) {
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 90377a609c98..e88fde18c946 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -24,6 +24,7 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_of.h>
 
 #include "kirin_drm_drv.h"
 
@@ -260,14 +261,13 @@ static struct device_node *kirin_get_remote_node(struct device_node *np)
 		DRM_ERROR("no valid endpoint node\n");
 		return ERR_PTR(-ENODEV);
 	}
-	of_node_put(endpoint);
 
 	remote = of_graph_get_remote_port_parent(endpoint);
+	of_node_put(endpoint);
 	if (!remote) {
 		DRM_ERROR("no valid remote node\n");
 		return ERR_PTR(-ENODEV);
 	}
-	of_node_put(remote);
 
 	if (!of_device_is_available(remote)) {
 		DRM_ERROR("not available for remote node\n");
@@ -294,7 +294,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)
 	if (IS_ERR(remote))
 		return PTR_ERR(remote);
 
-	component_match_add(dev, &match, compare_of, remote);
+	drm_of_component_match_add(dev, &match, compare_of, remote);
+	of_node_put(remote);
 
 	return component_master_add_with_match(dev, &kirin_drm_ops, match);
 
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index cf83f6507ec8..9c5430fb82a2 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -18,6 +18,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_gem.h>
 #include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_of.h>
 #include <linux/component.h>
 #include <linux/iommu.h>
 #include <linux/of_address.h>
@@ -415,7 +416,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
 		    comp_type == MTK_DPI) {
 			dev_info(dev, "Adding component match for %s\n",
 				 node->full_name);
-			component_match_add(dev, &match, compare_of, node);
+			drm_of_component_match_add(dev, &match, compare_of,
+						   node);
 		} else {
 			struct mtk_ddp_comp *comp;
 
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index fb5c0b0a7594..84d38eaea585 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -15,6 +15,8 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <drm/drm_of.h>
+
 #include "msm_drv.h"
 #include "msm_debugfs.h"
 #include "msm_fence.h"
@@ -919,8 +921,8 @@ static int add_components_mdp(struct device *mdp_dev,
 			continue;
 		}
 
-		component_match_add(master_dev, matchptr, compare_of, intf);
-
+		drm_of_component_match_add(master_dev, matchptr, compare_of,
+					   intf);
 		of_node_put(intf);
 		of_node_put(ep_node);
 	}
@@ -962,8 +964,8 @@ static int add_display_components(struct device *dev,
 		put_device(mdp_dev);
 
 		/* add the MDP component itself */
-		component_match_add(dev, matchptr, compare_of,
-				    mdp_dev->of_node);
+		drm_of_component_match_add(dev, matchptr, compare_of,
+					   mdp_dev->of_node);
 	} else {
 		/* MDP4 */
 		mdp_dev = dev;
@@ -996,7 +998,7 @@ static int add_gpu_components(struct device *dev,
 	if (!np)
 		return 0;
 
-	component_match_add(dev, matchptr, compare_of, np);
+	drm_of_component_match_add(dev, matchptr, compare_of, np);
 
 	of_node_put(np);
 
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 8c8cbe837e61..6fe161192bb4 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -20,6 +20,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_of.h>
 #include <linux/dma-mapping.h>
 #include <linux/pm_runtime.h>
 #include <linux/module.h>
@@ -388,7 +389,7 @@ static void rockchip_add_endpoints(struct device *dev,
 			continue;
 		}
 
-		component_match_add(dev, match, compare_of, remote);
+		drm_of_component_match_add(dev, match, compare_of, remote);
 		of_node_put(remote);
 	}
 }
@@ -437,7 +438,8 @@ static int rockchip_drm_platform_probe(struct platform_device *pdev)
 		}
 
 		of_node_put(iommu);
-		component_match_add(dev, &match, compare_of, port->parent);
+		drm_of_component_match_add(dev, &match, compare_of,
+					   port->parent);
 		of_node_put(port);
 	}
 
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 2784919a7366..5e819876e642 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -17,6 +17,7 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_of.h>
 
 #include "sti_crtc.h"
 #include "sti_drv.h"
@@ -423,8 +424,8 @@ static int sti_platform_probe(struct platform_device *pdev)
 	child_np = of_get_next_available_child(node, NULL);
 
 	while (child_np) {
-		component_match_add(dev, &match, compare_of, child_np);
-		of_node_put(child_np);
+		drm_of_component_match_add(dev, &match, compare_of,
+					   child_np);
 		child_np = of_get_next_available_child(node, child_np);
 	}
 
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 0da9862ad8ed..b3c4ad605e81 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -18,6 +18,7 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_of.h>
 
 #include "sun4i_crtc.h"
 #include "sun4i_drv.h"
@@ -239,7 +240,7 @@ static int sun4i_drv_add_endpoints(struct device *dev,
 		/* Add current component */
 		DRM_DEBUG_DRIVER("Adding component %s\n",
 				 of_node_full_name(node));
-		component_match_add(dev, match, compare_of, node);
+		drm_of_component_match_add(dev, match, compare_of, node);
 		count++;
 	}
 
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 68e895021005..06a4c584f3cb 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -10,6 +10,7 @@
 
 #include <linux/component.h>
 #include <linux/of_graph.h>
+#include <drm/drm_of.h>
 
 #include "tilcdc_drv.h"
 #include "tilcdc_external.h"
@@ -160,7 +161,8 @@ int tilcdc_get_external_components(struct device *dev,
 
 		dev_dbg(dev, "Subdevice node '%s' found\n", node->name);
 		if (match)
-			component_match_add(dev, match, dev_match_of, node);
+			drm_of_component_match_add(dev, match, dev_match_of,
+						   node);
 		of_node_put(node);
 		count++;
 	}
diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h
index 3fd87b386ed7..d6b4c5587bbe 100644
--- a/include/drm/drm_of.h
+++ b/include/drm/drm_of.h
@@ -4,6 +4,7 @@
 #include <linux/of_graph.h>
 
 struct component_master_ops;
+struct component_match;
 struct device;
 struct drm_device;
 struct drm_encoder;
@@ -12,6 +13,10 @@ struct device_node;
 #ifdef CONFIG_OF
 extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
 					   struct device_node *port);
+extern void drm_of_component_match_add(struct device *master,
+				       struct component_match **matchptr,
+				       int (*compare)(struct device *, void *),
+				       struct device_node *node);
 extern int drm_of_component_probe(struct device *dev,
 				  int (*compare_of)(struct device *, void *),
 				  const struct component_master_ops *m_ops);
@@ -25,6 +30,13 @@ static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
 	return 0;
 }
 
+static void drm_of_component_match_add(struct device *master,
+				       struct component_match **matchptr,
+				       int (*compare)(struct device *, void *),
+				       struct device_node *node)
+{
+}
+
 static inline int
 drm_of_component_probe(struct device *dev,
 		       int (*compare_of)(struct device *, void *),
-- 
2.1.0

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

end of thread, other threads:[~2016-10-25 16:44 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-03  7:58 [PATCH] drm: convert DT component matching to component_match_add_release() Russell King
2016-06-03  7:58 ` Russell King
2016-06-03  9:40 ` Liviu Dudau
2016-06-03  9:40   ` Liviu Dudau
2016-06-03 10:36   ` Russell King - ARM Linux
2016-06-03 10:36     ` Russell King - ARM Linux
2016-06-03 11:19     ` Liviu Dudau
2016-06-03 11:19       ` Liviu Dudau
2016-06-03 11:48       ` Russell King - ARM Linux
2016-06-03 11:48         ` Russell King - ARM Linux
2016-06-03 10:56 ` Robin Murphy
2016-06-03 10:56   ` Robin Murphy
2016-06-03 14:15   ` Russell King - ARM Linux
2016-06-03 14:15     ` Russell King - ARM Linux
2016-06-03 14:21     ` [PATCH v2 1/3] of: add common OF-based component functionality Russell King
2016-06-03 14:21       ` Russell King
     [not found]       ` <E1b8pyR-0005OJ-V3-eh5Bv4kxaXIk46pC+1QYvQNdhmdF6hFW@public.gmane.org>
2016-06-03 15:29         ` Rob Herring
2016-06-03 15:29           ` Rob Herring
2016-06-03 15:36           ` Russell King - ARM Linux
2016-06-03 15:36             ` Russell King - ARM Linux
2016-06-03 19:52             ` Rob Herring
2016-06-03 19:52               ` Rob Herring
2016-06-03 15:44         ` Thierry Reding
2016-06-03 15:44           ` Thierry Reding
2016-06-03 16:11           ` Russell King - ARM Linux
2016-06-03 16:11             ` Russell King - ARM Linux
2016-06-03 14:21     ` [PATCH v2 2/3] drm: convert DT component matching to component_match_add_release() Russell King
2016-06-03 14:21       ` Russell King
2016-06-03 15:10       ` Lucas Stach
2016-06-03 15:10         ` Lucas Stach
     [not found]       ` <E1b8pyX-0005OP-2s-eh5Bv4kxaXIk46pC+1QYvQNdhmdF6hFW@public.gmane.org>
2016-06-07 13:39         ` Liviu Dudau
2016-06-07 13:39           ` Liviu Dudau
2016-06-07 14:26         ` Vincent ABRIOU
2016-06-07 14:26           ` Vincent ABRIOU
2016-06-03 14:21     ` [PATCH v2 3/3] iommu: " Russell King
2016-06-03 14:21       ` Russell King
2016-06-03 15:20       ` Matthias Brugger
2016-06-03 15:20         ` Matthias Brugger
2016-06-15 13:31       ` Joerg Roedel
2016-06-15 13:31         ` Joerg Roedel
2016-10-19 10:28 [PATCH] drm: " Russell King
2016-10-19 10:28 ` Russell King
2016-10-20  6:36 ` Daniel Vetter
2016-10-20  6:36   ` Daniel Vetter
2016-10-20 20:39 ` Sean Paul
2016-10-20 20:39   ` Sean Paul
2016-10-20 21:50   ` Russell King - ARM Linux
2016-10-20 21:50     ` Russell King - ARM Linux
2016-10-20 23:15     ` Sean Paul
2016-10-20 23:15       ` Sean Paul
     [not found]       ` <CAOw6vbJ64JOugR2b3R87pFRDGDVs9HM3uZJM2z1-jHyhPf6WOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-21 15:23         ` Russell King - ARM Linux
2016-10-21 15:23           ` Russell King - ARM Linux
2016-10-24 13:21 ` Jyri Sarha
2016-10-24 13:21   ` Jyri Sarha
2016-10-25 16:44 ` Sean Paul
2016-10-25 16:44   ` Sean Paul

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.