* [PATCH] i2c: designware-platdrv: handle reset control deassert error
@ 2025-10-09 7:44 Artem Shimko
2025-10-09 8:15 ` Philipp Zabel
0 siblings, 1 reply; 6+ messages in thread
From: Artem Shimko @ 2025-10-09 7:44 UTC (permalink / raw)
To: Jarkko Nikula, Andy Shevchenko, Mika Westerberg, Jan Dabros,
Andi Shyti, Philipp Zabel
Cc: a.shimko.dev, linux-i2c, linux-kernel
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.
Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
---
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(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index a35e4c64a1d4..4c57c79d4ce5 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -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)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] i2c: designware-platdrv: handle reset control deassert error
2025-10-09 7:44 [PATCH] i2c: designware-platdrv: handle reset control deassert error Artem Shimko
@ 2025-10-09 8:15 ` Philipp Zabel
2025-10-09 8:37 ` Artem Shimko
0 siblings, 1 reply; 6+ messages in thread
From: Philipp Zabel @ 2025-10-09 8:15 UTC (permalink / raw)
To: Artem Shimko, Jarkko Nikula, Andy Shevchenko, Mika Westerberg,
Jan Dabros, Andi Shyti
Cc: linux-i2c, linux-kernel
Hi Artem,
On Do, 2025-10-09 at 10:44 +0300, Artem Shimko wrote:
> 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.
>
> Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
> ---
> 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(-)
>
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index a35e4c64a1d4..4c57c79d4ce5 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] i2c: designware-platdrv: handle reset control deassert error
2025-10-09 8:15 ` Philipp Zabel
@ 2025-10-09 8:37 ` Artem Shimko
2025-10-09 9:30 ` Mika Westerberg
2025-10-09 9:39 ` Philipp Zabel
0 siblings, 2 replies; 6+ messages in thread
From: Artem Shimko @ 2025-10-09 8:37 UTC (permalink / raw)
To: p.zabel
Cc: a.shimko.dev, andi.shyti, andriy.shevchenko, jarkko.nikula, jsd,
linux-i2c, linux-kernel, mika.westerberg
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.
Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
---
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/20251009074443.2010699-1-a.shimko.dev@gmail.com/
v2:
* change pdev->dev to local device dev
drivers/i2c/busses/i2c-designware-platdrv.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index a35e4c64a1d4..c89af7cbdfac 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -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)
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] i2c: designware-platdrv: handle reset control deassert error
2025-10-09 8:37 ` Artem Shimko
@ 2025-10-09 9:30 ` Mika Westerberg
2025-10-09 9:39 ` Philipp Zabel
1 sibling, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2025-10-09 9:30 UTC (permalink / raw)
To: Artem Shimko
Cc: p.zabel, andi.shyti, andriy.shevchenko, jarkko.nikula, jsd,
linux-i2c, linux-kernel
Hi,
On Thu, Oct 09, 2025 at 11:37:03AM +0300, Artem Shimko wrote:
> 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.
>
> Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
Looks good to me,
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] i2c: designware-platdrv: handle reset control deassert error
2025-10-09 8:37 ` Artem Shimko
2025-10-09 9:30 ` Mika Westerberg
@ 2025-10-09 9:39 ` Philipp Zabel
2025-10-24 8:07 ` Artem Shimko
1 sibling, 1 reply; 6+ messages in thread
From: Philipp Zabel @ 2025-10-09 9:39 UTC (permalink / raw)
To: Artem Shimko
Cc: andi.shyti, andriy.shevchenko, jarkko.nikula, jsd, linux-i2c,
linux-kernel, mika.westerberg
On Do, 2025-10-09 at 11:37 +0300, Artem Shimko wrote:
> 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.
>
> Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
regards
Philipp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] i2c: designware-platdrv: handle reset control deassert error
2025-10-09 9:39 ` Philipp Zabel
@ 2025-10-24 8:07 ` Artem Shimko
0 siblings, 0 replies; 6+ messages in thread
From: Artem Shimko @ 2025-10-24 8:07 UTC (permalink / raw)
To: Philipp Zabel
Cc: andi.shyti, andriy.shevchenko, jarkko.nikula, jsd, linux-i2c,
linux-kernel, mika.westerberg
On Thu, Oct 9, 2025 at 12:39 PM Philipp Zabel <p.zabel@pengutronix.de> wrote:
>
> On Do, 2025-10-09 at 11:37 +0300, Artem Shimko wrote:
> > 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.
> >
> > Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
>
> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Hi Philipp,
Should I do something to bring the changes to linux-next?
--
Best regards,
Artem
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-24 8:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-09 7:44 [PATCH] i2c: designware-platdrv: handle reset control deassert error Artem Shimko
2025-10-09 8:15 ` Philipp Zabel
2025-10-09 8:37 ` Artem Shimko
2025-10-09 9:30 ` Mika Westerberg
2025-10-09 9:39 ` Philipp Zabel
2025-10-24 8:07 ` Artem Shimko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox