struct net_device *
 ieee802154_if_add(struct ieee802154_local *local, const char *name,
                  struct wpan_dev **new_wpan_dev, int type);
+void ieee802154_remove_interfaces(struct ieee802154_local *local);
 
 #endif /* __IEEE802154_I_H */
 
        synchronize_rcu();
        unregister_netdevice(sdata->dev);
 }
+
+void ieee802154_remove_interfaces(struct ieee802154_local *local)
+{
+       struct ieee802154_sub_if_data *sdata, *next;
+
+       list_for_each_entry_safe(sdata, next, &local->interfaces, list) {
+               mutex_lock(&sdata->local->iflist_mtx);
+               list_del(&sdata->list);
+               mutex_unlock(&sdata->local->iflist_mtx);
+
+               unregister_netdevice(sdata->dev);
+       }
+}
 
 void ieee802154_unregister_hw(struct ieee802154_hw *hw)
 {
        struct ieee802154_local *local = hw_to_local(hw);
-       struct ieee802154_sub_if_data *sdata, *next;
 
        tasklet_kill(&local->tasklet);
        flush_workqueue(local->workqueue);
 
        rtnl_lock();
 
-       list_for_each_entry_safe(sdata, next, &local->interfaces, list) {
-               mutex_lock(&sdata->local->iflist_mtx);
-               list_del(&sdata->list);
-               mutex_unlock(&sdata->local->iflist_mtx);
-
-               unregister_netdevice(sdata->dev);
-       }
+       ieee802154_remove_interfaces(local);
 
        rtnl_unlock();