]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: mv643xx: fix wrong devm_clk_get usage
authorRosen Penev <rosenp@gmail.com>
Mon, 30 Sep 2024 20:29:51 +0000 (13:29 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 4 Oct 2024 15:59:47 +0000 (08:59 -0700)
This clock should be optional. In addition, PTR_ERR can be -EPROBE_DEFER
in which case it should return.

devm_clk_get_optional_enabled also allows removing explicit clock enable
and disable calls.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240930202951.297737-3-rosenp@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/mv643xx_eth.c

index 3036ac9f042a414b2a5b977b002490e4ed090f9d..34880017d9dc4e09dc0a43572928424edb70d938 100644 (file)
@@ -2858,9 +2858,9 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
        if (IS_ERR(msp->base))
                return PTR_ERR(msp->base);
 
-       msp->clk = devm_clk_get(&pdev->dev, NULL);
-       if (!IS_ERR(msp->clk))
-               clk_prepare_enable(msp->clk);
+       msp->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
+       if (IS_ERR(msp->clk))
+               return PTR_ERR(msp->clk);
 
        /*
         * (Re-)program MBUS remapping windows if we are asked to.
@@ -2871,7 +2871,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 
        ret = mv643xx_eth_shared_of_probe(pdev);
        if (ret)
-               goto err_put_clk;
+               return ret;
        pd = dev_get_platdata(&pdev->dev);
 
        msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
@@ -2879,20 +2879,11 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
        infer_hw_params(msp);
 
        return 0;
-
-err_put_clk:
-       if (!IS_ERR(msp->clk))
-               clk_disable_unprepare(msp->clk);
-       return ret;
 }
 
 static void mv643xx_eth_shared_remove(struct platform_device *pdev)
 {
-       struct mv643xx_eth_shared_private *msp = platform_get_drvdata(pdev);
-
        mv643xx_eth_shared_of_remove();
-       if (!IS_ERR(msp->clk))
-               clk_disable_unprepare(msp->clk);
 }
 
 static struct platform_driver mv643xx_eth_shared_driver = {