From: Markus Elfring <Markus.Elfring@web.de>
To: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Hemanth Selam <hemanth.selam@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
Jonas Gorski <jonas.gorski@gmail.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Christophe Jaillet <christophe.jaillet@wanadoo.fr>,
Florian Fainelli <f.fainelli@gmail.com>,
Frank Li <Frank.Li@kernel.org>
Subject: [PATCH net-next] bcm63xx_enet: Use devm_clk_get_enabled() in two probe functions
Date: Tue, 24 Nov 2026 20:23:24 +0100 [thread overview]
Message-ID: <d293609b-c8cd-4993-a243-89c6d1ace4a0@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Nov 2026 19:50:57 +0100
* Reuse existing functionality from devm_clk_get_enabled() instead of
keeping duplicate source code.
* Omit a clk_disable_unprepare() call on error handling paths
and in the implementation of two remove functions.
* Omit two labels.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 26 ++++----------------
1 file changed, 5 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index f6595fdc888d..e98130092357 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1751,14 +1751,11 @@ static int bcm_enet_probe(struct platform_device *pdev)
priv->irq_rx = irq_rx;
priv->irq_tx = irq_tx;
- priv->mac_clk = devm_clk_get(&pdev->dev, "enet");
+ priv->mac_clk = devm_clk_get_enabled(&pdev->dev, "enet");
if (IS_ERR(priv->mac_clk)) {
ret = PTR_ERR(priv->mac_clk);
goto out;
}
- ret = clk_prepare_enable(priv->mac_clk);
- if (ret)
- goto out;
/* initialize default and fetch platform data */
priv->rx_ring_size = BCMENET_DEF_RX_DESC;
@@ -1792,11 +1789,11 @@ static int bcm_enet_probe(struct platform_device *pdev)
if (IS_ERR(priv->phy_clk)) {
ret = PTR_ERR(priv->phy_clk);
priv->phy_clk = NULL;
- goto out_disable_clk_mac;
+ goto out;
}
ret = clk_prepare_enable(priv->phy_clk);
if (ret)
- goto out_disable_clk_mac;
+ goto out;
}
/* do minimal hardware init to be able to probe mii bus */
@@ -1890,8 +1887,6 @@ static int bcm_enet_probe(struct platform_device *pdev)
enet_writel(priv, 0, ENET_MIISC_REG);
clk_disable_unprepare(priv->phy_clk);
-out_disable_clk_mac:
- clk_disable_unprepare(priv->mac_clk);
out:
free_netdev(dev);
return ret;
@@ -1926,9 +1921,7 @@ static void bcm_enet_remove(struct platform_device *pdev)
bcm_enet_mdio_write_mii);
}
- /* disable hw block clocks */
clk_disable_unprepare(priv->phy_clk);
- clk_disable_unprepare(priv->mac_clk);
free_netdev(dev);
}
@@ -2692,14 +2685,11 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
goto out;
}
- priv->mac_clk = devm_clk_get(&pdev->dev, "enetsw");
+ priv->mac_clk = devm_clk_get_enabled(&pdev->dev, "enetsw");
if (IS_ERR(priv->mac_clk)) {
ret = PTR_ERR(priv->mac_clk);
goto out;
}
- ret = clk_prepare_enable(priv->mac_clk);
- if (ret)
- goto out;
priv->rx_chan = 0;
priv->tx_chan = 1;
@@ -2718,7 +2708,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
ret = register_netdev(dev);
if (ret)
- goto out_disable_clk;
+ goto out;
netif_carrier_off(dev);
platform_set_drvdata(pdev, dev);
@@ -2727,8 +2717,6 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
return 0;
-out_disable_clk:
- clk_disable_unprepare(priv->mac_clk);
out:
free_netdev(dev);
return ret;
@@ -2738,16 +2726,12 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
/* exit func, stops hardware and unregisters netdevice */
static void bcm_enetsw_remove(struct platform_device *pdev)
{
- struct bcm_enet_priv *priv;
struct net_device *dev;
/* stop netdevice */
dev = platform_get_drvdata(pdev);
- priv = netdev_priv(dev);
unregister_netdev(dev);
- clk_disable_unprepare(priv->mac_clk);
-
free_netdev(dev);
}
--
2.56.1
next reply other threads:[~2026-11-24 19:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 19:23 Markus Elfring [this message]
2026-11-24 20:20 ` Andy Shevchenko
2026-11-24 20:28 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d293609b-c8cd-4993-a243-89c6d1ace4a0@web.de \
--to=markus.elfring@web.de \
--cc=Frank.Li@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andriy.shevchenko@linux.intel.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=hemanth.selam@gmail.com \
--cc=horms@kernel.org \
--cc=jonas.gorski@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®