]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: ftgmac100: Use devm_clk_get_enabled
authorAndrew Lunn <andrew@lunn.ch>
Fri, 6 Feb 2026 03:17:46 +0000 (11:17 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 10 Feb 2026 12:40:50 +0000 (13:40 +0100)
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>
drivers/net/ethernet/faraday/ftgmac100.c

index ec2e7ec23ddf557ee350f3fb30ab07e19d8fffce..1fb03dd55c8f12f680fb2e8424d6d0f2215d88ca 100644 (file)
@@ -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.
         */