From: Yangtao Li <frank.li@vivo.com>
To: clement.leger@bootlin.com, andrew@lunn.ch, f.fainelli@gmail.com,
olteanv@gmail.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, ulli.kroll@googlemail.com,
linus.walleij@linaro.org, marcin.s.wojtas@gmail.com,
linux@armlinux.org.uk, alexandre.torgue@foss.st.com,
joabreu@synopsys.com, mcoquelin.stm32@gmail.com,
hkallweit1@gmail.com, kees@kernel.org, justinstitt@google.com,
u.kleine-koenig@pengutronix.de, horms@kernel.org,
sd@queasysnail.net
Cc: linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Yangtao Li <frank.li@vivo.com>
Subject: [net-next v2 6/9] net: ethernet: broadcom: bcm63xx_enet: Convert to devm_clk_get_enabled()
Date: Fri, 23 Aug 2024 01:21:18 -0600 [thread overview]
Message-ID: <20240823072122.2053401-7-frank.li@vivo.com> (raw)
In-Reply-To: <20240823072122.2053401-1-frank.li@vivo.com>
Convert devm_clk_get(), clk_prepare_enable() to a single
call to devm_clk_get_enabled(), as this is exactly
what this function does.
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
drivers/net/ethernet/broadcom/bcm63xx_enet.c | 47 ++++++--------------
drivers/net/ethernet/broadcom/bcm63xx_enet.h | 6 ---
2 files changed, 13 insertions(+), 40 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 3c0e3b9828be..6e288cee2c35 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1718,6 +1718,7 @@ static int bcm_enet_probe(struct platform_device *pdev)
struct bcm63xx_enet_platform_data *pd;
int irq, irq_rx, irq_tx;
struct mii_bus *bus;
+ struct clk *phy_clk, *mac_clk;
int i, ret;
if (!bcm_enet_shared_base[0])
@@ -1752,14 +1753,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");
- if (IS_ERR(priv->mac_clk)) {
- ret = PTR_ERR(priv->mac_clk);
+ mac_clk = devm_clk_get_enabled(&pdev->dev, "enet");
+ if (IS_ERR(mac_clk)) {
+ ret = PTR_ERR(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;
@@ -1789,15 +1787,11 @@ static int bcm_enet_probe(struct platform_device *pdev)
if (priv->has_phy && !priv->use_external_mii) {
/* using internal PHY, enable clock */
- priv->phy_clk = devm_clk_get(&pdev->dev, "ephy");
- if (IS_ERR(priv->phy_clk)) {
- ret = PTR_ERR(priv->phy_clk);
- priv->phy_clk = NULL;
- goto out_disable_clk_mac;
+ phy_clk = devm_clk_get_enabled(&pdev->dev, "ephy");
+ if (IS_ERR(phy_clk)) {
+ ret = PTR_ERR(phy_clk);
+ goto out;
}
- ret = clk_prepare_enable(priv->phy_clk);
- if (ret)
- goto out_disable_clk_mac;
}
/* do minimal hardware init to be able to probe mii bus */
@@ -1889,10 +1883,7 @@ static int bcm_enet_probe(struct platform_device *pdev)
out_uninit_hw:
/* turn off mdc clock */
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;
@@ -1927,10 +1918,6 @@ 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);
}
@@ -2648,6 +2635,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
struct bcm63xx_enetsw_platform_data *pd;
struct resource *res_mem;
int ret, irq_rx, irq_tx;
+ struct clk *mac_clk;
if (!bcm_enet_shared_base[0])
return -EPROBE_DEFER;
@@ -2694,14 +2682,11 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
goto out;
}
- priv->mac_clk = devm_clk_get(&pdev->dev, "enetsw");
- if (IS_ERR(priv->mac_clk)) {
- ret = PTR_ERR(priv->mac_clk);
+ mac_clk = devm_clk_get_enabled(&pdev->dev, "enetsw");
+ if (IS_ERR(mac_clk)) {
+ ret = PTR_ERR(mac_clk);
goto out;
}
- ret = clk_prepare_enable(priv->mac_clk);
- if (ret)
- goto out;
priv->rx_chan = 0;
priv->tx_chan = 1;
@@ -2720,7 +2705,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);
@@ -2729,8 +2714,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;
@@ -2740,16 +2723,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);
}
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.h b/drivers/net/ethernet/broadcom/bcm63xx_enet.h
index 78f1830fb3cb..e98838b8b92f 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.h
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.h
@@ -316,12 +316,6 @@ struct bcm_enet_priv {
/* lock mib update between userspace request and workqueue */
struct mutex mib_update_lock;
- /* mac clock */
- struct clk *mac_clk;
-
- /* phy clock if internal phy is used */
- struct clk *phy_clk;
-
/* network device reference */
struct net_device *net_dev;
--
2.39.0
next prev parent reply other threads:[~2024-08-23 7:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 7:21 [net-next v2 0/9] net: convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() Yangtao Li
2024-08-23 7:21 ` [net-next v2 1/9] net: stmmac: dwmac-intel-plat: Convert to devm_clk_get_enabled() Yangtao Li
2024-08-27 14:48 ` Simon Horman
2024-08-23 7:21 ` [net-next v2 2/9] net: stmmac: platform: Convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() Yangtao Li
2024-08-23 9:11 ` Serge Semin
2024-08-23 9:15 ` Biju Das
2024-08-23 9:37 ` Serge Semin
2024-08-23 9:41 ` Biju Das
2024-08-23 7:21 ` [net-next v2 3/9] net: ethernet: cortina: Convert to devm_clk_get_enabled() Yangtao Li
2024-08-26 8:46 ` Linus Walleij
2024-08-26 22:15 ` Jakub Kicinski
2024-08-23 7:21 ` [net-next v2 4/9] net: mdio: hisi-femac: " Yangtao Li
2024-08-23 7:21 ` [net-next v2 5/9] net: dsa: rzn1_a5psw: " Yangtao Li
2024-08-23 7:21 ` Yangtao Li [this message]
2024-08-26 22:15 ` [net-next v2 6/9] net: ethernet: broadcom: bcm63xx_enet: " Jakub Kicinski
2024-08-23 7:21 ` [net-next v2 7/9] net: ethernet: marvell: mvneta: " Yangtao Li
2024-08-23 16:54 ` Marcin Wojtas
2024-08-23 7:21 ` [net-next v2 8/9] net: mvpp2: Convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() Yangtao Li
2024-08-23 16:52 ` Marcin Wojtas
2024-08-23 7:21 ` [net-next v2 9/9] net: marvell: pxa168_eth: Convert to devm_clk_get_enabled() Yangtao Li
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=20240823072122.2053401-7-frank.li@vivo.com \
--to=frank.li@vivo.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew@lunn.ch \
--cc=clement.leger@bootlin.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=joabreu@synopsys.com \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=marcin.s.wojtas@gmail.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=u.kleine-koenig@pengutronix.de \
--cc=ulli.kroll@googlemail.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®