diff --git a/arch/arm/src/tiva/tm4c/tm4c_ethernet.c b/arch/arm/src/tiva/tm4c/tm4c_ethernet.c index a33daf84ed..afc5c540ba 100644 --- a/arch/arm/src/tiva/tm4c/tm4c_ethernet.c +++ b/arch/arm/src/tiva/tm4c/tm4c_ethernet.c @@ -46,6 +46,7 @@ #include #include #include +#include #ifdef CONFIG_TIVA_PHY_INTERRUPTS # include @@ -628,6 +629,7 @@ struct tiva_ethmac_s struct wdog_s txtimeout; /* TX timeout timer */ struct work_s irqwork; /* For deferring interrupt work to the work queue */ struct work_s pollwork; /* For deferring poll work to the work queue */ + spinlock_t lock; /* Spinlock */ #ifdef CONFIG_TIVA_PHY_INTERRUPTS xcpt_t handler; /* Attached PHY interrupt handler */ @@ -2250,7 +2252,7 @@ static int tiva_ifdown(struct net_driver_s *dev) /* Disable the Ethernet interrupt */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&priv->lock); up_disable_irq(TIVA_IRQ_ETHCON); /* Cancel the TX timeout timers */ @@ -2267,7 +2269,7 @@ static int tiva_ifdown(struct net_driver_s *dev) /* Mark the device "down" */ priv->ifup = false; - leave_critical_section(flags); + spin_unlock_irqrestore(&priv->lock, flags); return OK; } @@ -3180,6 +3182,8 @@ static int tiva_phyinit(struct tiva_ethmac_s *priv) #endif #endif + spin_lock_init(&priv->lock); + ninfo("Duplex: %s Speed: %d MBps\n", priv->fduplex ? "FULL" : "HALF", priv->mbps100 ? 100 : 10); @@ -4035,7 +4039,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&priv->lock); /* Save the new interrupt handler information */ @@ -4053,7 +4057,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, *enable = handler ? tiva_phy_intenable : NULL; } - leave_critical_section(flags); + spin_unlock_irqrestore(&priv->lock, flags); return OK; } #endif /* CONFIG_TIVA_PHY_INTERRUPTS */ diff --git a/arch/renesas/src/rx65n/rx65n_eth.c b/arch/renesas/src/rx65n/rx65n_eth.c index a3a5acd7ae..4fd8c330ea 100644 --- a/arch/renesas/src/rx65n/rx65n_eth.c +++ b/arch/renesas/src/rx65n/rx65n_eth.c @@ -47,6 +47,7 @@ #include #include #include +#include #if defined(CONFIG_ARCH_PHY_INTERRUPT) # include @@ -410,6 +411,7 @@ struct rx65n_ethmac_s uint32_t prevlinkstatus; /* Previous link status to ignore multiple link change interrupt (specific to GR-Rose) */ uint8_t mc_filter_flag; /* Multicast filter */ + spinlock_t lock; /* SpinLock */ }; /**************************************************************************** @@ -2097,7 +2099,7 @@ static int rx65n_ifdown(struct net_driver_s *dev) irqstate_t flags; int ret = OK; ninfo("Taking the network down\n"); - flags = enter_critical_section(); + flags = spin_lock_irqsave(&priv->lock); /* Disable the Ethernet interrupt */ @@ -2125,7 +2127,7 @@ static int rx65n_ifdown(struct net_driver_s *dev) priv->prevlinkstatus = ETHER_LINKDOWN; - leave_critical_section(flags); + spin_unlock_irqrestore(&priv->lock, flags); return ret; } @@ -2648,7 +2650,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, return -ENODEV; } - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_rx65nethmac[0].lock); rx65n_phyintenable(false); /* Configure the interrupt */ @@ -2677,7 +2679,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_rx65nethmac[0].lock, flags); return OK; } #endif @@ -3891,6 +3893,8 @@ int rx65n_ethinitialize(int intf) rx65n_cmtw0_create(RX65N_CMTW0_COUNT_VALUE_FOR_TXPOLL , RX65N_CMTW0_COUNT_VALUE_FOR_TXTIMEOUT); + spin_lock_init(&priv->lock); + /* Attach the IRQ to the driver */ if (irq_attach(RX65N_ETH_IRQ, rx65n_interrupt, NULL)) diff --git a/boards/arm/at32/at32f437-mini/src/at32_ethernet.c b/boards/arm/at32/at32f437-mini/src/at32_ethernet.c index ff436f9bb3..2821c61a4c 100644 --- a/boards/arm/at32/at32f437-mini/src/at32_ethernet.c +++ b/boards/arm/at32/at32f437-mini/src/at32_ethernet.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "at32_gpio.h" #include "at32_eth.h" @@ -80,6 +81,8 @@ * Private Data ****************************************************************************/ +static spinlock_t g_ethmac_lock = SP_UNLOCKED; + #ifdef HAVE_NETMONITOR static xcpt_t g_ethmac_handler; static void *g_ethmac_arg; @@ -214,7 +217,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, DEBUGASSERT(intf); - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_ethmac_lock); if (strcmp(intf, AT32_ETHMAC_DEVNAME) == 0) { @@ -234,7 +237,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, *enable = enabler; } - leave_critical_section(flags); + spin_unlock_irqrestore(&g_ethmac_lock, flags); return OK; } #endif diff --git a/boards/arm/imxrt/imxrt1020-evk/src/imxrt_ethernet.c b/boards/arm/imxrt/imxrt1020-evk/src/imxrt_ethernet.c index 8006802f0b..9bdd3f07f6 100644 --- a/boards/arm/imxrt/imxrt1020-evk/src/imxrt_ethernet.c +++ b/boards/arm/imxrt/imxrt1020-evk/src/imxrt_ethernet.c @@ -72,6 +72,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -235,7 +241,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -270,7 +276,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* GPIO_ENET_IRQ */ diff --git a/boards/arm/imxrt/imxrt1050-evk/src/imxrt_ethernet.c b/boards/arm/imxrt/imxrt1050-evk/src/imxrt_ethernet.c index 12a5c22e45..fea90e458b 100644 --- a/boards/arm/imxrt/imxrt1050-evk/src/imxrt_ethernet.c +++ b/boards/arm/imxrt/imxrt1050-evk/src/imxrt_ethernet.c @@ -75,6 +75,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -243,7 +249,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -278,7 +284,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_IMXRT_GPIO1_0_15_IRQ */ diff --git a/boards/arm/imxrt/imxrt1060-evk/src/imxrt_ethernet.c b/boards/arm/imxrt/imxrt1060-evk/src/imxrt_ethernet.c index f3446b0ad9..18c6cf7885 100644 --- a/boards/arm/imxrt/imxrt1060-evk/src/imxrt_ethernet.c +++ b/boards/arm/imxrt/imxrt1060-evk/src/imxrt_ethernet.c @@ -73,6 +73,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -235,7 +241,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -270,7 +276,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_IMXRT_GPIO1_0_15_IRQ */ diff --git a/boards/arm/imxrt/imxrt1064-evk/src/imxrt_ethernet.c b/boards/arm/imxrt/imxrt1064-evk/src/imxrt_ethernet.c index 4d4d0d1c44..0dcfc4da65 100644 --- a/boards/arm/imxrt/imxrt1064-evk/src/imxrt_ethernet.c +++ b/boards/arm/imxrt/imxrt1064-evk/src/imxrt_ethernet.c @@ -73,6 +73,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -235,7 +241,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -270,7 +276,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_IMXRT_GPIO1_0_15_IRQ */ diff --git a/boards/arm/imxrt/imxrt1170-evk/src/imxrt_ethernet.c b/boards/arm/imxrt/imxrt1170-evk/src/imxrt_ethernet.c index e1da7493cf..b21b3728b8 100644 --- a/boards/arm/imxrt/imxrt1170-evk/src/imxrt_ethernet.c +++ b/boards/arm/imxrt/imxrt1170-evk/src/imxrt_ethernet.c @@ -74,6 +74,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -254,7 +260,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -289,7 +295,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_IMXRT_GPIO1_0_15_IRQ */ diff --git a/boards/arm/imxrt/teensy-4.x/src/imxrt_ethernet.c b/boards/arm/imxrt/teensy-4.x/src/imxrt_ethernet.c index 6a90c15d8f..6053bcaec9 100644 --- a/boards/arm/imxrt/teensy-4.x/src/imxrt_ethernet.c +++ b/boards/arm/imxrt/teensy-4.x/src/imxrt_ethernet.c @@ -73,6 +73,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -235,7 +241,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = spin_lock_irqsave(NULL); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -270,7 +276,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - spin_unlock_irqrestore(NULL, flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_IMXRT_GPIO1_0_15_IRQ */ diff --git a/boards/arm/sam34/sam4e-ek/src/sam_ethernet.c b/boards/arm/sam34/sam4e-ek/src/sam_ethernet.c index 6823789897..f94d9390a4 100644 --- a/boards/arm/sam34/sam4e-ek/src/sam_ethernet.c +++ b/boards/arm/sam34/sam4e-ek/src/sam_ethernet.c @@ -41,6 +41,7 @@ #include #include +#include #include "sam_gpio.h" #include "sam_emac.h" @@ -71,6 +72,14 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_SAM34_GPIOD_IRQ +static spinlock_t g_phy_lock = SP_UNLOCKED; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -205,7 +214,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -237,7 +246,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_SAM34_GPIOD_IRQ */ diff --git a/boards/arm/sama5/jupiter-nano/src/sam_ethernet.c b/boards/arm/sama5/jupiter-nano/src/sam_ethernet.c index 94bb7f2f57..5cc7b430e9 100644 --- a/boards/arm/sama5/jupiter-nano/src/sam_ethernet.c +++ b/boards/arm/sama5/jupiter-nano/src/sam_ethernet.c @@ -41,6 +41,7 @@ #include #include +#include #include "sam_pio.h" #include "sam_ethernet.h" @@ -81,6 +82,14 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_SAMA5_PIOE_IRQ +static spinlock_t g_phy_lock = SP_UNLOCKED; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -290,7 +299,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -322,7 +331,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_SAMA5_PIOE_IRQ */ diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_ethernet.c b/boards/arm/sama5/sama5d2-xult/src/sam_ethernet.c index 06fcfe4fac..f6424c3ba1 100644 --- a/boards/arm/sama5/sama5d2-xult/src/sam_ethernet.c +++ b/boards/arm/sama5/sama5d2-xult/src/sam_ethernet.c @@ -41,6 +41,7 @@ #include #include +#include #include "sam_pio.h" #include "sam_ethernet.h" @@ -81,6 +82,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -290,7 +297,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -322,7 +329,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_SAMA5_PIOE_IRQ */ diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_ethernet.c b/boards/arm/sama5/sama5d3-xplained/src/sam_ethernet.c index fcd278a8d5..3fec7e655f 100644 --- a/boards/arm/sama5/sama5d3-xplained/src/sam_ethernet.c +++ b/boards/arm/sama5/sama5d3-xplained/src/sam_ethernet.c @@ -41,6 +41,7 @@ #include #include +#include #include "sam_pio.h" #include "sam_ethernet.h" @@ -81,6 +82,14 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_SAMA5_PIOE_IRQ +static spinlock_t g_phy_lock = SP_UNLOCKED; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -290,7 +299,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -322,7 +331,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_SAMA5_PIOE_IRQ */ diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_ethernet.c b/boards/arm/sama5/sama5d3x-ek/src/sam_ethernet.c index d512e54ba8..e3d32befad 100644 --- a/boards/arm/sama5/sama5d3x-ek/src/sam_ethernet.c +++ b/boards/arm/sama5/sama5d3x-ek/src/sam_ethernet.c @@ -41,6 +41,7 @@ #include #include +#include #include "sam_pio.h" #include "sam_ethernet.h" @@ -81,6 +82,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -290,7 +297,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -322,7 +329,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_SAMA5_PIOE_IRQ */ diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_ethernet.c b/boards/arm/sama5/sama5d4-ek/src/sam_ethernet.c index 99880b830f..64361d9b36 100644 --- a/boards/arm/sama5/sama5d4-ek/src/sam_ethernet.c +++ b/boards/arm/sama5/sama5d4-ek/src/sam_ethernet.c @@ -42,6 +42,7 @@ #include #include +#include #include "sam_pio.h" #include "sam_ethernet.h" @@ -82,6 +83,14 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_SAMA5_PIOE_IRQ +static spinlock_t g_phy_lock = SP_UNLOCKED; +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -258,7 +267,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -290,7 +299,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_SAMA5_PIOE_IRQ */ diff --git a/boards/arm/samv7/same70-xplained/src/sam_ethernet.c b/boards/arm/samv7/same70-xplained/src/sam_ethernet.c index 7464fcf4b4..d100c42689 100644 --- a/boards/arm/samv7/same70-xplained/src/sam_ethernet.c +++ b/boards/arm/samv7/same70-xplained/src/sam_ethernet.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "sam_gpio.h" #include "sam_twihs.h" @@ -77,6 +78,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -310,7 +317,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -342,7 +349,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_SAMV7_GPIOA_IRQ */ diff --git a/boards/arm/samv7/samv71-xult/src/sam_ethernet.c b/boards/arm/samv7/samv71-xult/src/sam_ethernet.c index bcf1502620..7bcdb6be69 100644 --- a/boards/arm/samv7/samv71-xult/src/sam_ethernet.c +++ b/boards/arm/samv7/samv71-xult/src/sam_ethernet.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "sam_gpio.h" #include "sam_twihs.h" @@ -77,6 +78,12 @@ # define phyinfo(x...) #endif +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static spinlock_t g_phy_lock = SP_UNLOCKED; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -315,7 +322,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, * following operations are atomic. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); /* Configure the interrupt */ @@ -347,7 +354,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, /* Return the old handler (so that it can be restored) */ - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif /* CONFIG_SAMV7_GPIOA_IRQ */ diff --git a/boards/arm/stm32/stm32f4discovery/src/stm32_ethernet.c b/boards/arm/stm32/stm32f4discovery/src/stm32_ethernet.c index 9f2bc5c780..45e722039f 100644 --- a/boards/arm/stm32/stm32f4discovery/src/stm32_ethernet.c +++ b/boards/arm/stm32/stm32f4discovery/src/stm32_ethernet.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "stm32_gpio.h" #include "stm32_eth.h" @@ -80,6 +81,8 @@ * Private Data ****************************************************************************/ +static spinlock_t g_phy_lock = SP_UNLOCKED; + #ifdef HAVE_NETMONITOR static xcpt_t g_ethmac_handler; static void *g_ethmac_arg; @@ -214,7 +217,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, DEBUGASSERT(intf); - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_phy_lock); if (strcmp(intf, STM32_ETHMAC_DEVNAME) == 0) { @@ -234,7 +237,7 @@ int arch_phy_irq(const char *intf, xcpt_t handler, void *arg, *enable = enabler; } - leave_critical_section(flags); + spin_unlock_irqrestore(&g_phy_lock, flags); return OK; } #endif