Skip to content

Commit d915eb8

Browse files
ABOSTMnashif
authored andcommitted
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>
1 parent d77290e commit d915eb8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/ethernet/eth_stm32_hal.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ static void eth_iface_init(struct net_if *iface)
777777
{
778778
const struct device *dev;
779779
struct eth_stm32_hal_dev_data *dev_data;
780+
bool is_first_init = false;
780781

781782
__ASSERT_NO_MSG(iface != NULL);
782783

@@ -792,10 +793,7 @@ static void eth_iface_init(struct net_if *iface)
792793
*/
793794
if (dev_data->iface == NULL) {
794795
dev_data->iface = iface;
795-
796-
/* Now that the iface is setup, we are safe to enable IRQs. */
797-
__ASSERT_NO_MSG(DEV_CFG(dev)->config_func != NULL);
798-
DEV_CFG(dev)->config_func();
796+
is_first_init = true;
799797
}
800798

801799
/* Register Ethernet MAC Address with the upper layer */
@@ -806,6 +804,12 @@ static void eth_iface_init(struct net_if *iface)
806804
ethernet_init(iface);
807805

808806
net_if_flag_set(iface, NET_IF_NO_AUTO_START);
807+
808+
if (is_first_init) {
809+
/* Now that the iface is setup, we are safe to enable IRQs. */
810+
__ASSERT_NO_MSG(DEV_CFG(dev)->config_func != NULL);
811+
DEV_CFG(dev)->config_func();
812+
}
809813
}
810814

811815
static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(const struct device *dev)

0 commit comments

Comments
 (0)