cfg802154: convert deprecated iface add and del
authorAlexander Aring <alex.aring@gmail.com>
Sun, 2 Nov 2014 03:18:38 +0000 (04:18 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 2 Nov 2014 03:51:06 +0000 (04:51 +0100)
This patch removes the wpan_phy callbacks for add and del an interface
on a phy. Instead we introduce deprecated cfg802154 callbacks for this.
Furthermore we introduce a new netlink interface nl802154 which use
different callbacks. The deprecated function is to have a backwards
compatibility with the current netlink interface.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/cfg802154.h
net/ieee802154/nl-phy.c
net/ieee802154/rdev-ops.h [new file with mode: 0644]
net/mac802154/cfg.c
net/mac802154/ieee802154_i.h
net/mac802154/main.c

index 12de66bda9a52e87a11697937ac976eb0ca795dc..864bce2b0728e3924c0497388ad95ff1ba7d1a00 100644 (file)
 struct wpan_phy;
 
 struct cfg802154_ops {
+       struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
+                                                          const char *name,
+                                                          int type);
+       void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy,
+                                           struct net_device *dev);
 };
 
 struct wpan_phy {
@@ -58,10 +63,6 @@ struct wpan_phy {
        struct device dev;
        int idx;
 
-       struct net_device *(*add_iface)(struct wpan_phy *phy,
-                                       const char *name, int type);
-       void (*del_iface)(struct wpan_phy *phy, struct net_device *dev);
-
        char priv[0] __aligned(NETDEV_ALIGN);
 };
 
index 0afe760ff5126d6e24530236377d6b9e19b71728..5d914d30e0b14ce34b4d959b6641c1fbcb7fdd14 100644 (file)
@@ -30,6 +30,8 @@
 #include <linux/nl802154.h>
 
 #include "ieee802154.h"
+#include "rdev-ops.h"
+#include "core.h"
 
 static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
                                  u32 seq, int flags, struct wpan_phy *phy)
@@ -203,11 +205,6 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
        if (!msg)
                goto out_dev;
 
-       if (!phy->add_iface) {
-               rc = -EINVAL;
-               goto nla_put_failure;
-       }
-
        if (info->attrs[IEEE802154_ATTR_HW_ADDR] &&
            nla_len(info->attrs[IEEE802154_ATTR_HW_ADDR]) !=
                        IEEE802154_ADDR_LEN) {
@@ -223,7 +220,8 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
                }
        }
 
-       dev = phy->add_iface(phy, devname, type);
+       dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname,
+                                              type);
        if (IS_ERR(dev)) {
                rc = PTR_ERR(dev);
                goto nla_put_failure;
@@ -257,7 +255,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
 
 dev_unregister:
        rtnl_lock(); /* del_iface must be called with RTNL lock */
-       phy->del_iface(phy, dev);
+       rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev);
        dev_put(dev);
        rtnl_unlock();
 nla_put_failure:
@@ -319,13 +317,8 @@ int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info)
        if (!msg)
                goto out_dev;
 
-       if (!phy->del_iface) {
-               rc = -EINVAL;
-               goto nla_put_failure;
-       }
-
        rtnl_lock();
-       phy->del_iface(phy, dev);
+       rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev);
 
        /* We don't have device anymore */
        dev_put(dev);
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h
new file mode 100644 (file)
index 0000000..ac8824e
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef __CFG802154_RDEV_OPS
+#define __CFG802154_RDEV_OPS
+
+#include <net/cfg802154.h>
+
+#include "core.h"
+
+static inline struct net_device *
+rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
+                                const char *name, int type)
+{
+       return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
+                                                     type);
+}
+
+static inline void
+rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
+                                struct net_device *dev)
+{
+       rdev->ops->del_virtual_intf_deprecated(&rdev->wpan_phy, dev);
+}
+
+#endif /* __CFG802154_RDEV_OPS */
index 105468ec8f2653289f87d74dd4e460b0c06f462c..75a5d258ac24efb5c4e6607c6dad8c6bed028746 100644 (file)
 
 #include <net/cfg802154.h>
 
+#include "ieee802154_i.h"
+
+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);
+}
+
+static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy,
+                                           struct net_device *dev)
+{
+       mac802154_del_iface(wpan_phy, dev);
+}
+
 const struct cfg802154_ops mac802154_config_ops = {
+       .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated,
+       .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated,
 };
index 1086a9d96f8f6d94bc321b579ffe9b4a194dc94e..39af6eaec410a6d3c902810b78c426c49e4422f7 100644 (file)
@@ -174,4 +174,8 @@ void mac802154_get_table(struct net_device *dev,
                         struct ieee802154_llsec_table **t);
 void mac802154_unlock_table(struct net_device *dev);
 
+struct net_device *
+mac802154_add_iface(struct wpan_phy *phy, const char *name, int type);
+void mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev);
+
 #endif /* __IEEE802154_I_H */
index 785abb1aafb440e5f8f3ac56e1e8c2aa87ec17ed..b34ddbf43c3d9cf053d1762d5794748af0cc909c 100644 (file)
@@ -59,8 +59,7 @@ mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev)
        return 0;
 }
 
-static void
-mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
+void mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
 {
        struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
 
@@ -76,7 +75,7 @@ mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev)
        unregister_netdevice(sdata->dev);
 }
 
-static struct net_device *
+struct net_device *
 mac802154_add_iface(struct wpan_phy *phy, const char *name, int type)
 {
        struct net_device *dev;
@@ -221,9 +220,6 @@ int ieee802154_register_hw(struct ieee802154_hw *hw)
 
        wpan_phy_set_dev(local->phy, local->hw.parent);
 
-       local->phy->add_iface = mac802154_add_iface;
-       local->phy->del_iface = mac802154_del_iface;
-
        rc = wpan_phy_register(local->phy);
        if (rc < 0)
                goto out_wq;