* [PATCH net-next] net: dsa: bcm_sf2: Use devm_clk_get_optional_enabled() in bcm_sf2_sw_probe()
@ 2026-11-19 16:37 Markus Elfring
2026-11-19 17:45 ` Florian Fainelli
2026-11-19 20:21 ` Christophe JAILLET
0 siblings, 2 replies; 4+ messages in thread
From: Markus Elfring @ 2026-11-19 16:37 UTC (permalink / raw)
To: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Florian Fainelli, Jakub Kicinski, Jonas Gorski, Paolo Abeni,
Vladimir Oltean
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 19 Nov 2026 17:30:09 +0100
Reuse existing functionality from devm_clk_get_optional_enabled()
instead of keeping duplicate source code.
The source code was transformed by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/dsa/bcm_sf2.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 1747a1f20c78..011ce79392e8 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1467,14 +1467,10 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
base++;
}
- priv->clk = devm_clk_get_optional(&pdev->dev, "sw_switch");
+ priv->clk = devm_clk_get_optional_enabled(&pdev->dev, "sw_switch");
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
- ret = clk_prepare_enable(priv->clk);
- if (ret)
- return ret;
-
priv->clk_mdiv = devm_clk_get_optional(&pdev->dev, "sw_switch_mdiv");
if (IS_ERR(priv->clk_mdiv)) {
ret = PTR_ERR(priv->clk_mdiv);
--
2.56.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: dsa: bcm_sf2: Use devm_clk_get_optional_enabled() in bcm_sf2_sw_probe()
2026-11-19 16:37 [PATCH net-next] net: dsa: bcm_sf2: Use devm_clk_get_optional_enabled() in bcm_sf2_sw_probe() Markus Elfring
@ 2026-11-19 17:45 ` Florian Fainelli
2026-11-19 20:21 ` Christophe JAILLET
1 sibling, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2026-11-19 17:45 UTC (permalink / raw)
To: Markus Elfring, netdev, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Jonas Gorski, Paolo Abeni,
Vladimir Oltean
Cc: LKML, kernel-janitors
On 11/19/26 08:37, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 19 Nov 2026 17:30:09 +0100
>
> Reuse existing functionality from devm_clk_get_optional_enabled()
> instead of keeping duplicate source code.
>
> The source code was transformed by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: dsa: bcm_sf2: Use devm_clk_get_optional_enabled() in bcm_sf2_sw_probe()
2026-11-19 16:37 [PATCH net-next] net: dsa: bcm_sf2: Use devm_clk_get_optional_enabled() in bcm_sf2_sw_probe() Markus Elfring
2026-11-19 17:45 ` Florian Fainelli
@ 2026-11-19 20:21 ` Christophe JAILLET
2026-11-19 21:06 ` Florian Fainelli
1 sibling, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2026-11-19 20:21 UTC (permalink / raw)
To: Markus Elfring, netdev, Andrew Lunn, David S. Miller,
Eric Dumazet, Florian Fainelli, Jakub Kicinski, Jonas Gorski,
Paolo Abeni, Vladimir Oltean
Cc: LKML, kernel-janitors
Le 19/11/2026 à 17:37, Markus Elfring a écrit :
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 19 Nov 2026 17:30:09 +0100
>
> Reuse existing functionality from devm_clk_get_optional_enabled()
> instead of keeping duplicate source code.
>
> The source code was transformed by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/net/dsa/bcm_sf2.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 1747a1f20c78..011ce79392e8 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -1467,14 +1467,10 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
> base++;
> }
>
> - priv->clk = devm_clk_get_optional(&pdev->dev, "sw_switch");
> + priv->clk = devm_clk_get_optional_enabled(&pdev->dev, "sw_switch");
> if (IS_ERR(priv->clk))
> return PTR_ERR(priv->clk);
>
> - ret = clk_prepare_enable(priv->clk);
> - if (ret)
> - return ret;
> -
> priv->clk_mdiv = devm_clk_get_optional(&pdev->dev, "sw_switch_mdiv");
> if (IS_ERR(priv->clk_mdiv)) {
> ret = PTR_ERR(priv->clk_mdiv);
Hi,
NACK, this patch is wrong because the remove function and the error
handling path of the probe need to be updated.
CJ
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: dsa: bcm_sf2: Use devm_clk_get_optional_enabled() in bcm_sf2_sw_probe()
2026-11-19 20:21 ` Christophe JAILLET
@ 2026-11-19 21:06 ` Florian Fainelli
0 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2026-11-19 21:06 UTC (permalink / raw)
To: Christophe JAILLET, Markus Elfring, netdev, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Jonas Gorski,
Paolo Abeni, Vladimir Oltean
Cc: LKML, kernel-janitors
On 11/19/26 12:21, Christophe JAILLET wrote:
> Le 19/11/2026 à 17:37, Markus Elfring a écrit :
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Thu, 19 Nov 2026 17:30:09 +0100
>>
>> Reuse existing functionality from devm_clk_get_optional_enabled()
>> instead of keeping duplicate source code.
>>
>> The source code was transformed by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>> drivers/net/dsa/bcm_sf2.c | 6 +-----
>> 1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
>> index 1747a1f20c78..011ce79392e8 100644
>> --- a/drivers/net/dsa/bcm_sf2.c
>> +++ b/drivers/net/dsa/bcm_sf2.c
>> @@ -1467,14 +1467,10 @@ static int bcm_sf2_sw_probe(struct
>> platform_device *pdev)
>> base++;
>> }
>> - priv->clk = devm_clk_get_optional(&pdev->dev, "sw_switch");
>> + priv->clk = devm_clk_get_optional_enabled(&pdev->dev, "sw_switch");
>> if (IS_ERR(priv->clk))
>> return PTR_ERR(priv->clk);
>> - ret = clk_prepare_enable(priv->clk);
>> - if (ret)
>> - return ret;
>> -
>> priv->clk_mdiv = devm_clk_get_optional(&pdev->dev,
>> "sw_switch_mdiv");
>> if (IS_ERR(priv->clk_mdiv)) {
>> ret = PTR_ERR(priv->clk_mdiv);
>
> Hi,
>
> NACK, this patch is wrong because the remove function and the error
> handling path of the probe need to be updated.
My bad you are right this creates the following regressions:
devm_clk_get_optional_enabled() registers a devres action that calls
clk_disable_unprepare() on detach. The patch leaves the manual
clk_disable_unprepare(priv->clk) in two places in
drivers/net/dsa/bcm_sf2.c: the probe error path (out_clk:) and
bcm_sf2_sw_remove().
pw-bot: cr
--
Florian
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-19 21:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 16:37 [PATCH net-next] net: dsa: bcm_sf2: Use devm_clk_get_optional_enabled() in bcm_sf2_sw_probe() Markus Elfring
2026-11-19 17:45 ` Florian Fainelli
2026-11-19 20:21 ` Christophe JAILLET
2026-11-19 21:06 ` Florian Fainelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®