drivers: ethernet: stm32: enable IRQ at the end of iface init
This avoid IRQ to be handle before iface init is finished
(especially before iface address is set)
Fixes #32771
Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
diff --git a/drivers/ethernet/eth_stm32_hal.c b/drivers/ethernet/eth_stm32_hal.c
index a36ca61..9b34303 100644
--- a/drivers/ethernet/eth_stm32_hal.c
+++ b/drivers/ethernet/eth_stm32_hal.c
@@ -777,6 +777,7 @@
{
const struct device *dev;
struct eth_stm32_hal_dev_data *dev_data;
+ bool is_first_init = false;
__ASSERT_NO_MSG(iface != NULL);
@@ -792,10 +793,7 @@
*/
if (dev_data->iface == NULL) {
dev_data->iface = iface;
-
- /* Now that the iface is setup, we are safe to enable IRQs. */
- __ASSERT_NO_MSG(DEV_CFG(dev)->config_func != NULL);
- DEV_CFG(dev)->config_func();
+ is_first_init = true;
}
/* Register Ethernet MAC Address with the upper layer */
@@ -806,6 +804,12 @@
ethernet_init(iface);
net_if_flag_set(iface, NET_IF_NO_AUTO_START);
+
+ if (is_first_init) {
+ /* Now that the iface is setup, we are safe to enable IRQs. */
+ __ASSERT_NO_MSG(DEV_CFG(dev)->config_func != NULL);
+ DEV_CFG(dev)->config_func();
+ }
}
static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(const struct device *dev)