diff options
author | Stefan Agner <stefan@agner.ch> | 2015-05-18 12:33:27 -0400 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2015-07-16 03:04:21 -0400 |
commit | 25b401c1816ae64bcc5dcb1d39ab41812522a0ce (patch) | |
tree | e2c2df8846c9b5bb0c6374b4194222f1fa68149a /drivers/net/can | |
parent | 15afb10df4a3f1bd781373ffd968e70cc4b21a42 (diff) |
can: mcp251x: fix resume when device is down
If a valid power regulator or a dummy regulator is used (which
happens to be the case when no regulator is specified), restart_work
is queued no matter whether the device was running or not at suspend
time. Since work queues get initialized in the ndo_open callback,
resuming leads to a NULL pointer exception.
Reverse exactly the steps executed at suspend time:
- Enable the power regulator in any case
- Enable the transceiver regulator if the device was running, even in
case we have a power regulator
- Queue restart_work only in case the device was running
Fixes: bf66f3736a94 ("can: mcp251x: Move to threaded interrupts instead of workqueues.")
Signed-off-by: Stefan Agner <stefan@agner.ch>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r-- | drivers/net/can/spi/mcp251x.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c index c1a95a34d62e..3b2f34e6ba9b 100644 --- a/drivers/net/can/spi/mcp251x.c +++ b/drivers/net/can/spi/mcp251x.c | |||
@@ -1222,17 +1222,16 @@ static int __maybe_unused mcp251x_can_resume(struct device *dev) | |||
1222 | struct spi_device *spi = to_spi_device(dev); | 1222 | struct spi_device *spi = to_spi_device(dev); |
1223 | struct mcp251x_priv *priv = spi_get_drvdata(spi); | 1223 | struct mcp251x_priv *priv = spi_get_drvdata(spi); |
1224 | 1224 | ||
1225 | if (priv->after_suspend & AFTER_SUSPEND_POWER) { | 1225 | if (priv->after_suspend & AFTER_SUSPEND_POWER) |
1226 | mcp251x_power_enable(priv->power, 1); | 1226 | mcp251x_power_enable(priv->power, 1); |
1227 | |||
1228 | if (priv->after_suspend & AFTER_SUSPEND_UP) { | ||
1229 | mcp251x_power_enable(priv->transceiver, 1); | ||
1227 | queue_work(priv->wq, &priv->restart_work); | 1230 | queue_work(priv->wq, &priv->restart_work); |
1228 | } else { | 1231 | } else { |
1229 | if (priv->after_suspend & AFTER_SUSPEND_UP) { | 1232 | priv->after_suspend = 0; |
1230 | mcp251x_power_enable(priv->transceiver, 1); | ||
1231 | queue_work(priv->wq, &priv->restart_work); | ||
1232 | } else { | ||
1233 | priv->after_suspend = 0; | ||
1234 | } | ||
1235 | } | 1233 | } |
1234 | |||
1236 | priv->force_quit = 0; | 1235 | priv->force_quit = 0; |
1237 | enable_irq(spi->irq); | 1236 | enable_irq(spi->irq); |
1238 | return 0; | 1237 | return 0; |