diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2021-10-22 18:45:05 +0200 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2022-01-08 20:17:41 +0100 |
commit | e91aae8efc4eebd33bdebe067ab248c242cc0135 (patch) | |
tree | 352e38b19ee5ced7c55070e7501590622c57157a /drivers/net/can | |
parent | 3bd9d8ce6f8c5c43ee2f1106021db0f98882cc75 (diff) | |
download | linux-e91aae8efc4eebd33bdebe067ab248c242cc0135.tar.gz linux-e91aae8efc4eebd33bdebe067ab248c242cc0135.tar.bz2 linux-e91aae8efc4eebd33bdebe067ab248c242cc0135.zip |
can: mcp251xfd: mcp251xfd_open(): open_candev() first
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.
Link: https://lore.kernel.org/all/20220105154300.1258636-5-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r-- | drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 16 |
1 files 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; } |