[PATCH v7 6/9] iio: ssp_sensors: Drop duplicated wdt timer and work cleanup

Sanjay Chitroda
2026-04-26T09:17:46Z

From: Sanjay Chitroda <sanjayembeddedse@gmail.com>

The SSP remove path cleans up the watchdog timer and associated work
both via ssp_disable_wdt_timer() and through explicit timer and work
teardown.

ssp_disable_wdt_timer() already performs a synchronous teardown of the
watchdog timer and watchdog work, guaranteeing that no timer callbacks
or watchdog work can be running or requeued once it returns.

In addition, the remove path disables interrupts and frees IRQ handler
using ssp_disable_mcu() and free_irq(). The refresh work is also
cancelled, preventing wdt_timer being re-armed before teardown. This
ensures that no new refresh or watchdog activity can be triggered from
the IRQ thread and refresh workqueue.

As a result, the additional timer and work cancellation is redundant
and does not provide additional ordering or race protection. Remove the
duplicated cleanup and rely on the centralized watchdog disable helper.

Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
---
Changes in v7:
- Following comment from Andy, Study the timer, work and IRQ
relationship and how it would work internally for ssp_sensors and
changes looks correct; updated the commit message to explain the
race condition and information on resource release during teardown.
- v6 change: https://lore.kernel.org/all/20260415050749.3858046-5-sanjayembedded@gmail.com/
---
drivers/iio/common/ssp_sensors/ssp_dev.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/common/ssp_sensors/ssp_dev.c
index fa47282b39c0..29b17118ba2a 100644
--- a/drivers/iio/common/ssp_sensors/ssp_dev.c
+++ b/drivers/iio/common/ssp_sensors/ssp_dev.c
@@ -596,15 +596,12 @@ static void ssp_remove(struct spi_device *spi)
"SSP_MSG2SSP_AP_STATUS_SHUTDOWN failed\n");

ssp_disable_mcu(data);
- ssp_disable_wdt_timer(data);
-
ssp_clean_pending_list(data);

free_irq(data->spi->irq, data);
cancel_delayed_work_sync(&data->work_refresh);

- timer_delete_sync(&data->wdt_timer);
- cancel_work_sync(&data->work_wdt);
+ ssp_disable_wdt_timer(data);

mutex_destroy(&data->comm_lock);
mutex_destroy(&data->pending_lock);
--
2.34.1