All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Oleksij Rempel <linux@rempel-privat.de>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	NXP Linux Team <linux-imx@nxp.com>
Cc: linux-i2c@vger.kernel.org,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	linux-clk@vger.kernel.org
Subject: [PATCH] i2c: imx: Simplify using devm_clk_get_prepared()
Date: Wed, 24 Mar 2021 21:12:23 +0100	[thread overview]
Message-ID: <20210324201223.75921-1-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20210301135053.1462168-1-u.kleine-koenig@pengutronix.de>

devm_clk_get_prepared returns the clk already prepared and the
automatically called cleanup cares for unpreparing. So simplify .probe
and .remove accordingly.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

this simplification depends on a patch set that introduces
devm_clk_get_prepared() and friends.

The most recent version of this patch set can be found at

	https://lore.kernel.org/r/20210301135053.1462168-1-u.kleine-koenig@pengutronix.de

Unfortunately I didn't get any feedback at all from the clk maintainers
on it, so I try to make other maintainers aware of it in the expectation
that the simplifications are welcome and so lure the clk maintainers to
share their thoughts.

Best regards
Uwe

 drivers/i2c/busses/i2c-imx.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index b80fdc1f0092..c0e18a6caa38 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -1405,16 +1405,10 @@ static int i2c_imx_probe(struct platform_device *pdev)
 	ACPI_COMPANION_SET(&i2c_imx->adapter.dev, ACPI_COMPANION(&pdev->dev));
 
 	/* Get I2C clock */
-	i2c_imx->clk = devm_clk_get(&pdev->dev, NULL);
+	i2c_imx->clk = devm_clk_get_prepared(&pdev->dev, NULL);
 	if (IS_ERR(i2c_imx->clk))
 		return dev_err_probe(&pdev->dev, PTR_ERR(i2c_imx->clk),
-				     "can't get I2C clock\n");
-
-	ret = clk_prepare_enable(i2c_imx->clk);
-	if (ret) {
-		dev_err(&pdev->dev, "can't enable I2C clock, ret=%d\n", ret);
-		return ret;
-	}
+				     "can't get prepared I2C clock\n");
 
 	/* Init queue */
 	init_waitqueue_head(&i2c_imx->queue);
@@ -1517,7 +1511,6 @@ static int i2c_imx_remove(struct platform_device *pdev)
 	irq = platform_get_irq(pdev, 0);
 	if (irq >= 0)
 		free_irq(irq, i2c_imx);
-	clk_disable_unprepare(i2c_imx->clk);
 
 	pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-- 
2.30.2


  parent reply	other threads:[~2021-03-24 20:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 13:50 [PATCH v3 0/3] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König
2021-03-01 13:50 ` [PATCH v3 1/3] clk: generalize devm_clk_get() a bit Uwe Kleine-König
2021-03-01 13:50 ` [PATCH v3 2/3] clk: Provide new devm_clk_helpers for prepared and enabled clocks Uwe Kleine-König
2021-03-01 13:50 ` [PATCH v3 3/3] pwm: atmel: Simplify using devm_clk_get_prepared() Uwe Kleine-König
2021-03-22 14:22 ` [PATCH v3 0/3] clk: provide new devm helpers for prepared and enabled clocks Uwe Kleine-König
2021-03-24 20:12 ` Uwe Kleine-König [this message]
2021-03-24 20:22   ` [PATCH] i2c: imx: Simplify using devm_clk_get_prepared() Uwe Kleine-König
2021-03-25  4:49     ` Oleksij Rempel
2021-03-26 13:42   ` kernel test robot
2021-03-26 13:42     ` kernel test robot
2021-03-31  3:37   ` kernel test robot
2021-03-31  3:37     ` kernel test robot
2021-03-24 20:17 ` [PATCH] spi: davinci: " Uwe Kleine-König
2021-03-24 20:22   ` Uwe Kleine-König
2021-03-30 17:04     ` Mark Brown
2021-03-30  4:09   ` kernel test robot
2021-03-30  4:09     ` kernel test robot
2021-03-24 20:27 ` [PATCH] rtc: at91sma9: Simplify using devm_clk_get_enabled() Uwe Kleine-König
2021-03-24 20:27   ` Uwe Kleine-König
2021-03-25  1:11   ` kernel test robot
2021-03-25  1:11     ` kernel test robot
2021-03-25  1:11     ` kernel test robot
2021-03-25 15:15   ` kernel test robot
2021-03-25 15:15     ` kernel test robot
2021-03-25 15:15     ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210324201223.75921-1-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux@rempel-privat.de \
    --cc=mturquette@baylibre.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.