net: allwinner: Use devm_clk_get_enabled() in emac_probe()
PATCH 1/1 net: allwinner: Use devm_clk_get_enabled() in emac_probe()
From: Markus Elfring <[email protected]>
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 <[email protected]>
--- drivers/net/ethernet/allwinner/sun4i-emac.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/ethernet/allwinner/sun4i-emac.c +2 -11
@@ -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);
Signature · 1 line
2.56.1