* [PATCH] i2c: exynos5: simplify probe with devm
@ 2025-12-17 20:49 Rosen Penev
0 siblings, 0 replies; only message 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 related [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-17 20:50 UTC | newest]
Thread overview: (only message) (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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).