Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: peak_canfd: rearrange the way resources are released

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>

authored by

Stephane Grosjean and committed by
Marc Kleine-Budde
5592cd03 d31f8513

+6 -3
+6 -3
drivers/net/can/peak_canfd/peak_pciefd_main.c
··· 488 488 489 489 /* controller now in reset mode: */ 490 490 491 + /* disable IRQ for this CAN */ 492 + pciefd_can_writereg(priv, CANFD_CTL_IEN_BIT, 493 + PCIEFD_REG_CAN_RX_CTL_CLR); 494 + 491 495 /* stop and reset DMA addresses in Tx/Rx engines */ 492 496 pciefd_can_clear_tx_dma(priv); 493 497 pciefd_can_clear_rx_dma(priv); 494 498 495 - /* disable IRQ for this CAN */ 496 - pciefd_can_writereg(priv, CANFD_CTL_IEN_BIT, 497 - PCIEFD_REG_CAN_RX_CTL_CLR); 499 + /* wait for above commands to complete (read cycle) */ 500 + (void)pciefd_sys_readreg(priv->board, PCIEFD_REG_SYS_VER1); 498 501 499 502 free_irq(priv->ucan.ndev->irq, priv); 500 503