Commit e91aae8e authored by Marc Kleine-Budde's avatar Marc Kleine-Budde

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.deSigned-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 3bd9d8ce
...@@ -2503,19 +2503,19 @@ static int mcp251xfd_open(struct net_device *ndev) ...@@ -2503,19 +2503,19 @@ static int mcp251xfd_open(struct net_device *ndev)
const struct spi_device *spi = priv->spi; const struct spi_device *spi = priv->spi;
int err; int err;
err = open_candev(ndev);
if (err)
return err;
err = pm_runtime_get_sync(ndev->dev.parent); err = pm_runtime_get_sync(ndev->dev.parent);
if (err < 0) { if (err < 0) {
pm_runtime_put_noidle(ndev->dev.parent); 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); err = mcp251xfd_ring_alloc(priv);
if (err) if (err)
goto out_close_candev; goto out_pm_runtime_put;
err = mcp251xfd_transceiver_enable(priv); err = mcp251xfd_transceiver_enable(priv);
if (err) if (err)
...@@ -2551,11 +2551,11 @@ static int mcp251xfd_open(struct net_device *ndev) ...@@ -2551,11 +2551,11 @@ static int mcp251xfd_open(struct net_device *ndev)
mcp251xfd_transceiver_disable(priv); mcp251xfd_transceiver_disable(priv);
out_mcp251xfd_ring_free: out_mcp251xfd_ring_free:
mcp251xfd_ring_free(priv); mcp251xfd_ring_free(priv);
out_close_candev:
close_candev(ndev);
out_pm_runtime_put: out_pm_runtime_put:
mcp251xfd_chip_stop(priv, CAN_STATE_STOPPED); mcp251xfd_chip_stop(priv, CAN_STATE_STOPPED);
pm_runtime_put(ndev->dev.parent); pm_runtime_put(ndev->dev.parent);
out_close_candev:
close_candev(ndev);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment