linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Zhang Zekun <zhangzekun11@huawei.com>,
	robh@kernel.org, saravanak@google.com, justin.chen@broadcom.com,
	florian.fainelli@broadcom.com, andrew+netdev@lunn.ch,
	kuba@kernel.org, o.rempel@pengutronix.de,
	kory.maincent@bootlin.com, jacopo+renesas@jmondi.org,
	kieran.bingham+renesas@ideasonboard.com,
	laurent.pinchart+renesas@ideasonboard.com, maddy@linux.ibm.com,
	mpe@ellerman.id.au, npiggin@gmail.com, olteanv@gmail.com,
	davem@davemloft.net, taras.chornyi@plvision.eu,
	edumazet@google.com, pabeni@redhat.com, sudeep.holla@arm.com,
	cristian.marussi@arm.com
Cc: arm-scmi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-media@vger.kernel.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, chenjun102@huawei.com
Subject: Re: [PATCH 1/9] of: Add warpper function of_find_node_by_name_balanced()
Date: Wed, 12 Feb 2025 06:47:20 +0100	[thread overview]
Message-ID: <e7a1b608-2bad-41d4-844a-07fd73818bb3@kernel.org> (raw)
In-Reply-To: <20250207013117.104205-2-zhangzekun11@huawei.com>

On 07/02/2025 02:31, Zhang Zekun wrote:
> There are many drivers use of_find_node_by_name() with a not-NULL
> device_node pointer, and a number of callers would require a call to
> of_node_get() before using it. There are also some drivers who forget
> to call of_node_get() which would cause a ref count leak[1]. So, Add a
> wraper function for of_find_node_by_name(), drivers may use this function
> to call of_find_node_by_name() with the refcount already balanced.
> 
> [1] https://lore.kernel.org/all/20241024015909.58654-1-zhangzekun11@huawei.com/
> 
> Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
> ---
>  include/linux/of.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux/of.h b/include/linux/of.h
> index eaf0e2a2b75c..b7c6d7ff278c 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -268,6 +268,11 @@ static inline const char *of_node_full_name(const struct device_node *np)
>  #define for_each_of_allnodes(dn) for_each_of_allnodes_from(NULL, dn)
>  extern struct device_node *of_find_node_by_name(struct device_node *from,
>  	const char *name);
> +static inline struct device_node *of_find_node_by_name_balanced(struct device_node *from,
> +								const char *name)
> +{
> +	return of_find_node_by_name(of_node_get(from), name);

I don't think that solution to people not reading API description is to
create more API with similar but a bit different behavior, especially
undocumented.

Best regards,
Krzysztof


  parent reply	other threads:[~2025-02-12  5:47 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07  1:31 [PATCH 0/9] Add wrapper function of_find_node_by_name_balanced() Zhang Zekun
2025-02-07  1:31 ` [PATCH 1/9] of: Add warpper " Zhang Zekun
2025-02-07  8:24   ` Oleksij Rempel
2025-02-07  8:57     ` Laurent Pinchart
2025-02-07 11:28     ` zhangzekun (A)
2025-02-07 15:37       ` Laurent Pinchart
2025-02-08  4:18         ` Dan Carpenter
2025-04-25 15:30           ` Dan Carpenter
2025-04-25 17:07             ` Laurent Pinchart
2025-06-10 19:39               ` Andy Shevchenko
2025-06-10 20:03                 ` Laurent Pinchart
2025-06-10 20:17                   ` Andy Shevchenko
2025-02-10  6:47         ` zhangzekun (A)
2025-02-10 10:03           ` Laurent Pinchart
2025-02-11 11:26             ` zhangzekun (A)
2025-02-11 11:43               ` Laurent Pinchart
2025-02-11 14:15         ` Rob Herring
2025-02-12  5:47   ` Krzysztof Kozlowski [this message]
2025-02-07  1:31 ` [PATCH 2/9] net: bcmasp: Add missing of_node_get() before of_find_node_by_name() Zhang Zekun
2025-02-12  5:52   ` Krzysztof Kozlowski
2025-02-12  6:50     ` zhangzekun (A)
2025-02-07  1:31 ` [PATCH 3/9] net: pse-pd: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 4/9] media: max9286: Use of_find_node_by_name_balanced() to find device_node Zhang Zekun
2025-02-07  1:31 ` [PATCH 5/9] powerpc: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 6/9] net: dsa: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 7/9] net: dsa: hellcreek: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 8/9] net: prestera: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 9/9] regulator: scmi: " Zhang Zekun

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=e7a1b608-2bad-41d4-844a-07fd73818bb3@kernel.org \
    --to=krzk@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=arm-scmi@vger.kernel.org \
    --cc=chenjun102@huawei.com \
    --cc=cristian.marussi@arm.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=justin.chen@broadcom.com \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=netdev@vger.kernel.org \
    --cc=npiggin@gmail.com \
    --cc=o.rempel@pengutronix.de \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=saravanak@google.com \
    --cc=sudeep.holla@arm.com \
    --cc=taras.chornyi@plvision.eu \
    --cc=zhangzekun11@huawei.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).