[PATCH v2 1/3] i2c: designware-platdrv: simplify reset control with devm variant
From: Artem Shimko
Date: Tue Nov 11 2025 - 06:57:01 EST
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. This eliminates
the need for explicit deassertion and its associated error checking while
maintaining the same functional behavior through automatic resource
management.
Suggested-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Signed-off-by: Artem Shimko <a.shimko.dev@xxxxxxxxx>
---
Hi Philip,
That works, thank you.
I also added two more separate commits to improve the driver.
--
Regards,
Artem
ChangeLog:
v2: Simplify reset control using devm_reset_control_get_optional_exclusive_deasserted()
* Replace separate reset acquisition and deassertion with combined function
* Remove explicit reset_control_deassert() call and error handling
* Maintain same functionality with cleaner code
* Add devm_add_action_or_reset() to fully automate reset management
* Remove all manual reset_control_assert() calls from probe and remove
* Streamline error handling by removing goto exit_probe and using direct cleanup
drivers/i2c/busses/i2c-designware-platdrv.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 34d881572351..c77029e520dc 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -236,11 +236,9 @@ 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);
+ return PTR_ERR(dev->rst);
ret = i2c_dw_fw_parse_and_configure(dev);
if (ret)
--
2.43.0