summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Shimko <a.shimko.dev@gmail.com>2026-01-30 14:10:36 +0300
committerAndi Shyti <andi.shyti@kernel.org>2026-02-05 13:28:17 +0300
commit78821a753fc911a64b5bccc44cb13fd7203aea13 (patch)
treef139a75645a7cfe019ba9803a6d51a05519ec71f
parenteddfdab4de202b8781fc0719c2e4790db84f9453 (diff)
downloadlinux-78821a753fc911a64b5bccc44cb13fd7203aea13.tar.xz
i2c: designware-platdrv: simplify reset control
The current implementation uses separate calls to acquire and deassert reset control, requiring manual error handling for the deassertion operation. This can be simplified using the dedicated devm function that combines both operations. Replace devm_reset_control_get_optional_exclusive() with devm_reset_control_get_optional_exclusive_deasserted(), which handles both reset acquisition and deassertion in a single call as well as reset_control_put() which is called automatically on driver detach. This eliminates the need for explicit deassertion and its associated error checking while maintaining the same functional behavior through automatic resource management. Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://lore.kernel.org/r/20260130111039.874548-2-a.shimko.dev@gmail.com
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 481a4eaaa28d..f591da26916f 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -160,40 +160,32 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
if (ret)
return ret;
- dev->rst = devm_reset_control_get_optional_exclusive(device, NULL);
+ dev->rst = devm_reset_control_get_optional_exclusive_deasserted(device, NULL);
if (IS_ERR(dev->rst))
return dev_err_probe(device, PTR_ERR(dev->rst), "failed to acquire reset\n");
- reset_control_deassert(dev->rst);
-
ret = i2c_dw_fw_parse_and_configure(dev);
if (ret)
- goto exit_reset;
+ return ret;
ret = i2c_dw_probe_lock_support(dev);
- if (ret) {
- dev_err_probe(device, ret, "failed to probe lock support\n");
- goto exit_reset;
- }
+ if (ret)
+ return dev_err_probe(device, ret, "failed to probe lock support\n");
i2c_dw_configure(dev);
/* Optional interface clock */
dev->pclk = devm_clk_get_optional(device, "pclk");
- if (IS_ERR(dev->pclk)) {
- ret = dev_err_probe(device, PTR_ERR(dev->pclk), "failed to acquire pclk\n");
- goto exit_reset;
- }
+ if (IS_ERR(dev->pclk))
+ return dev_err_probe(device, PTR_ERR(dev->pclk), "failed to acquire pclk\n");
dev->clk = devm_clk_get_optional(device, NULL);
- if (IS_ERR(dev->clk)) {
- ret = dev_err_probe(device, PTR_ERR(dev->clk), "failed to acquire clock\n");
- goto exit_reset;
- }
+ if (IS_ERR(dev->clk))
+ return dev_err_probe(device, PTR_ERR(dev->clk), "failed to acquire clock\n");
ret = i2c_dw_prepare_clk(dev, true);
if (ret)
- goto exit_reset;
+ return ret;
if (dev->clk) {
struct i2c_timings *t = &dev->timings;
@@ -241,8 +233,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
exit_probe:
dw_i2c_plat_pm_cleanup(dev);
i2c_dw_prepare_clk(dev, false);
-exit_reset:
- reset_control_assert(dev->rst);
return ret;
}
@@ -262,8 +252,6 @@ static void dw_i2c_plat_remove(struct platform_device *pdev)
dw_i2c_plat_pm_cleanup(dev);
i2c_dw_prepare_clk(dev, false);
-
- reset_control_assert(dev->rst);
}
static const struct of_device_id dw_i2c_of_match[] = {