@@ -485,24 +485,11 @@ static err_t eth_netif_device_init(struct netif *netif)
485485 ethif = (struct eth_device * )netif -> state ;
486486 if (ethif != RT_NULL )
487487 {
488- rt_device_t device ;
489-
490488#ifdef RT_USING_NETDEV
491489 /* network interface device register */
492490 netdev_add (netif );
493491#endif /* RT_USING_NETDEV */
494492
495- /* get device object */
496- device = (rt_device_t ) ethif ;
497- if (rt_device_init (device ) != RT_EOK )
498- {
499- return ERR_IF ;
500- }
501- if (rt_device_open (device , RT_DEVICE_FLAG_RDWR ) != RT_EOK )
502- {
503- return ERR_IF ;
504- }
505-
506493 /* copy device flags to netif flags */
507494 netif -> flags = (ethif -> flags & 0xff );
508495 netif -> mtu = ETHERNET_MTU ;
@@ -545,6 +532,19 @@ static err_t eth_netif_device_init(struct netif *netif)
545532 dhcp_start (netif );
546533#endif
547534
535+ rt_device_t device ;
536+ /* get device object */
537+ device = (rt_device_t ) ethif ;
538+ if (rt_device_init (device ) != RT_EOK )
539+ {
540+ return ERR_IF ;
541+ }
542+ if (rt_device_open (device , RT_DEVICE_FLAG_RDWR ) != RT_EOK )
543+ {
544+ return ERR_IF ;
545+ }
546+ netif -> flags |= (ethif -> flags & 0xff );
547+
548548 if (ethif -> flags & ETHIF_LINK_PHYUP )
549549 {
550550 /* set link_up for this netif */
@@ -673,24 +673,11 @@ static err_t af_unix_eth_netif_device_init(struct netif *netif)
673673 ethif = (struct eth_device * )netif -> state ;
674674 if (ethif != RT_NULL )
675675 {
676- rt_device_t device ;
677-
678676#ifdef RT_USING_NETDEV
679677 /* network interface device register */
680678 netdev_add (netif );
681679#endif /* RT_USING_NETDEV */
682680
683- /* get device object */
684- device = (rt_device_t ) ethif ;
685- if (rt_device_init (device ) != RT_EOK )
686- {
687- return ERR_IF ;
688- }
689- if (rt_device_open (device , RT_DEVICE_FLAG_RDWR ) != RT_EOK )
690- {
691- return ERR_IF ;
692- }
693-
694681 /* copy device flags to netif flags */
695682 netif -> flags = (ethif -> flags & 0xff );
696683 netif -> mtu = ETHERNET_MTU ;
@@ -728,6 +715,20 @@ static err_t af_unix_eth_netif_device_init(struct netif *netif)
728715 /* set interface up */
729716 netif_set_up (netif );
730717
718+ rt_device_t device ;
719+ /* get device object */
720+ device = (rt_device_t ) ethif ;
721+ if (rt_device_init (device ) != RT_EOK )
722+ {
723+ return ERR_IF ;
724+ }
725+ if (rt_device_open (device , RT_DEVICE_FLAG_RDWR ) != RT_EOK )
726+ {
727+ return ERR_IF ;
728+ }
729+
730+ netif -> flags |= (ethif -> flags & 0xff );
731+
731732 if (ethif -> flags & ETHIF_LINK_PHYUP )
732733 {
733734 /* set link_up for this netif */
0 commit comments