All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-can@vger.kernel.org
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	Thomas Kopp <thomas.kopp@microchip.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 04/13] can: mcp251xfd: mcp251xfd_open(): open_candev() first
Date: Wed,  5 Jan 2022 16:42:51 +0100	[thread overview]
Message-ID: <20220105154300.1258636-5-mkl@pengutronix.de> (raw)
In-Reply-To: <20220105154300.1258636-1-mkl@pengutronix.de>

This patch exchanges the order of open_candev() and
pm_runtime_get_sync(), so that open_candev() is called first.

A usual reason why open_candev() fails is missing CAN bit rate
configuration. It makes no sense to resume the device from PM sleep
first just to put it to sleep if the bit rate is not configured.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index bf2ebd46ff83..161e12cdf8e8 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -2503,19 +2503,19 @@ static int mcp251xfd_open(struct net_device *ndev)
 	const struct spi_device *spi = priv->spi;
 	int err;
 
+	err = open_candev(ndev);
+	if (err)
+		return err;
+
 	err = pm_runtime_get_sync(ndev->dev.parent);
 	if (err < 0) {
 		pm_runtime_put_noidle(ndev->dev.parent);
-		return err;
+		goto out_close_candev;
 	}
 
-	err = open_candev(ndev);
-	if (err)
-		goto out_pm_runtime_put;
-
 	err = mcp251xfd_ring_alloc(priv);
 	if (err)
-		goto out_close_candev;
+		goto out_pm_runtime_put;
 
 	err = mcp251xfd_transceiver_enable(priv);
 	if (err)
@@ -2551,11 +2551,11 @@ static int mcp251xfd_open(struct net_device *ndev)
 	mcp251xfd_transceiver_disable(priv);
  out_mcp251xfd_ring_free:
 	mcp251xfd_ring_free(priv);
- out_close_candev:
-	close_candev(ndev);
  out_pm_runtime_put:
 	mcp251xfd_chip_stop(priv, CAN_STATE_STOPPED);
 	pm_runtime_put(ndev->dev.parent);
+ out_close_candev:
+	close_candev(ndev);
 
 	return err;
 }
-- 
2.34.1



  parent reply	other threads:[~2022-01-05 15:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 15:42 [PATCH 00/13] can: mcp251xfd: cleanups and preparation to improve FIFO handling Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 01/13] can: mcp251xfd: remove double blank lines Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 02/13] can: mcp251xfd: mcp251xfd_tef_obj_read(): fix typo in error message Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 03/13] can: mcp251xfd: add missing newline to printed strings Marc Kleine-Budde
2022-01-05 15:42 ` Marc Kleine-Budde [this message]
2022-01-05 15:42 ` [PATCH 05/13] can: mcp251xfd: mcp251xfd_open(): make use of pm_runtime_resume_and_get() Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 06/13] can: mcp251xfd: mcp251xfd_handle_rxovif(): denote RX overflow message to debug + add rate limiting Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 07/13] can: mcp251xfd: mcp251xfd.h: sort function prototypes Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 08/13] can: mcp251xfd: move RX handling into separate file Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 09/13] can: mcp251xfd: move TX " Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 10/13] can: mcp251xfd: move TEF " Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 11/13] can: mcp251xfd: move chip FIFO init " Marc Kleine-Budde
2022-01-05 15:42 ` [PATCH 12/13] can: mcp251xfd: move ring init into separate function Marc Kleine-Budde
2022-01-05 15:43 ` [PATCH 13/13] can: mcp251xfd: introduce and make use of mcp251xfd_is_fd_mode() Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220105154300.1258636-5-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=thomas.kopp@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.