From: Stephen Boyd <sboyd@kernel.org>
To: baolin.wang7@gmail.com, linux-clk@vger.kernel.org,
mturquette@baylibre.com, orsonzhai@gmail.com, windhl@126.com,
zhang.lyra@gmail.com
Subject: Re: [PATCH v5] clk: sprd: Hold reference returned by of_get_parent()
Date: Fri, 19 Aug 2022 14:48:24 -0700 [thread overview]
Message-ID: <20220819214826.8862FC4347C@smtp.kernel.org> (raw)
In-Reply-To: <20220704004729.272481-1-windhl@126.com>
Quoting Liang He (2022-07-03 17:47:29)
> We should hold the reference returned by of_get_parent() and use it
> to call of_node_put() for refcount balance.
>
> Fixes: f95e8c7923d1 ("clk: sprd: support to get regmap from parent node")
> Signed-off-by: Liang He <windhl@126.com>
> ---
> changelog:
>
> v5: fix bug reported by Chunyan and confirmed by Orson
> v4: fix another bug in the same place, missing in v3
> v3: (1) keep original 'if-else if-else' coding style adviesd by Orson
> (2) fix typo in commit-log: of_node_out --> of_node_put
> v2: minimize the effective range of of_get_parent() advised by Orson
> v1: hold reference returned by of_get_parent()
>
>
> drivers/clk/sprd/common.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/sprd/common.c b/drivers/clk/sprd/common.c
> index d620bbbcdfc8..24db1df09075 100644
> --- a/drivers/clk/sprd/common.c
> +++ b/drivers/clk/sprd/common.c
> @@ -41,7 +41,7 @@ int sprd_clk_regmap_init(struct platform_device *pdev,
> {
> void __iomem *base;
> struct device *dev = &pdev->dev;
> - struct device_node *node = dev->of_node;
> + struct device_node *node = dev->of_node, *np;
> struct regmap *regmap;
>
> if (of_find_property(node, "sprd,syscon", NULL)) {
> @@ -50,9 +50,10 @@ int sprd_clk_regmap_init(struct platform_device *pdev,
> pr_err("%s: failed to get syscon regmap\n", __func__);
> return PTR_ERR(regmap);
> }
> - } else if (of_device_is_compatible(of_get_parent(dev->of_node),
> - "syscon")) {
> - regmap = device_node_to_regmap(of_get_parent(dev->of_node));
> + } else if (of_device_is_compatible(np = of_get_parent(node), "syscon")
> + || (of_node_put(np), 0)) {
This is gross.
next prev parent reply other threads:[~2022-08-19 21:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 0:47 [PATCH v5] clk: sprd: Hold reference returned by of_get_parent() Liang He
2022-07-06 3:31 ` Orson Zhai
2022-08-19 21:48 ` Stephen Boyd [this message]
2022-08-19 21:55 ` Stephen Boyd
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=20220819214826.8862FC4347C@smtp.kernel.org \
--to=sboyd@kernel.org \
--cc=baolin.wang7@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=orsonzhai@gmail.com \
--cc=windhl@126.com \
--cc=zhang.lyra@gmail.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