* [PATCH next] arch: powerpc: platforms: Remove unnecessary call to of_node_get
@ 2024-05-22 19:42 Prabhav Kumar Vaish
2024-05-23 11:25 ` Michael Ellerman
0 siblings, 1 reply; 3+ messages in thread
From: Prabhav Kumar Vaish @ 2024-05-22 19:42 UTC (permalink / raw)
To: akpm
Cc: Prabhav Kumar Vaish, javier.carrasco.cruz, linux-kernel,
julia.lawall, npiggin, skhan, naveen.n.rao, linuxppc-dev
`dev->of_node` has a pointer to device node, of_node_get call seems
unnecessary.
It will automate the cleanup process allowing to remove the of_node_put
call.
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);
@@ -805,7 +804,7 @@ static u64 cell_iommu_get_fixed_address(struct device *dev)
if (!ranges) {
dev_dbg(dev, "iommu: no dma-ranges found\n");
- goto out;
+ return dev_addr;
}
len /= sizeof(u32);
@@ -833,8 +832,6 @@ static u64 cell_iommu_get_fixed_address(struct device *dev)
} else
dev_dbg(dev, "iommu: no suitable range found!\n");
-out:
- of_node_put(np);
return dev_addr;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH next] arch: powerpc: platforms: Remove unnecessary call to of_node_get
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
2024-05-23 18:01 ` prabhav kumar
0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2024-05-23 11:25 UTC (permalink / raw)
To: Prabhav Kumar Vaish, akpm
Cc: Prabhav Kumar Vaish, javier.carrasco.cruz, linux-kernel,
julia.lawall, npiggin, skhan, naveen.n.rao, linuxppc-dev
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH next] arch: powerpc: platforms: Remove unnecessary call to of_node_get
2024-05-23 11:25 ` Michael Ellerman
@ 2024-05-23 18:01 ` prabhav kumar
0 siblings, 0 replies; 3+ messages in thread
From: prabhav kumar @ 2024-05-23 18:01 UTC (permalink / raw)
To: Michael Ellerman
Cc: javier.carrasco.cruz, linux-kernel, julia.lawall, npiggin, skhan,
naveen.n.rao, akpm, linuxppc-dev
On Thu, May 23, 2024 at 4:55 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> 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.
>
Thanks, I will check this out once again
Prabhav
> cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-30 22:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-05-23 18:01 ` prabhav kumar
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).