[PATCH v6 2/2] i2c: designware-platdrv: fix cleanup on probe failure

Artem Shimko posted 2 patches 1 week, 1 day ago
[PATCH v6 2/2] i2c: designware-platdrv: fix cleanup on probe failure
Posted by Artem Shimko 1 week, 1 day ago
Simplify the error handling in dw_i2c_plat_probe() by consolidating
cleanup operations directly in the error path instead of using a
goto label.

This eliminates the goto statement, makes the error handling more
transparent, and reduces code indirection while maintaining identical
cleanup behavior on probe failure.

Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
---
 drivers/i2c/busses/i2c-designware-platdrv.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 88e70970c72c..74246fcd5138 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -292,14 +292,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	pm_runtime_enable(device);
 
 	ret = i2c_dw_probe(dev);
-	if (ret)
-		goto exit_probe;
-
-	return ret;
+	if (ret) {
+		dw_i2c_plat_pm_cleanup(dev);
+		i2c_dw_prepare_clk(dev, false);
+	}
 
-exit_probe:
-	dw_i2c_plat_pm_cleanup(dev);
-	i2c_dw_prepare_clk(dev, false);
 	return ret;
 }
 
-- 
2.43.0
Re: [PATCH v6 2/2] i2c: designware-platdrv: fix cleanup on probe failure
Posted by Mika Westerberg 5 days, 8 hours ago
On Fri, Jan 30, 2026 at 02:10:37PM +0300, Artem Shimko wrote:
> Simplify the error handling in dw_i2c_plat_probe() by consolidating
> cleanup operations directly in the error path instead of using a
> goto label.
> 
> This eliminates the goto statement, makes the error handling more
> transparent, and reduces code indirection while maintaining identical
> cleanup behavior on probe failure.
> 
> Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>