[PATCH v2 2/2] can: tcan4x5x: Add suspend error handling

From: Markus Schneider-Pargmann

Date: Fri Oct 16 2026 - 06:06:31 EST


m_can_class_suspend() may return errors. On error we should first
restore the previous state and then pass the error code on. Otherwise we
keep the device in a misconfigured state for the running state.

Fixes: b6b640c04446 ("can: tcan4x5x: support resuming from rx interrupt signal")
Signed-off-by: Markus Schneider-Pargmann <msp@xxxxxxxxxxxx>
---
drivers/net/can/m_can/tcan4x5x-core.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index a5b8829aa519..b69312413d62 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -575,11 +575,20 @@ static int __maybe_unused tcan4x5x_suspend(struct device *dev)
{
struct m_can_classdev *cdev = dev_get_drvdata(dev);
struct spi_device *spi = to_spi_device(dev);
+ int ret;

if (cdev->pm_wake_source)
enable_irq_wake(spi->irq);

- return m_can_class_suspend(dev);
+ ret = m_can_class_suspend(dev);
+ if (ret)
+ goto err_disable_irq;
+ return 0;
+
+err_disable_irq:
+ if (cdev->pm_wake_source)
+ disable_irq_wake(spi->irq);
+ return ret;
}

static int __maybe_unused tcan4x5x_resume(struct device *dev)

--
2.55.0