Skip to content

Commit

Permalink
can: peak_canfd: rearrange the way resources are released
Browse files Browse the repository at this point in the history
This patch improves the sequence the resources are released by, first,

- disabling the IRQ in the controller, then by
- resetting the DMA logic, and finally, by
- adding a read cycle to ensure that the above commands have been received

before freeing the system interrupt.

Signed-off-by: Stephane Grosjean <s.grosjean@peak-system.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Stephane Grosjean authored and Marc Kleine-Budde committed Jul 27, 2018
1 parent d31f851 commit 5592cd0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/net/can/peak_canfd/peak_pciefd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,16 @@ static int pciefd_post_cmd(struct peak_canfd_priv *ucan)

/* controller now in reset mode: */

/* disable IRQ for this CAN */
pciefd_can_writereg(priv, CANFD_CTL_IEN_BIT,
PCIEFD_REG_CAN_RX_CTL_CLR);

/* stop and reset DMA addresses in Tx/Rx engines */
pciefd_can_clear_tx_dma(priv);
pciefd_can_clear_rx_dma(priv);

/* disable IRQ for this CAN */
pciefd_can_writereg(priv, CANFD_CTL_IEN_BIT,
PCIEFD_REG_CAN_RX_CTL_CLR);
/* wait for above commands to complete (read cycle) */
(void)pciefd_sys_readreg(priv->board, PCIEFD_REG_SYS_VER1);

free_irq(priv->ucan.ndev->irq, priv);

Expand Down

0 comments on commit 5592cd0

Please sign in to comment.