[PATCH] spi: dw-mmio: add error handling for reset_control_deassert()

Artem Shimko posted 1 patch 4 months ago
drivers/spi/spi-dw-mmio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] spi: dw-mmio: add error handling for reset_control_deassert()
Posted by Artem Shimko 4 months ago
Currently reset_control_deassert() is called without checking its
return value. This can lead to silent failures when reset deassertion
fails.

Add proper error handling to:
1. Check the return value of reset_control_deassert()
2. Return the error to the caller
3. Provide meaningful error message using dev_err_probe()

This ensures that reset-related failures are properly reported during
probe and helps with debugging reset issues.

Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
---

This patch addresses an issue in the DesignWare SPI MMIO driver
where the return value of reset_control_deassert() was not being checked,
potentially leading to silent failures.

The problem occurs when reset deassertion fails - the driver would
continue probing without the device being properly reset, which could
result in unpredictable behavior or hardware malfunctions.

Patch adds proper error checking and propagation for the
reset_control_deassert() call, ensuring that probe fails gracefully
when reset operations cannot be completed successfully.

This change improves the robustness of the driver and provides better
debugging information when reset-related issues occur.

 drivers/spi/spi-dw-mmio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index f0f576fac77a..7a5197586919 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -358,7 +358,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 	if (IS_ERR(dwsmmio->rstc))
 		return PTR_ERR(dwsmmio->rstc);
 
-	reset_control_deassert(dwsmmio->rstc);
+	ret = reset_control_deassert(dwsmmio->rstc);
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "Failed to deassert resets\n");
 
 	dws->bus_num = pdev->id;
 
-- 
2.43.0
Re: [PATCH] spi: dw-mmio: add error handling for reset_control_deassert()
Posted by Mark Brown 4 months ago
On Tue, 07 Oct 2025 13:11:33 +0300, Artem Shimko wrote:
> Currently reset_control_deassert() is called without checking its
> return value. This can lead to silent failures when reset deassertion
> fails.
> 
> Add proper error handling to:
> 1. Check the return value of reset_control_deassert()
> 2. Return the error to the caller
> 3. Provide meaningful error message using dev_err_probe()
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: dw-mmio: add error handling for reset_control_deassert()
      commit: 18a5f1af596e6ba22cd40ada449063041f3ce6d4

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark