can: mcp251x: fix resume when device is down
authorStefan Agner <stefan@agner.ch>
Mon, 18 May 2015 16:33:27 +0000 (18:33 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 16 Jul 2015 07:04:21 +0000 (09:04 +0200)
commit25b401c1816ae64bcc5dcb1d39ab41812522a0ce
treee2c2df8846c9b5bb0c6374b4194222f1fa68149a
parent15afb10df4a3f1bd781373ffd968e70cc4b21a42
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>
drivers/net/can/spi/mcp251x.c