mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-05 04:46:54 -04:00
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>
This commit is contained in:
@@ -1801,13 +1801,10 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv)
|
||||
struct clk *clk;
|
||||
int rc;
|
||||
|
||||
clk = devm_clk_get(priv->dev, NULL /* MACCLK */);
|
||||
clk = devm_clk_get_enabled(priv->dev, NULL /* MACCLK */);
|
||||
if (IS_ERR(clk))
|
||||
return PTR_ERR(clk);
|
||||
priv->clk = clk;
|
||||
rc = clk_prepare_enable(priv->clk);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
/* Aspeed specifies a 100MHz clock is required for up to
|
||||
* 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz
|
||||
@@ -1816,21 +1813,17 @@ static int ftgmac100_setup_clk(struct ftgmac100 *priv)
|
||||
rc = clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ :
|
||||
FTGMAC_100MHZ);
|
||||
if (rc)
|
||||
goto cleanup_clk;
|
||||
return rc;
|
||||
|
||||
/* RCLK is for RMII, typically used for NCSI. Optional because it's not
|
||||
* necessary if it's the AST2400 MAC, or the MAC is configured for
|
||||
* RGMII, or the controller is not an ASPEED-based controller.
|
||||
*/
|
||||
priv->rclk = devm_clk_get_optional(priv->dev, "RCLK");
|
||||
rc = clk_prepare_enable(priv->rclk);
|
||||
if (!rc)
|
||||
return 0;
|
||||
priv->rclk = devm_clk_get_optional_enabled(priv->dev, "RCLK");
|
||||
if (IS_ERR(priv->rclk))
|
||||
return PTR_ERR(priv->rclk);
|
||||
|
||||
cleanup_clk:
|
||||
clk_disable_unprepare(priv->clk);
|
||||
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
err_register_netdev:
|
||||
clk_disable_unprepare(priv->rclk);
|
||||
clk_disable_unprepare(priv->clk);
|
||||
err_phy_connect:
|
||||
ftgmac100_phy_disconnect(netdev);
|
||||
err_ncsi_dev:
|
||||
@@ -2088,9 +2079,6 @@ static void ftgmac100_remove(struct platform_device *pdev)
|
||||
ncsi_unregister_dev(priv->ndev);
|
||||
unregister_netdev(netdev);
|
||||
|
||||
clk_disable_unprepare(priv->rclk);
|
||||
clk_disable_unprepare(priv->clk);
|
||||
|
||||
/* There's a small chance the reset task will have been re-queued,
|
||||
* during stop, make sure it's gone before we free the structure.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user