]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
mac802154: move interface add handling in iface
authorAlexander Aring <alex.aring@gmail.com>
Wed, 5 Nov 2014 19:51:15 +0000 (20:51 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 5 Nov 2014 20:53:03 +0000 (21:53 +0100)
This patch moves and renames the mac802154_add_iface and
mac802154_netdev_register functions into iface.c. The function
mac802154_add_iface is renamed to ieee802154_if_add which is a similar naming
convention like mac80211.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/mac802154/cfg.c
net/mac802154/ieee802154_i.h
net/mac802154/iface.c
net/mac802154/main.c

index 3f9afad1f61235707b55ff0236cf2370aeb1036f..0a08f66512b30d8120706e65060c13cde5c037c9 100644 (file)
@@ -22,7 +22,9 @@ static struct net_device *
 ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy,
                                const char *name, int type)
 {
-       return mac802154_add_iface(wpan_phy, name, type);
+       struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
+
+       return ieee802154_if_add(local, name, NULL, type);
 }
 
 static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy,
index 61a6a0fd39ad4caaf461f16e51d897d73df68b99..3ad85404fc9454d4ea3af41fee9ecab02136b56a 100644 (file)
@@ -176,5 +176,8 @@ void mac802154_unlock_table(struct net_device *dev);
 struct net_device *
 mac802154_add_iface(struct wpan_phy *phy, const char *name, int type);
 void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
+struct net_device *
+ieee802154_if_add(struct ieee802154_local *local, const char *name,
+                 struct wpan_dev **new_wpan_dev, int type);
 
 #endif /* __IEEE802154_I_H */
index 9d6012e430de7dba356a46c92f9f08d0e8c3379e..fced04b052755fcdfb5e7509d6b1f3c099d60662 100644 (file)
@@ -444,6 +444,72 @@ void mac802154_monitor_setup(struct net_device *dev)
        sdata->promisuous_mode = true;
 }
 
+static int
+mac802154_netdev_register(struct ieee802154_local *local,
+                         struct net_device *dev)
+{
+       struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
+       int err;
+
+       sdata->dev = dev;
+       sdata->local = local;
+
+       dev->needed_headroom = local->hw.extra_tx_headroom;
+
+       SET_NETDEV_DEV(dev, &local->phy->dev);
+
+       err = register_netdev(dev);
+       if (err < 0)
+               return err;
+
+       rtnl_lock();
+       mutex_lock(&local->iflist_mtx);
+       list_add_tail_rcu(&sdata->list, &local->interfaces);
+       mutex_unlock(&local->iflist_mtx);
+       rtnl_unlock();
+
+       return 0;
+}
+
+struct net_device *
+ieee802154_if_add(struct ieee802154_local *local, const char *name,
+                 struct wpan_dev **new_wpan_dev, int type)
+{
+       struct net_device *dev;
+       int err = -ENOMEM;
+
+       switch (type) {
+       case IEEE802154_DEV_MONITOR:
+               dev = alloc_netdev(sizeof(struct ieee802154_sub_if_data),
+                                  name, NET_NAME_UNKNOWN,
+                                  mac802154_monitor_setup);
+               break;
+       case IEEE802154_DEV_WPAN:
+               dev = alloc_netdev(sizeof(struct ieee802154_sub_if_data),
+                                  name, NET_NAME_UNKNOWN,
+                                  mac802154_wpan_setup);
+               break;
+       default:
+               dev = NULL;
+               err = -EINVAL;
+               break;
+       }
+       if (!dev)
+               goto err;
+
+       err = mac802154_netdev_register(local, dev);
+       if (err)
+               goto err_free;
+
+       dev_hold(dev); /* we return an incremented device refcount */
+       return dev;
+
+err_free:
+       free_netdev(dev);
+err:
+       return ERR_PTR(err);
+}
+
 void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata)
 {
        ASSERT_RTNL();
index 333d33daec6ee1bc90c96347decd804027dc5a2d..a371eb5fa0539ac9d8ed375b7c878ae3f6321c29 100644 (file)
 #include "ieee802154_i.h"
 #include "cfg.h"
 
-static int
-mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
-{
-       struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
-       struct ieee802154_local *local;
-       int err;
-
-       local = wpan_phy_priv(phy);
-
-       sdata->dev = dev;
-       sdata->local = local;
-
-       dev->needed_headroom = local->hw.extra_tx_headroom;
-
-       SET_NETDEV_DEV(dev, &local->phy->dev);
-
-       err = register_netdev(dev);
-       if (err < 0)
-               return err;
-
-       rtnl_lock();
-       mutex_lock(&local->iflist_mtx);
-       list_add_tail_rcu(&sdata->list, &local->interfaces);
-       mutex_unlock(&local->iflist_mtx);
-       rtnl_unlock();
-
-       return 0;
-}
-
-struct net_device *
-mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
-{
-       struct net_device *dev;
-       int err = -ENOMEM;
-
-       switch (type) {
-       case IEEE802154_DEV_MONITOR:
-               dev = alloc_netdev(sizeof(struct ieee802154_sub_if_data),
-                                  name, NET_NAME_UNKNOWN,
-                                  mac802154_monitor_setup);
-               break;
-       case IEEE802154_DEV_WPAN:
-               dev = alloc_netdev(sizeof(struct ieee802154_sub_if_data),
-                                  name, NET_NAME_UNKNOWN,
-                                  mac802154_wpan_setup);
-               break;
-       default:
-               dev = NULL;
-               err = -EINVAL;
-               break;
-       }
-       if (!dev)
-               goto err;
-
-       err = mac802154_netdev_register(phy, dev);
-       if (err)
-               goto err_free;
-
-       dev_hold(dev); /* we return an incremented device refcount */
-       return dev;
-
-err_free:
-       free_netdev(dev);
-err:
-       return ERR_PTR(err);
-}
-
 static void ieee802154_tasklet_handler(unsigned long data)
 {
        struct ieee802154_local *local = (struct ieee802154_local *)data;