From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Liang He <windhl@126.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
"open list:BROADCOM NVRAM DRIVER" <linux-mips@vger.kernel.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>
Subject: Re: [PATCH] mips/kernel: Add missing of_node_get()
Date: Wed, 22 Jun 2022 08:56:32 +0200 [thread overview]
Message-ID: <CAMuHMdUiZSqGY2xbosDBCxcvMej6ir8sDfuOk9qfXTzJPh6ZOw@mail.gmail.com> (raw)
In-Reply-To: <20220622060807.4095040-1-windhl@126.com>
Hi Liang,
CC devicetree
On Wed, Jun 22, 2022 at 8:08 AM Liang He <windhl@126.com> wrote:
> In mips_cpc_default_phys_base(), we need to add of_node_get() before
> of_find_compatible_node() which will decrease the refcount of its
> first arg.
>
> Signed-off-by: Liang He <windhl@126.com>
Thanks for your patch!
> --- a/arch/mips/kernel/mips-cpc.c
> +++ b/arch/mips/kernel/mips-cpc.c
> @@ -25,6 +25,7 @@ phys_addr_t __weak mips_cpc_default_phys_base(void)
> struct resource res;
> int err;
>
> + of_node_get(of_root);
Adding this looks strange to me...
However, of_find_compatible_node() indeed calls of_node_put(from),
so your patch is correct.
However, when passed NULL as the from pointer, __of_find_all_nodes()
(expanded from for_each_of_allnodes_from()) turns this into of_root.
As of_find_compatible_node() still has the original (NULL) from
pointer, of_node_put(from) becomes a no-op.
> cpc_node = of_find_compatible_node(of_root, NULL, "mti,mips-cpc");
Hence I think it would be better to change the above to
cpc_node = of_find_compatible_node(NULL, NULL, "mti,mips-cpc");
instead, i.e. get rid of the explicit of_root handling?
> if (cpc_node) {
> err = of_address_to_resource(cpc_node, 0, &res);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2022-06-22 6:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 6:08 [PATCH] mips/kernel: Add missing of_node_get() Liang He
2022-06-22 6:56 ` Geert Uytterhoeven [this message]
2022-06-22 7:12 ` Liang He
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=CAMuHMdUiZSqGY2xbosDBCxcvMej6ir8sDfuOk9qfXTzJPh6ZOw@mail.gmail.com \
--to=geert@linux-m68k.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
--cc=windhl@126.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).