[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <206e36398db6075bfb0bb0b98295ee7328c5f64f.camel@pengutronix.de>
Date: Thu, 09 Oct 2025 10:15:03 +0200
From: Philipp Zabel <p.zabel@...gutronix.de>
To: Artem Shimko <a.shimko.dev@...il.com>, Jarkko Nikula
<jarkko.nikula@...ux.intel.com>, Andy Shevchenko
<andriy.shevchenko@...ux.intel.com>, Mika Westerberg
<mika.westerberg@...ux.intel.com>, Jan Dabros <jsd@...ihalf.com>, Andi
Shyti <andi.shyti@...nel.org>
Cc: linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] i2c: designware-platdrv: handle reset control deassert
error
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@...il.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
Powered by blists - more mailing lists