* [PATCH] net: allwinner: Use devm_clk_get_enabled() in emac_probe()
@ 2026-11-24 17:19 Markus Elfring
2026-11-24 20:17 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-11-24 17:19 UTC (permalink / raw)
To: linux-sunxi, linux-arm-kernel, netdev, Andrew Lunn,
Arnd Bergmann, bui duc phuc, Chen-Yu Tsai, David S. Miller,
Eric Dumazet, Frank Li, Hans de Goede, Jakub Kicinski,
Jernej Skrabec, Joe Damato, Julia Lawall, Li Youhong,
Maxime Ripard, Paolo Abeni, Samuel Holland
Cc: LKML, kernel-janitors, Andy Shevchenko, Christophe Jaillet,
Florian Fainelli
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Nov 2026 17:56:11 +0100
* Reuse existing functionality from devm_clk_get_enabled() instead of
keeping duplicate source code.
* Delete a clk_disable_unprepare() call on an error handling path
and in the implementation of the function “emac_remove”.
* Omit the label “out_clk_disable_unprepare”.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ethernet/allwinner/sun4i-emac.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index d7ee42b2c197..c075356cf6cc 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -1001,22 +1001,16 @@ static int emac_probe(struct platform_device *pdev)
if (emac_configure_dma(db))
netdev_info(ndev, "configure dma failed. disable dma.\n");
- db->clk = devm_clk_get(&pdev->dev, NULL);
+ db->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(db->clk)) {
ret = PTR_ERR(db->clk);
goto out_dispose_mapping;
}
- ret = clk_prepare_enable(db->clk);
- if (ret) {
- dev_err(&pdev->dev, "Error couldn't enable clock (%d)\n", ret);
- goto out_dispose_mapping;
- }
-
ret = sunxi_sram_claim(&pdev->dev);
if (ret) {
dev_err(&pdev->dev, "Error couldn't map SRAM to device\n");
- goto out_clk_disable_unprepare;
+ goto out_dispose_mapping;
}
db->phy_node = of_parse_phandle(np, "phy-handle", 0);
@@ -1065,8 +1059,6 @@ static int emac_probe(struct platform_device *pdev)
out_release_sram:
of_node_put(db->phy_node);
sunxi_sram_release(&pdev->dev);
-out_clk_disable_unprepare:
- clk_disable_unprepare(db->clk);
out_dispose_mapping:
irq_dispose_mapping(ndev->irq);
dma_release_channel(db->rx_chan);
@@ -1093,7 +1085,6 @@ static void emac_remove(struct platform_device *pdev)
unregister_netdev(ndev);
of_node_put(db->phy_node);
sunxi_sram_release(&pdev->dev);
- clk_disable_unprepare(db->clk);
irq_dispose_mapping(ndev->irq);
iounmap(db->membase);
free_netdev(ndev);
--
2.56.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] net: allwinner: Use devm_clk_get_enabled() in emac_probe()
2026-11-24 17:19 [PATCH] net: allwinner: Use devm_clk_get_enabled() in emac_probe() Markus Elfring
@ 2026-11-24 20:17 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2026-11-24 20:17 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-sunxi, linux-arm-kernel, netdev, Andrew Lunn,
Arnd Bergmann, bui duc phuc, Chen-Yu Tsai, David S. Miller,
Eric Dumazet, Frank Li, Hans de Goede, Jakub Kicinski,
Jernej Skrabec, Joe Damato, Julia Lawall, Li Youhong,
Maxime Ripard, Paolo Abeni, Samuel Holland, LKML,
kernel-janitors, Christophe Jaillet, Florian Fainelli
On Tue, Nov 24, 2026 at 06:19:54PM +0100, Markus Elfring wrote:
>
> * Reuse existing functionality from devm_clk_get_enabled() instead of
> keeping duplicate source code.
>
> * Delete a clk_disable_unprepare() call on an error handling path
> and in the implementation of the function “emac_remove”.
>
> * Omit the label “out_clk_disable_unprepare”.
>
> This issue was detected by using the Coccinelle software.
This breaks the order at remove and probe error path cases.
Note, devm_*() at this case will keep just a clk object, but
the actual enabling is done explicitly. W/o testing on real
HW it's hard to say if this order is strict or not.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-24 20:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 17:19 [PATCH] net: allwinner: Use devm_clk_get_enabled() in emac_probe() Markus Elfring
2026-11-24 20:17 ` Andy Shevchenko
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®