i2c: mt7621: Use devm_clk_get_enabled()
authorAndi Shyti <andi.shyti@kernel.org>
Sun, 11 Jun 2023 22:56:55 +0000 (00:56 +0200)
committerWolfram Sang <wsa@kernel.org>
Fri, 23 Jun 2023 09:56:24 +0000 (11:56 +0200)
Replace the pair of functions, devm_clk_get() and clk_prepare_enable(),
with a single function devm_clk_get_enabled().

Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/busses/i2c-mt7621.c

index f9c294e2bd3c5840665920c84fde5e3563ecec5e..104bb194e9906d68c6a59019acb1ca27a77139f8 100644 (file)
@@ -282,16 +282,11 @@ static int mtk_i2c_probe(struct platform_device *pdev)
        if (IS_ERR(i2c->base))
                return PTR_ERR(i2c->base);
 
-       i2c->clk = devm_clk_get(&pdev->dev, NULL);
+       i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
        if (IS_ERR(i2c->clk)) {
-               dev_err(&pdev->dev, "no clock defined\n");
+               dev_err(&pdev->dev, "Failed to enable clock\n");
                return PTR_ERR(i2c->clk);
        }
-       ret = clk_prepare_enable(i2c->clk);
-       if (ret) {
-               dev_err(&pdev->dev, "Unable to enable clock\n");
-               return ret;
-       }
 
        i2c->dev = &pdev->dev;
 
@@ -301,8 +296,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
 
        if (i2c->bus_freq == 0) {
                dev_warn(i2c->dev, "clock-frequency 0 not supported\n");
-               ret = -EINVAL;
-               goto err_disable_clk;
+               return -EINVAL;
        }
 
        adap = &i2c->adap;
@@ -320,23 +314,17 @@ static int mtk_i2c_probe(struct platform_device *pdev)
 
        ret = i2c_add_adapter(adap);
        if (ret < 0)
-               goto err_disable_clk;
+               return ret;
 
        dev_info(&pdev->dev, "clock %u kHz\n", i2c->bus_freq / 1000);
 
        return 0;
-
-err_disable_clk:
-       clk_disable_unprepare(i2c->clk);
-
-       return ret;
 }
 
 static void mtk_i2c_remove(struct platform_device *pdev)
 {
        struct mtk_i2c *i2c = platform_get_drvdata(pdev);
 
-       clk_disable_unprepare(i2c->clk);
        i2c_del_adapter(&i2c->adap);
 }