Skip to contentSkip to conversation

i2c: designware-platdrv: handle reset control deassert error

PATCH In review Artem Shimko 3 participants 6 messages Oct 9, 2025 – Oct 24, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: designware-platdrv: handle reset control deassert error

Handle the error returned by reset_control_deassert() in the probe function to prevent continuing probe when reset deassertion fails.

Previously, reset_control_deassert() was called without checking its return value, which could lead to probe continuing even when the device reset wasn't properly deasserted.

The fix checks the return value and returns an error with dev_err_probe() if reset deassertion fails, providing better error handling and diagnostics.

---
Hello maintainers and reviewers,

This patch adds proper error handling for reset_control_deassert() in the DesignWare I2C platform driver probe function.

Currently, if reset deassertion fails, the driver continues probing which could lead to operating a device that is still held in reset. This patch ensures we properly check the return value and fail the probe with a meaningful error message if reset deassertion fails.

The change is safe because:
1. reset_control_deassert() handles NULL pointers (for optional resets) by returning 0 (success)
2. For non-NULL reset controls, we now properly validate the operation
3. dev_err_probe() provides appropriate error context for diagnostics

Thank you for your consideration.

Best regards,
Artem Shimko

 drivers/i2c/busses/i2c-designware-platdrv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-platdrv.c +3 -1
index a35e4c64a1d4..4c57c79d4ce5 100644
@@ -240,7 +240,9 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	if (IS_ERR(dev->rst))
 		return PTR_ERR(dev->rst);
 
-	reset_control_deassert(dev->rst);
+	ret = reset_control_deassert(dev->rst);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to deassert reset\n");
 
 	ret = i2c_dw_fw_parse_and_configure(dev);
 	if (ret)
Signature · 1 line
2.43.0
#1 lore raw

Hi Artem,

Quoted 42 lines · Artem Shimko

Handle the error returned by reset_control_deassert() in the probe function to prevent continuing probe when reset deassertion fails.

Previously, reset_control_deassert() was called without checking its return value, which could lead to probe continuing even when the device reset wasn't properly deasserted.

The fix checks the return value and returns an error with dev_err_probe() if reset deassertion fails, providing better error handling and diagnostics.

---
Hello maintainers and reviewers,

This patch adds proper error handling for reset_control_deassert() in the DesignWare I2C platform driver probe function.

Currently, if reset deassertion fails, the driver continues probing which could lead to operating a device that is still held in reset. This patch ensures we properly check the return value and fail the probe with a meaningful error message if reset deassertion fails.

The change is safe because:
1. reset_control_deassert() handles NULL pointers (for optional resets) by returning 0 (success)
2. For non-NULL reset controls, we now properly validate the operation
3. dev_err_probe() provides appropriate error context for diagnostics

Thank you for your consideration.

Best regards,
Artem Shimko

 drivers/i2c/busses/i2c-designware-platdrv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-platdrv.c +0 -0
index a35e4c64a1d4..4c57c79d4ce5 100644

drivers/i2c/busses/i2c-designware-platdrv.c static int dw_i2c_plat_probe(struct platform_device *pdev) · line 245

Quoted 7 lines
drivers/i2c/busses/i2c-designware-platdrv.c +3 -1
@@ -240,7 +240,9 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	if (IS_ERR(dev->rst))
 		return PTR_ERR(dev->rst);
 
-	reset_control_deassert(dev->rst);
+	ret = reset_control_deassert(dev->rst);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to deassert reset\n");

There is a local variable "struct device *device = &pdev->dev", better use that for consistency.

regards
Philipp

#2 lore raw

PATCH 1/1 i2c: designware-platdrv: handle reset control deassert error

Handle the error returned by reset_control_deassert() in the probe function to prevent continuing probe when reset deassertion fails.

Previously, reset_control_deassert() was called without checking its return value, which could lead to probe continuing even when the device reset wasn't properly deasserted.

The fix checks the return value and returns an error with dev_err_probe() if reset deassertion fails, providing better error handling and diagnostics.

---
Hi Philipp,

Oh, sorry, sure.

Could you please have a look at the v2.

Thank you

Best regards,
Artem Shimko

ChangeLog:
v1:
* https://lore.kernel.org/all/[email protected]/
v2:
* change pdev->dev to local device dev

 drivers/i2c/busses/i2c-designware-platdrv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-platdrv.c +3 -1
index a35e4c64a1d4..c89af7cbdfac 100644
@@ -240,7 +240,9 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
 	if (IS_ERR(dev->rst))
 		return PTR_ERR(dev->rst);
 
-	reset_control_deassert(dev->rst);
+	ret = reset_control_deassert(dev->rst);
+	if (ret)
+		return dev_err_probe(device, ret, "Failed to deassert reset\n");
 
 	ret = i2c_dw_fw_parse_and_configure(dev);
 	if (ret)
Signature · 1 line
2.43.0
maintainer Acked-by on v1 1/1
#3 lore raw

Hi,

Quoted 7 lines · Artem Shimko

Handle the error returned by reset_control_deassert() in the probe function to prevent continuing probe when reset deassertion fails.

Previously, reset_control_deassert() was called without checking its return value, which could lead to probe continuing even when the device reset wasn't properly deasserted.

Quoted 5 lines

The fix checks the return value and returns an error with dev_err_probe() if reset deassertion fails, providing better error handling and diagnostics.

Looks good to me,

Reviewed-by on v1 1/1
#4 lore raw
In reply to Artem Shimko
Quoted 7 lines · Artem Shimko

Handle the error returned by reset_control_deassert() in the probe function to prevent continuing probe when reset deassertion fails.

Previously, reset_control_deassert() was called without checking its return value, which could lead to probe continuing even when the device reset wasn't properly deasserted.

Quoted 5 lines

The fix checks the return value and returns an error with dev_err_probe() if reset deassertion fails, providing better error handling and diagnostics.

regards
Philipp

#5 lore raw
Quoted 9 lines · Philipp Zabel
Quoted 7 lines · Artem Shimko

Handle the error returned by reset_control_deassert() in the probe function to prevent continuing probe when reset deassertion fails.

Previously, reset_control_deassert() was called without checking its return value, which could lead to probe continuing even when the device reset wasn't properly deasserted.

Quoted 7 lines
Quoted 5 lines

The fix checks the return value and returns an error with dev_err_probe() if reset deassertion fails, providing better error handling and diagnostics.

Hi Philipp,

Should I do something to bring the changes to linux-next?

--
Best regards,
Artem