* [PATCH] i2c: exynos5: simplify probe with devm
@ 2025-12-17 20:49 Rosen Penev
2026-01-15 15:31 ` Andi Shyti
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2025-12-17 20:49 UTC (permalink / raw)
To: linux-i2c
Cc: Andi Shyti, Krzysztof Kozlowski, Alim Akhtar,
moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES,
open list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES,
open list
Cleans up probe a little bit and separates preparation from enablement.
Also use devm for i2c_add_adapter to get rid of the remove function.
Fix return code for failed clk_get_prepared. It returns PTR_ERR.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/i2c/busses/i2c-exynos5.c | 41 ++++++++------------------------
1 file changed, 10 insertions(+), 31 deletions(-)
diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
index 9c1c5f3c09f6..fcc062910497 100644
--- a/drivers/i2c/busses/i2c-exynos5.c
+++ b/drivers/i2c/busses/i2c-exynos5.c
@@ -903,23 +903,20 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
i2c->adap.retries = 3;
i2c->dev = &pdev->dev;
- i2c->clk = devm_clk_get(&pdev->dev, "hsi2c");
- if (IS_ERR(i2c->clk)) {
- dev_err(&pdev->dev, "cannot get clock\n");
- return -ENOENT;
- }
+ i2c->clk = devm_clk_get_prepared(&pdev->dev, "hsi2c");
+ if (IS_ERR(i2c->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk), "cannot get clock\n");
- i2c->pclk = devm_clk_get_optional(&pdev->dev, "hsi2c_pclk");
- if (IS_ERR(i2c->pclk)) {
+ i2c->pclk = devm_clk_get_optional_prepared(&pdev->dev, "hsi2c_pclk");
+ if (IS_ERR(i2c->pclk))
return dev_err_probe(&pdev->dev, PTR_ERR(i2c->pclk),
"cannot get pclk");
- }
- ret = clk_prepare_enable(i2c->pclk);
+ ret = clk_enable(i2c->pclk);
if (ret)
return ret;
- ret = clk_prepare_enable(i2c->clk);
+ ret = clk_enable(i2c->clk);
if (ret)
goto err_pclk;
@@ -958,35 +955,18 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
exynos5_i2c_reset(i2c);
- ret = i2c_add_adapter(&i2c->adap);
- if (ret < 0)
- goto err_clk;
+ ret = devm_i2c_add_adapter(&pdev->dev, &i2c->adap);
platform_set_drvdata(pdev, i2c);
- clk_disable(i2c->clk);
- clk_disable(i2c->pclk);
-
- return 0;
-
err_clk:
- clk_disable_unprepare(i2c->clk);
+ clk_disable(i2c->clk);
err_pclk:
- clk_disable_unprepare(i2c->pclk);
+ clk_disable(i2c->pclk);
return ret;
}
-static void exynos5_i2c_remove(struct platform_device *pdev)
-{
- struct exynos5_i2c *i2c = platform_get_drvdata(pdev);
-
- i2c_del_adapter(&i2c->adap);
-
- clk_unprepare(i2c->clk);
- clk_unprepare(i2c->pclk);
-}
-
static int exynos5_i2c_suspend_noirq(struct device *dev)
{
struct exynos5_i2c *i2c = dev_get_drvdata(dev);
@@ -1036,7 +1016,6 @@ static const struct dev_pm_ops exynos5_i2c_dev_pm_ops = {
static struct platform_driver exynos5_i2c_driver = {
.probe = exynos5_i2c_probe,
- .remove = exynos5_i2c_remove,
.driver = {
.name = "exynos5-hsi2c",
.pm = pm_sleep_ptr(&exynos5_i2c_dev_pm_ops),
--
2.52.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] i2c: exynos5: simplify probe with devm
2025-12-17 20:49 [PATCH] i2c: exynos5: simplify probe with devm Rosen Penev
@ 2026-01-15 15:31 ` Andi Shyti
0 siblings, 0 replies; 2+ messages in thread
From: Andi Shyti @ 2026-01-15 15:31 UTC (permalink / raw)
To: Rosen Penev
Cc: linux-i2c, Krzysztof Kozlowski, Alim Akhtar,
moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES,
open list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES,
open list
Hi Rosen,
On Wed, Dec 17, 2025 at 12:49:44PM -0800, Rosen Penev wrote:
> Cleans up probe a little bit and separates preparation from enablement.
>
> Also use devm for i2c_add_adapter to get rid of the remove function.
>
> Fix return code for failed clk_get_prepared. It returns PTR_ERR.
The patch is good, but this commit log is messy. Please send a
new version of the commit log where you describe or list things
you have changed using the imperative form (sentences like
"Cleans up probe a little bit" mean very little).
No need to resend, just reply to this email and I can update the
log before merging.
Thanks,
Andi
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-15 15:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-17 20:49 [PATCH] i2c: exynos5: simplify probe with devm Rosen Penev
2026-01-15 15:31 ` Andi Shyti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®