mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
can: mcp251x: fix resume when device is down
commit25b401c181upstream. 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:bf66f3736a("can: mcp251x: Move to threaded interrupts instead of workqueues.") Signed-off-by: Stefan Agner <stefan@agner.ch> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
23596d7deb
commit
8a5d1e374b
@@ -1221,17 +1221,16 @@ static int __maybe_unused mcp251x_can_resume(struct device *dev)
|
||||
struct spi_device *spi = to_spi_device(dev);
|
||||
struct mcp251x_priv *priv = spi_get_drvdata(spi);
|
||||
|
||||
if (priv->after_suspend & AFTER_SUSPEND_POWER) {
|
||||
if (priv->after_suspend & AFTER_SUSPEND_POWER)
|
||||
mcp251x_power_enable(priv->power, 1);
|
||||
queue_work(priv->wq, &priv->restart_work);
|
||||
} else {
|
||||
|
||||
if (priv->after_suspend & AFTER_SUSPEND_UP) {
|
||||
mcp251x_power_enable(priv->transceiver, 1);
|
||||
queue_work(priv->wq, &priv->restart_work);
|
||||
} else {
|
||||
priv->after_suspend = 0;
|
||||
}
|
||||
}
|
||||
|
||||
priv->force_quit = 0;
|
||||
enable_irq(spi->irq);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user