Skip to content

Commit 4659cce

Browse files
lunnPaolo Abeni
authored andcommitted
net: ftgmac100: Use devm_clk_get_enabled
Make use of devm_ methods to request and enable clocks to simplify cleanup. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com> Link: https://patch.msgid.link/20260206-ftgmac-cleanup-v5-6-ad28a9067ea7@aspeedtech.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 67127f8 commit 4659cce

1 file changed

Lines changed: 6 additions & 18 deletions

File tree

drivers/net/ethernet/faraday/ftgmac100.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,13 +1801,10 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv)
18011801
struct clk *clk;
18021802
int rc;
18031803

1804-
clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
1804+
clk = devm_clk_get_enabled(priv->dev, NULL /* MACCLK */);
18051805
if (IS_ERR(clk))
18061806
return PTR_ERR(clk);
18071807
priv->clk = clk;
1808-
rc = clk_prepare_enable(priv->clk);
1809-
if (rc)
1810-
return rc;
18111808

18121809
/* Aspeed specifies a 100MHz clock is required for up to
18131810
* 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz
@@ -1816,21 +1813,17 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv)
18161813
rc = clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
18171814
FTGMAC_100MHZ);
18181815
if (rc)
1819-
goto cleanup_clk;
1816+
return rc;
18201817

18211818
/* RCLK is for RMII, typically used for NCSI. Optional because it's not
18221819
* necessary if it's the AST2400 MAC, or the MAC is configured for
18231820
* RGMII, or the controller is not an ASPEED-based controller.
18241821
*/
1825-
priv->rclk = devm_clk_get_optional(priv->dev, "RCLK");
1826-
rc = clk_prepare_enable(priv->rclk);
1827-
if (!rc)
1828-
return 0;
1822+
priv->rclk = devm_clk_get_optional_enabled(priv->dev, "RCLK");
1823+
if (IS_ERR(priv->rclk))
1824+
return PTR_ERR(priv->rclk);
18291825

1830-
cleanup_clk:
1831-
clk_disable_unprepare(priv->clk);
1832-
1833-
return rc;
1826+
return 0;
18341827
}
18351828

18361829
static bool ftgmac100_has_child_node(struct device_node *np, const char *name)
@@ -2064,8 +2057,6 @@ static int ftgmac100_probe(struct platform_device *pdev)
20642057
return 0;
20652058

20662059
err_register_netdev:
2067-
clk_disable_unprepare(priv->rclk);
2068-
clk_disable_unprepare(priv->clk);
20692060
err_phy_connect:
20702061
ftgmac100_phy_disconnect(netdev);
20712062
err_ncsi_dev:
@@ -2088,9 +2079,6 @@ static void ftgmac100_remove(struct platform_device *pdev)
20882079
ncsi_unregister_dev(priv->ndev);
20892080
unregister_netdev(netdev);
20902081

2091-
clk_disable_unprepare(priv->rclk);
2092-
clk_disable_unprepare(priv->clk);
2093-
20942082
/* There's a small chance the reset task will have been re-queued,
20952083
* during stop, make sure it's gone before we free the structure.
20962084
*/

0 commit comments

Comments
 (0)