| 112 | ****************************************************************************/ |
| 113 | |
| 114 | int netdev_unregister(FAR struct net_driver_s *dev) |
| 115 | { |
| 116 | struct net_driver_s *prev; |
| 117 | struct net_driver_s *curr; |
| 118 | |
| 119 | if (dev) |
| 120 | { |
| 121 | netdev_list_lock(); |
| 122 | |
| 123 | /* Find the device in the list of known network devices */ |
| 124 | |
| 125 | for (prev = NULL, curr = g_netdevices; |
| 126 | curr && curr != dev; |
| 127 | prev = curr, curr = curr->flink); |
| 128 | |
| 129 | /* Remove the device to the list of known network devices */ |
| 130 | |
| 131 | if (curr) |
| 132 | { |
| 133 | /* Where was the entry */ |
| 134 | |
| 135 | if (prev) |
| 136 | { |
| 137 | /* The entry was in the middle or at the end of the list */ |
| 138 | |
| 139 | prev->flink = curr->flink; |
| 140 | } |
| 141 | else |
| 142 | { |
| 143 | /* The entry was at the beginning of the list */ |
| 144 | |
| 145 | g_netdevices = curr->flink; |
| 146 | } |
| 147 | |
| 148 | curr->flink = NULL; |
| 149 | } |
| 150 | |
| 151 | #ifdef CONFIG_NETDEV_IFINDEX |
| 152 | free_ifindex(dev->d_ifindex); |
| 153 | #endif |
| 154 | |
| 155 | #ifdef CONFIG_NET_MLD |
| 156 | if ((dev->d_flags & IFF_MULTICAST) != 0) |
| 157 | { |
| 158 | /* MLD is only supported on multicast capable devices */ |
| 159 | |
| 160 | mld_grpfree_all(dev); |
| 161 | } |
| 162 | #endif |
| 163 | |
| 164 | netdev_list_unlock(); |
| 165 | |
| 166 | nxrmutex_destroy(&dev->d_lock); |
| 167 | |
| 168 | #if CONFIG_NETDEV_STATISTICS_LOG_PERIOD > 0 |
| 169 | work_cancel_sync(NETDEV_STATISTICS_WORK, &dev->d_statistics.logwork); |
| 170 | #endif |
| 171 |
no test coverage detected