From: Michael Ellerman <mpe@ellerman.id.au>
To: Prabhav Kumar Vaish <pvkumar5749404@gmail.com>,
akpm@linux-foundation.org
Cc: Prabhav Kumar Vaish <pvkumar5749404@gmail.com>,
javier.carrasco.cruz@gmail.com, linux-kernel@vger.kernel.org,
julia.lawall@inria.fr, npiggin@gmail.com,
skhan@linuxfoundation.org, naveen.n.rao@linux.ibm.com,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH next] arch: powerpc: platforms: Remove unnecessary call to of_node_get
Date: Thu, 23 May 2024 21:25:01 +1000 [thread overview]
Message-ID: <87h6eo3h4i.fsf@mail.lhotse> (raw)
In-Reply-To: <20240522194250.1165568-1-pvkumar5749404@gmail.com>
Prabhav Kumar Vaish <pvkumar5749404@gmail.com> writes:
> `dev->of_node` has a pointer to device node, of_node_get call seems
> unnecessary.
Sorry but it is necessary.
> Signed-off-by: Prabhav Kumar Vaish <pvkumar5749404@gmail.com>
> ---
> arch/powerpc/platforms/cell/iommu.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
> index 4cd9c0de22c2..5b794ce08689 100644
> --- a/arch/powerpc/platforms/cell/iommu.c
> +++ b/arch/powerpc/platforms/cell/iommu.c
> @@ -780,14 +780,13 @@ static int __init cell_iommu_init_disabled(void)
> static u64 cell_iommu_get_fixed_address(struct device *dev)
> {
> u64 cpu_addr, size, best_size, dev_addr = OF_BAD_ADDR;
> - struct device_node *np;
> + struct device_node *np = dev->of_node;
> const u32 *ranges = NULL;
> int i, len, best, naddr, nsize, pna, range_size;
>
> /* We can be called for platform devices that have no of_node */
> - np = of_node_get(dev->of_node);
> if (!np)
> - goto out;
> + return dev_addr;
>
> while (1) {
> naddr = of_n_addr_cells(np);
nsize = of_n_size_cells(np);
np = of_get_next_parent(np);
if (!np)
break;
of_get_next_parent() drops the reference of the node passed to it (np).
So if you actually tested your patch you should see a recount underflow.
cheers
next prev parent reply other threads:[~2024-05-23 11:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 19:42 [PATCH next] arch: powerpc: platforms: Remove unnecessary call to of_node_get Prabhav Kumar Vaish
2024-05-23 11:25 ` Michael Ellerman [this message]
2024-05-23 18:01 ` prabhav kumar
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=87h6eo3h4i.fsf@mail.lhotse \
--to=mpe@ellerman.id.au \
--cc=akpm@linux-foundation.org \
--cc=javier.carrasco.cruz@gmail.com \
--cc=julia.lawall@inria.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=pvkumar5749404@gmail.com \
--cc=skhan@linuxfoundation.org \
/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).