* [PATCH v5 2/2] i2c: designware-platdrv: refactor error handling and simplify cleanup
@ 2026-01-23 10:05 Artem Shimko
2026-01-23 12:48 ` Philipp Zabel
0 siblings, 1 reply; 3+ messages in thread
From: Artem Shimko @ 2026-01-23 10:05 UTC (permalink / raw)
To: Mika Westerberg, Andy Shevchenko, Jan Dabros, Andi Shyti,
Philipp Zabel
Cc: Artem Shimko, linux-i2c, linux-kernel
Streamline the probe error handling by replacing goto statements with
direct returns and using dev_err_probe() for consistent error reporting.
This results in more linear and readable control flow.
Remove the explicit reset_control_assert() call from the driver's
remove function, as the reset controller is acquired with
devm_reset_control_get_optional_exclusive_deasserted() which manages
the reset state automatically through devm resource management.
Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 37 +++++++--------------
1 file changed, 12 insertions(+), 25 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index ab960458b5a8..74246fcd5138 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -233,32 +233,26 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
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;
@@ -298,17 +292,12 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
pm_runtime_enable(device);
ret = i2c_dw_probe(dev);
- if (ret)
- goto exit_probe;
+ if (ret) {
+ dw_i2c_plat_pm_cleanup(dev);
+ i2c_dw_prepare_clk(dev, false);
+ }
return ret;
-
-exit_probe:
- dw_i2c_plat_pm_cleanup(dev);
- i2c_dw_prepare_clk(dev, false);
-exit_reset:
- reset_control_assert(dev->rst);
- return ret;
}
static void dw_i2c_plat_remove(struct platform_device *pdev)
@@ -327,8 +316,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[] = {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v5 2/2] i2c: designware-platdrv: refactor error handling and simplify cleanup
2026-01-23 10:05 [PATCH v5 2/2] i2c: designware-platdrv: refactor error handling and simplify cleanup Artem Shimko
@ 2026-01-23 12:48 ` Philipp Zabel
2026-01-23 16:09 ` Artem Shimko
0 siblings, 1 reply; 3+ messages in thread
From: Philipp Zabel @ 2026-01-23 12:48 UTC (permalink / raw)
To: Artem Shimko, Mika Westerberg, Andy Shevchenko, Jan Dabros,
Andi Shyti
Cc: linux-i2c, linux-kernel
On Fr, 2026-01-23 at 13:05 +0300, Artem Shimko wrote:
> Streamline the probe error handling by replacing goto statements with
> direct returns and using dev_err_probe() for consistent error reporting.
> This results in more linear and readable control flow.
>
> Remove the explicit reset_control_assert() call from the driver's
> remove function, as the reset controller is acquired with
> devm_reset_control_get_optional_exclusive_deasserted() which manages
> the reset state automatically through devm resource management.
This change belongs in patch 1, same with the assert in the probe
error path.
regards
Philipp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v5 2/2] i2c: designware-platdrv: refactor error handling and simplify cleanup
2026-01-23 12:48 ` Philipp Zabel
@ 2026-01-23 16:09 ` Artem Shimko
0 siblings, 0 replies; 3+ messages in thread
From: Artem Shimko @ 2026-01-23 16:09 UTC (permalink / raw)
To: Philipp Zabel
Cc: Mika Westerberg, Andy Shevchenko, Jan Dabros, Andi Shyti,
linux-i2c, linux-kernel
On Fri, Jan 23, 2026 at 3:48 PM Philipp Zabel <p.zabel@pengutronix.de> wrote:
>
> On Fr, 2026-01-23 at 13:05 +0300, Artem Shimko wrote:
> > Streamline the probe error handling by replacing goto statements with
> > direct returns and using dev_err_probe() for consistent error reporting.
> > This results in more linear and readable control flow.
> >
> > Remove the explicit reset_control_assert() call from the driver's
> > remove function, as the reset controller is acquired with
> > devm_reset_control_get_optional_exclusive_deasserted() which manages
> > the reset state automatically through devm resource management.
>
> This change belongs in patch 1, same with the assert in the probe
> error path.
Hi Philipp,
You're absolutely right. I misunderstood Andy's earlier feedback in [1].
He was specifically referring to separating the dw_i2c_plat_pm_cleanup
change into its own patch, not the reset_control_assert() changes.
I'll fix it.
Thank you.
[1] https://lore.kernel.org/all/20251111075400.2982270-1-a.shimko.dev@gmail.com/T/#u
Regards,
artem
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-23 16:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-23 10:05 [PATCH v5 2/2] i2c: designware-platdrv: refactor error handling and simplify cleanup Artem Shimko
2026-01-23 12:48 ` Philipp Zabel
2026-01-23 16:09 ` Artem Shimko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox