linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* pull-request: can 2015-07-16
@ 2015-07-16  8:33 Marc Kleine-Budde
  2015-07-16  8:33 ` [PATCH 1/2] can: mcp251x: fix resume when device is down Marc Kleine-Budde
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2015-07-16  8:33 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel

Hello David,

this is a pull request of 2 patches by Stefan Agner. He fixes the resume
operation in the mcp251x driver.

regards,
Marc

---

The following changes since commit 15afb10df4a3f1bd781373ffd968e70cc4b21a42:

  Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth (2015-07-15 21:59:23 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-4.2-20150716

for you to fetch changes up to 69da3f2ac528642acbd06ed14564ac1b9a918394:

  can: mcp251x: get regulators optionally (2015-07-16 09:04:22 +0200)

----------------------------------------------------------------
linux-can-fixes-for-4.2-20150716

----------------------------------------------------------------
Stefan Agner (2):
      can: mcp251x: fix resume when device is down
      can: mcp251x: get regulators optionally

 drivers/net/can/spi/mcp251x.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH 1/2] can: mcp251x: fix resume when device is down
@ 2015-05-18 16:33 Stefan Agner
  2015-05-18 16:33 ` [PATCH 2/2] can: mcp251x: get regulators optionally Stefan Agner
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Agner @ 2015-05-18 16:33 UTC (permalink / raw)
  To: wg, mkl; +Cc: chripell, linux-can, netdev, linux-kernel, stefan

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>
---
 drivers/net/can/spi/mcp251x.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
index bf63fee..34c625e 100644
--- a/drivers/net/can/spi/mcp251x.c
+++ b/drivers/net/can/spi/mcp251x.c
@@ -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);
+
+	if (priv->after_suspend & AFTER_SUSPEND_UP) {
+		mcp251x_power_enable(priv->transceiver, 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->after_suspend = 0;
 	}
+
 	priv->force_quit = 0;
 	enable_irq(spi->irq);
 	return 0;
-- 
2.4.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-07-21  3:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16  8:33 pull-request: can 2015-07-16 Marc Kleine-Budde
2015-07-16  8:33 ` [PATCH 1/2] can: mcp251x: fix resume when device is down Marc Kleine-Budde
2015-07-16  8:33 ` [PATCH 2/2] can: mcp251x: get regulators optionally Marc Kleine-Budde
2015-07-21  3:28 ` pull-request: can 2015-07-16 David Miller
  -- strict thread matches above, loose matches on Subject: below --
2015-05-18 16:33 [PATCH 1/2] can: mcp251x: fix resume when device is down Stefan Agner
2015-05-18 16:33 ` [PATCH 2/2] can: mcp251x: get regulators optionally Stefan Agner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).