diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2020-11-19 11:09:14 +0100 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2020-11-20 12:06:46 +0100 |
commit | 49dea0443918da38f1cce94e74e17d2972c03016 (patch) | |
tree | c344e8e903cadbbd677cedf168adc7f3017880d9 | |
parent | 1c5e6dbe4c4f83bb44735656f52a501ebbe3281a (diff) | |
download | linux-49dea0443918da38f1cce94e74e17d2972c03016.tar.bz2 |
can: flexcan: move enabling/disabling of interrupts from flexcan_chip_{start,stop}() to callers
The function flexcan_chip_start() first configures the CAN controller and then
enables the interrupt, flexcan_chip_stop() does the opposite.
In an upcoming patch the order of operations in flexcan_open() and
flexcan_close() are changed. This requires
flexcan_chip_start()/flexcan_chip_stop_disable_on_error() and
flexcan_chip_interrupts_{enable,disable}() to be independent of each other.
This patch moves the enabling of the interrupts from flexcan_chip_start() to
its callers flexcan_open() and flexcan_resume(). Likewise the disabling of the
interrupts is moved from __flexcan_chip_stop() to its indirect callers
flexcan_close() and flexcan_suspend().
Link: https://lore.kernel.org/r/20201119100917.3013281-3-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r-- | drivers/net/can/flexcan.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 681a4d82681c..64c174aa868b 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -1598,8 +1598,6 @@ static int flexcan_chip_start(struct net_device *dev) priv->can.state = CAN_STATE_ERROR_ACTIVE; - flexcan_chip_interrupts_enable(dev); - /* print chip status */ netdev_dbg(dev, "%s: reading mcr=0x%08x ctrl=0x%08x\n", __func__, priv->read(®s->mcr), priv->read(®s->ctrl)); @@ -1628,8 +1626,6 @@ static int __flexcan_chip_stop(struct net_device *dev, bool disable_on_error) if (err && !disable_on_error) goto out_chip_unfreeze; - flexcan_chip_interrupts_disable(dev); - priv->can.state = CAN_STATE_STOPPED; return 0; @@ -1719,6 +1715,8 @@ static int flexcan_open(struct net_device *dev) if (err) goto out_offload_del; + flexcan_chip_interrupts_enable(dev); + can_led_event(dev, CAN_LED_EVENT_OPEN); can_rx_offload_enable(&priv->offload); @@ -1747,6 +1745,7 @@ static int flexcan_close(struct net_device *dev) netif_stop_queue(dev); can_rx_offload_disable(&priv->offload); flexcan_chip_stop_disable_on_error(dev); + flexcan_chip_interrupts_disable(dev); can_rx_offload_del(&priv->offload); free_irq(dev->irq, dev); @@ -1770,6 +1769,8 @@ static int flexcan_set_mode(struct net_device *dev, enum can_mode mode) if (err) return err; + flexcan_chip_interrupts_enable(dev); + netif_wake_queue(dev); break; @@ -2108,6 +2109,8 @@ static int __maybe_unused flexcan_suspend(struct device *device) if (err) return err; + flexcan_chip_interrupts_disable(dev); + err = pinctrl_pm_select_sleep_state(device); if (err) return err; @@ -2143,6 +2146,8 @@ static int __maybe_unused flexcan_resume(struct device *device) err = flexcan_chip_start(dev); if (err) return err; + + flexcan_chip_interrupts_enable(dev); } } |