net/dev: link the net device as order of registration

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-05-25 14:49:32 +08:00 committed by Xiang Xiao
parent 7ac6c0a8de
commit 70f6eb232a
1 changed files with 10 additions and 2 deletions

View File

@ -240,6 +240,7 @@ static int get_ifindex(void)
int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
{
FAR struct net_driver_s **last;
FAR char devfmt_str[IFNAMSIZ];
FAR const char *devfmt;
uint16_t pktsize = 0;
@ -428,8 +429,15 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
/* Add the device to the list of known network devices */
dev->flink = g_netdevices;
g_netdevices = dev;
last = &g_netdevices;
while (*last)
{
last = &((*last)->flink);
}
*last = dev;
dev->flink = NULL;
#ifdef CONFIG_NET_IGMP
/* Configure the device for IGMP support */