From 531456d20c67e21a7e03894ab602b815b24b61f7 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 17 Aug 2015 11:49:20 -0600 Subject: [PATCH] Fix deadlock when closing the MCAN device driver --- arch/arm/src/samv7/sam_mcan.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/samv7/sam_mcan.c b/arch/arm/src/samv7/sam_mcan.c index c9e4dcda60..788f297e62 100755 --- a/arch/arm/src/samv7/sam_mcan.c +++ b/arch/arm/src/samv7/sam_mcan.c @@ -2215,19 +2215,24 @@ static void mcan_shutdown(FAR struct can_dev_s *dev) mcan_dev_lock(priv); - /* Disable the MCAN interrupts */ + /* Disable MCAN interrupts at the NVIC */ up_disable_irq(config->irq0); up_disable_irq(config->irq1); + /* Disable all interrupts from the MCAN peripheral */ + + mcan_putreg(priv, SAM_MCAN_IE_OFFSET, 0); + mcan_putreg(priv, SAM_MCAN_TXBTIE_OFFSET, 0); + /* Detach the MCAN interrupt handler */ irq_detach(config->irq0); irq_detach(config->irq1); - /* And reset the hardware */ + /* Disable peripheral clocking to the MCAN controller */ - mcan_reset(dev); + sam_disableperiph1(priv->config->pid); mcan_dev_unlock(priv); }