linux-rockchip.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Russell King <rmk+kernel@armlinux.org.uk>,
	Liviu Dudau <liviu.dudau@arm.com>,
	David Airlie <airlied@linux.ie>, Rob Clark <robdclark@gmail.com>,
	Mark Yao <mark.yao@rock-chips.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Vincent Abriou <vincent.abriou@st.com>,
	dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	freedreno@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Subject: Re: [PATCH] drm: convert DT component matching to component_match_add_release()
Date: Fri, 3 Jun 2016 11:56:40 +0100	[thread overview]
Message-ID: <57516268.3020401@arm.com> (raw)
In-Reply-To: <E1b8jze-00046l-K5@rmk-PC.armlinux.org.uk>

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++;
>   	}
>
>

  parent reply	other threads:[~2016-06-03 10:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03  7:58 [PATCH] drm: convert DT component matching to component_match_add_release() Russell King
2016-06-03  9:40 ` Liviu Dudau
2016-06-03 10:36   ` Russell King - ARM Linux
2016-06-03 11:19     ` Liviu Dudau
2016-06-03 11:48       ` Russell King - ARM Linux
2016-06-03 10:56 ` Robin Murphy [this message]
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
     [not found]       ` <E1b8pyR-0005OJ-V3-eh5Bv4kxaXIk46pC+1QYvQNdhmdF6hFW@public.gmane.org>
2016-06-03 15:29         ` Rob Herring
2016-06-03 15:36           ` Russell King - ARM Linux
2016-06-03 19:52             ` Rob Herring
2016-06-03 15:44         ` Thierry Reding
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 15:10       ` Lucas Stach
     [not found]       ` <E1b8pyX-0005OP-2s-eh5Bv4kxaXIk46pC+1QYvQNdhmdF6hFW@public.gmane.org>
2016-06-07 13:39         ` Liviu Dudau
2016-06-07 14:26         ` Vincent ABRIOU
2016-06-03 14:21     ` [PATCH v2 3/3] iommu: " Russell King
2016-06-03 15:20       ` Matthias Brugger
2016-06-15 13:31       ` Joerg Roedel
  -- strict thread matches above, loose matches on Subject: below --
2016-10-19 10:28 [PATCH] drm: " Russell King
2016-10-20  6:36 ` Daniel Vetter
2016-10-20 20:39 ` Sean Paul
2016-10-20 21:50   ` Russell King - ARM Linux
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-24 13:21 ` Jyri Sarha
2016-10-25 16:44 ` Sean Paul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57516268.3020401@arm.com \
    --to=robin.murphy@arm.com \
    --cc=airlied@linux.ie \
    --cc=benjamin.gaignard@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=liviu.dudau@arm.com \
    --cc=mark.yao@rock-chips.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=robdclark@gmail.com \
    --cc=vincent.abriou@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).