All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: mdio: thunder: Add missing fwnode_handle_put()
@ 2023-03-22  6:20 Liang He
  2023-03-22  8:55 ` Horatiu Vultur
  2023-03-23  8:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 5+ messages in thread
From: Liang He @ 2023-03-22  6:20 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	david.daney, windhl

In device_for_each_child_node(), we should add fwnode_handle_put()
when break out of the iteration device_for_each_child_node()
as it will automatically increase and decrease the refcounter.

Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
Signed-off-by: Liang He <windhl@126.com>
---
 drivers/net/mdio/mdio-thunder.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mdio/mdio-thunder.c b/drivers/net/mdio/mdio-thunder.c
index 822d2cdd2f35..394b864aaa37 100644
--- a/drivers/net/mdio/mdio-thunder.c
+++ b/drivers/net/mdio/mdio-thunder.c
@@ -104,6 +104,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
 		if (i >= ARRAY_SIZE(nexus->buses))
 			break;
 	}
+	fwnode_handle_put(fwn);
 	return 0;
 
 err_release_regions:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: mdio: thunder: Add missing fwnode_handle_put()
  2023-03-22  6:20 [PATCH] net: mdio: thunder: Add missing fwnode_handle_put() Liang He
@ 2023-03-22  8:55 ` Horatiu Vultur
  2023-03-23  1:53   ` Liang He
  2023-03-23  8:50 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 5+ messages in thread
From: Horatiu Vultur @ 2023-03-22  8:55 UTC (permalink / raw)
  To: Liang He
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	david.daney

The 03/22/2023 14:20, Liang He wrote:
> 
> In device_for_each_child_node(), we should add fwnode_handle_put()
> when break out of the iteration device_for_each_child_node()
> as it will automatically increase and decrease the refcounter.

Don't forget to mention the tree which you are targeting.
It shoud be something like:
"[PATCH net] net: mdio: thunder: Add missing fwnode_handle_put()" and
you can achieve this using option --subject-prefix when you create your
patch:
git format-patch ... --subject-prefix "PATCH net"


> 
> Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  drivers/net/mdio/mdio-thunder.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/mdio/mdio-thunder.c b/drivers/net/mdio/mdio-thunder.c
> index 822d2cdd2f35..394b864aaa37 100644
> --- a/drivers/net/mdio/mdio-thunder.c
> +++ b/drivers/net/mdio/mdio-thunder.c
> @@ -104,6 +104,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
>                 if (i >= ARRAY_SIZE(nexus->buses))
>                         break;
>         }
> +       fwnode_handle_put(fwn);

Can you declare only 1 mdio bus in the DT under this pci device?
Because in that case, I don't think this is correct, because then
'device_for_each_child_node' will exit before all 4 mdio buses are probed.
And according to the comments for 'fwnode_handle_put' you need to use
with break or return.

>         return 0;
> 
>  err_release_regions:
> --
> 2.25.1
> 

-- 
/Horatiu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re:Re: [PATCH] net: mdio: thunder: Add missing fwnode_handle_put()
  2023-03-22  8:55 ` Horatiu Vultur
@ 2023-03-23  1:53   ` Liang He
  2023-03-23  7:36     ` Horatiu Vultur
  0 siblings, 1 reply; 5+ messages in thread
From: Liang He @ 2023-03-23  1:53 UTC (permalink / raw)
  To: Horatiu Vultur
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	david.daney



At 2023-03-22 16:55:38, "Horatiu Vultur" <horatiu.vultur@microchip.com> wrote:
>The 03/22/2023 14:20, Liang He wrote:
>> 
>> In device_for_each_child_node(), we should add fwnode_handle_put()
>> when break out of the iteration device_for_each_child_node()
>> as it will automatically increase and decrease the refcounter.
>
>Don't forget to mention the tree which you are targeting.
>It shoud be something like:
>"[PATCH net] net: mdio: thunder: Add missing fwnode_handle_put()" and
>you can achieve this using option --subject-prefix when you create your
>patch:
>git format-patch ... --subject-prefix "PATCH net"
>

Thanks for your reply and advise, I will add it in my future patches.

>
>> 
>> Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>>  drivers/net/mdio/mdio-thunder.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/net/mdio/mdio-thunder.c b/drivers/net/mdio/mdio-thunder.c
>> index 822d2cdd2f35..394b864aaa37 100644
>> --- a/drivers/net/mdio/mdio-thunder.c
>> +++ b/drivers/net/mdio/mdio-thunder.c
>> @@ -104,6 +104,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
>>                 if (i >= ARRAY_SIZE(nexus->buses))
>>                         break;
>>         }
>> +       fwnode_handle_put(fwn);
>
>Can you declare only 1 mdio bus in the DT under this pci device?
>Because in that case, I don't think this is correct, because then
>'device_for_each_child_node' will exit before all 4 mdio buses are probed.
>And according to the comments for 'fwnode_handle_put' you need to use
>with break or return.
>

In fact, the fwnode_handle_put(fwn) consider the NULL-check of fwn, and 
there are only break, not return, so I think it can work in this case.
However, if you prefer to add fwnode_handle_put before break, I can
send a new patch.

Thanks,
Liang

>>         return 0;
>> 
>>  err_release_regions:
>> --
>> 2.25.1
>> 
>
>-- 
>/Horatiu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: mdio: thunder: Add missing fwnode_handle_put()
  2023-03-23  1:53   ` Liang He
@ 2023-03-23  7:36     ` Horatiu Vultur
  0 siblings, 0 replies; 5+ messages in thread
From: Horatiu Vultur @ 2023-03-23  7:36 UTC (permalink / raw)
  To: Liang He
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	david.daney

The 03/23/2023 09:53, Liang He wrote:
> 
> At 2023-03-22 16:55:38, "Horatiu Vultur" <horatiu.vultur@microchip.com> wrote:
> >The 03/22/2023 14:20, Liang He wrote:
> >>
> >> In device_for_each_child_node(), we should add fwnode_handle_put()
> >> when break out of the iteration device_for_each_child_node()
> >> as it will automatically increase and decrease the refcounter.
> >
> >Don't forget to mention the tree which you are targeting.
> >It shoud be something like:
> >"[PATCH net] net: mdio: thunder: Add missing fwnode_handle_put()" and
> >you can achieve this using option --subject-prefix when you create your
> >patch:
> >git format-patch ... --subject-prefix "PATCH net"
> >
> 
> Thanks for your reply and advise, I will add it in my future patches.
> 
> >
> >>
> >> Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
> >> Signed-off-by: Liang He <windhl@126.com>
> >> ---
> >>  drivers/net/mdio/mdio-thunder.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/drivers/net/mdio/mdio-thunder.c b/drivers/net/mdio/mdio-thunder.c
> >> index 822d2cdd2f35..394b864aaa37 100644
> >> --- a/drivers/net/mdio/mdio-thunder.c
> >> +++ b/drivers/net/mdio/mdio-thunder.c
> >> @@ -104,6 +104,7 @@ static int thunder_mdiobus_pci_probe(struct pci_dev *pdev,
> >>                 if (i >= ARRAY_SIZE(nexus->buses))
> >>                         break;
> >>         }
> >> +       fwnode_handle_put(fwn);
> >
> >Can you declare only 1 mdio bus in the DT under this pci device?
> >Because in that case, I don't think this is correct, because then
> >'device_for_each_child_node' will exit before all 4 mdio buses are probed.
> >And according to the comments for 'fwnode_handle_put' you need to use
> >with break or return.
> >
> 
> In fact, the fwnode_handle_put(fwn) consider the NULL-check of fwn, and
> there are only break, not return, so I think it can work in this case.
> However, if you prefer to add fwnode_handle_put before break, I can
> send a new patch.

You are right, fwnode_handle_put checks for NULL.
It is up too you how you prefer.

> 
> Thanks,
> Liang
> 
> >>         return 0;
> >>
> >>  err_release_regions:
> >> --
> >> 2.25.1
> >>
> >
> >--
> >/Horatiu

-- 
/Horatiu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: mdio: thunder: Add missing fwnode_handle_put()
  2023-03-22  6:20 [PATCH] net: mdio: thunder: Add missing fwnode_handle_put() Liang He
  2023-03-22  8:55 ` Horatiu Vultur
@ 2023-03-23  8:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-23  8:50 UTC (permalink / raw)
  To: Liang He
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	david.daney

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 22 Mar 2023 14:20:57 +0800 you wrote:
> In device_for_each_child_node(), we should add fwnode_handle_put()
> when break out of the iteration device_for_each_child_node()
> as it will automatically increase and decrease the refcounter.
> 
> Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
> Signed-off-by: Liang He <windhl@126.com>
> 
> [...]

Here is the summary with links:
  - net: mdio: thunder: Add missing fwnode_handle_put()
    https://git.kernel.org/netdev/net/c/b1de5c78ebe9

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-23  8:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22  6:20 [PATCH] net: mdio: thunder: Add missing fwnode_handle_put() Liang He
2023-03-22  8:55 ` Horatiu Vultur
2023-03-23  1:53   ` Liang He
2023-03-23  7:36     ` Horatiu Vultur
2023-03-23  8:50 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.