[PATCH 1/4] can: mcp251xfd: stop timestamp before sending chip to sleep

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



MCP2518FD exits Low-Power Mode (LPM) when CS is asserted. When chip
is send to sleep and the timestamp workqueue is not stopped chip is
waked by SPI transfer of mcp251xfd_timestamp_read.

So before sending chip to sleep stop timestamp otherwise the
mcp251xfd_timestamp_read callback would wake chip up.

Also there are error paths in mcp251xfd_chip_start where workqueue has
not been initialized but mcp251xfd_chip_stop is called. So check for
initialized func before canceling delayed_work.

Fixes: 55e5b97f003e ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
Signed-off-by: Gregor Herburger <gregor.herburger@xxxxxxxxxxxxxxx>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c      | 1 +
 drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index 1d9057dc44f2..eb699288c076 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -744,6 +744,7 @@ static void mcp251xfd_chip_stop(struct mcp251xfd_priv *priv,
 
 	mcp251xfd_chip_interrupts_disable(priv);
 	mcp251xfd_chip_rx_int_disable(priv);
+	mcp251xfd_timestamp_stop(priv);
 	mcp251xfd_chip_sleep(priv);
 }
 
diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c
index 712e09186987..537c31890838 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c
@@ -67,5 +67,8 @@ void mcp251xfd_timestamp_init(struct mcp251xfd_priv *priv)
 
 void mcp251xfd_timestamp_stop(struct mcp251xfd_priv *priv)
 {
-	cancel_delayed_work_sync(&priv->timestamp);
+	struct work_struct *work = &priv->timestamp.work;
+
+	if (work->func)
+		cancel_delayed_work_sync(&priv->timestamp);
 }

-- 
2.34.1





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux