mac802154: add ifname change notifier
[deliverable/linux.git] / net / mac802154 / iface.c
index 8d90fbafda140dd43a39abae104b73f3f43d65ec..ec92b48d1b0bfa40a7fafc148ff6f1d0bd9d3a1f 100644 (file)
@@ -538,13 +538,48 @@ void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata)
 
 void ieee802154_remove_interfaces(struct ieee802154_local *local)
 {
-       struct ieee802154_sub_if_data *sdata, *next;
+       struct ieee802154_sub_if_data *sdata, *tmp;
 
-       list_for_each_entry_safe(sdata, next, &local->interfaces, list) {
-               mutex_lock(&sdata->local->iflist_mtx);
+       mutex_lock(&local->iflist_mtx);
+       list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
                list_del(&sdata->list);
-               mutex_unlock(&sdata->local->iflist_mtx);
 
                unregister_netdevice(sdata->dev);
        }
+       mutex_unlock(&local->iflist_mtx);
+}
+
+static int netdev_notify(struct notifier_block *nb,
+                        unsigned long state, void *ptr)
+{
+       struct net_device *dev = netdev_notifier_info_to_dev(ptr);
+       struct ieee802154_sub_if_data *sdata;
+
+       if (state != NETDEV_CHANGENAME)
+               return NOTIFY_DONE;
+
+       if (!dev->ieee802154_ptr || !dev->ieee802154_ptr->wpan_phy)
+               return NOTIFY_DONE;
+
+       if (dev->ieee802154_ptr->wpan_phy->privid != mac802154_wpan_phy_privid)
+               return NOTIFY_DONE;
+
+       sdata = IEEE802154_DEV_TO_SUB_IF(dev);
+       memcpy(sdata->name, dev->name, IFNAMSIZ);
+
+       return NOTIFY_OK;
+}
+
+static struct notifier_block mac802154_netdev_notifier = {
+       .notifier_call = netdev_notify,
+};
+
+int ieee802154_iface_init(void)
+{
+       return register_netdevice_notifier(&mac802154_netdev_notifier);
+}
+
+void ieee802154_iface_exit(void)
+{
+       unregister_netdevice_notifier(&mac802154_netdev_notifier);
 }
This page took 0.026278 seconds and 5 git commands to generate.