diff options
author | Alexander Aring <alex.aring@gmail.com> | 2014-11-01 23:18:38 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-11-01 23:51:06 -0400 |
commit | 4a9a816a4f8c79260446811bdf80615b36539949 (patch) | |
tree | 0a1cd15db83d484ed190714bf60db93341f9c7c7 | |
parent | ea4dcd32a445908c12e04b3b879c57ec5b3e659a (diff) |
cfg802154: convert deprecated iface add and del
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>
-rw-r--r-- | include/net/cfg802154.h | 9 | ||||
-rw-r--r-- | net/ieee802154/nl-phy.c | 19 | ||||
-rw-r--r-- | net/ieee802154/rdev-ops.h | 23 | ||||
-rw-r--r-- | net/mac802154/cfg.c | 17 | ||||
-rw-r--r-- | net/mac802154/ieee802154_i.h | 4 | ||||
-rw-r--r-- | net/mac802154/main.c | 8 |
6 files changed, 57 insertions, 23 deletions
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h index 12de66bda9a5..864bce2b0728 100644 --- a/include/net/cfg802154.h +++ b/include/net/cfg802154.h | |||
@@ -32,6 +32,11 @@ | |||
32 | struct wpan_phy; | 32 | struct wpan_phy; |
33 | 33 | ||
34 | struct cfg802154_ops { | 34 | struct cfg802154_ops { |
35 | struct net_device * (*add_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, | ||
36 | const char *name, | ||
37 | int type); | ||
38 | void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, | ||
39 | struct net_device *dev); | ||
35 | }; | 40 | }; |
36 | 41 | ||
37 | struct wpan_phy { | 42 | struct wpan_phy { |
@@ -58,10 +63,6 @@ struct wpan_phy { | |||
58 | struct device dev; | 63 | struct device dev; |
59 | int idx; | 64 | int idx; |
60 | 65 | ||
61 | struct net_device *(*add_iface)(struct wpan_phy *phy, | ||
62 | const char *name, int type); | ||
63 | void (*del_iface)(struct wpan_phy *phy, struct net_device *dev); | ||
64 | |||
65 | char priv[0] __aligned(NETDEV_ALIGN); | 66 | char priv[0] __aligned(NETDEV_ALIGN); |
66 | }; | 67 | }; |
67 | 68 | ||
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c index 0afe760ff512..5d914d30e0b1 100644 --- a/net/ieee802154/nl-phy.c +++ b/net/ieee802154/nl-phy.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/nl802154.h> | 30 | #include <linux/nl802154.h> |
31 | 31 | ||
32 | #include "ieee802154.h" | 32 | #include "ieee802154.h" |
33 | #include "rdev-ops.h" | ||
34 | #include "core.h" | ||
33 | 35 | ||
34 | static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, | 36 | static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, |
35 | u32 seq, int flags, struct wpan_phy *phy) | 37 | u32 seq, int flags, struct wpan_phy *phy) |
@@ -203,11 +205,6 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) | |||
203 | if (!msg) | 205 | if (!msg) |
204 | goto out_dev; | 206 | goto out_dev; |
205 | 207 | ||
206 | if (!phy->add_iface) { | ||
207 | rc = -EINVAL; | ||
208 | goto nla_put_failure; | ||
209 | } | ||
210 | |||
211 | if (info->attrs[IEEE802154_ATTR_HW_ADDR] && | 208 | if (info->attrs[IEEE802154_ATTR_HW_ADDR] && |
212 | nla_len(info->attrs[IEEE802154_ATTR_HW_ADDR]) != | 209 | nla_len(info->attrs[IEEE802154_ATTR_HW_ADDR]) != |
213 | IEEE802154_ADDR_LEN) { | 210 | IEEE802154_ADDR_LEN) { |
@@ -223,7 +220,8 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) | |||
223 | } | 220 | } |
224 | } | 221 | } |
225 | 222 | ||
226 | dev = phy->add_iface(phy, devname, type); | 223 | dev = rdev_add_virtual_intf_deprecated(wpan_phy_to_rdev(phy), devname, |
224 | type); | ||
227 | if (IS_ERR(dev)) { | 225 | if (IS_ERR(dev)) { |
228 | rc = PTR_ERR(dev); | 226 | rc = PTR_ERR(dev); |
229 | goto nla_put_failure; | 227 | goto nla_put_failure; |
@@ -257,7 +255,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info) | |||
257 | 255 | ||
258 | dev_unregister: | 256 | dev_unregister: |
259 | rtnl_lock(); /* del_iface must be called with RTNL lock */ | 257 | rtnl_lock(); /* del_iface must be called with RTNL lock */ |
260 | phy->del_iface(phy, dev); | 258 | rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev); |
261 | dev_put(dev); | 259 | dev_put(dev); |
262 | rtnl_unlock(); | 260 | rtnl_unlock(); |
263 | nla_put_failure: | 261 | nla_put_failure: |
@@ -319,13 +317,8 @@ int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info) | |||
319 | if (!msg) | 317 | if (!msg) |
320 | goto out_dev; | 318 | goto out_dev; |
321 | 319 | ||
322 | if (!phy->del_iface) { | ||
323 | rc = -EINVAL; | ||
324 | goto nla_put_failure; | ||
325 | } | ||
326 | |||
327 | rtnl_lock(); | 320 | rtnl_lock(); |
328 | phy->del_iface(phy, dev); | 321 | rdev_del_virtual_intf_deprecated(wpan_phy_to_rdev(phy), dev); |
329 | 322 | ||
330 | /* We don't have device anymore */ | 323 | /* We don't have device anymore */ |
331 | dev_put(dev); | 324 | dev_put(dev); |
diff --git a/net/ieee802154/rdev-ops.h b/net/ieee802154/rdev-ops.h new file mode 100644 index 000000000000..ac8824ec168c --- /dev/null +++ b/net/ieee802154/rdev-ops.h | |||
@@ -0,0 +1,23 @@ | |||
1 | #ifndef __CFG802154_RDEV_OPS | ||
2 | #define __CFG802154_RDEV_OPS | ||
3 | |||
4 | #include <net/cfg802154.h> | ||
5 | |||
6 | #include "core.h" | ||
7 | |||
8 | static inline struct net_device * | ||
9 | rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, | ||
10 | const char *name, int type) | ||
11 | { | ||
12 | return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name, | ||
13 | type); | ||
14 | } | ||
15 | |||
16 | static inline void | ||
17 | rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev, | ||
18 | struct net_device *dev) | ||
19 | { | ||
20 | rdev->ops->del_virtual_intf_deprecated(&rdev->wpan_phy, dev); | ||
21 | } | ||
22 | |||
23 | #endif /* __CFG802154_RDEV_OPS */ | ||
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c index 105468ec8f26..75a5d258ac24 100644 --- a/net/mac802154/cfg.c +++ b/net/mac802154/cfg.c | |||
@@ -15,5 +15,22 @@ | |||
15 | 15 | ||
16 | #include <net/cfg802154.h> | 16 | #include <net/cfg802154.h> |
17 | 17 | ||
18 | #include "ieee802154_i.h" | ||
19 | |||
20 | static struct net_device * | ||
21 | ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy, | ||
22 | const char *name, int type) | ||
23 | { | ||
24 | return mac802154_add_iface(wpan_phy, name, type); | ||
25 | } | ||
26 | |||
27 | static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy, | ||
28 | struct net_device *dev) | ||
29 | { | ||
30 | mac802154_del_iface(wpan_phy, dev); | ||
31 | } | ||
32 | |||
18 | const struct cfg802154_ops mac802154_config_ops = { | 33 | const struct cfg802154_ops mac802154_config_ops = { |
34 | .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated, | ||
35 | .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated, | ||
19 | }; | 36 | }; |
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 1086a9d96f8f..39af6eaec410 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h | |||
@@ -174,4 +174,8 @@ void mac802154_get_table(struct net_device *dev, | |||
174 | struct ieee802154_llsec_table **t); | 174 | struct ieee802154_llsec_table **t); |
175 | void mac802154_unlock_table(struct net_device *dev); | 175 | void mac802154_unlock_table(struct net_device *dev); |
176 | 176 | ||
177 | struct net_device * | ||
178 | mac802154_add_iface(struct wpan_phy *phy, const char *name, int type); | ||
179 | void mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev); | ||
180 | |||
177 | #endif /* __IEEE802154_I_H */ | 181 | #endif /* __IEEE802154_I_H */ |
diff --git a/net/mac802154/main.c b/net/mac802154/main.c index 785abb1aafb4..b34ddbf43c3d 100644 --- a/net/mac802154/main.c +++ b/net/mac802154/main.c | |||
@@ -59,8 +59,7 @@ mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev) | |||
59 | return 0; | 59 | return 0; |
60 | } | 60 | } |
61 | 61 | ||
62 | static void | 62 | void mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev) |
63 | mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev) | ||
64 | { | 63 | { |
65 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); | 64 | struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev); |
66 | 65 | ||
@@ -76,7 +75,7 @@ mac802154_del_iface(struct wpan_phy *phy, struct net_device *dev) | |||
76 | unregister_netdevice(sdata->dev); | 75 | unregister_netdevice(sdata->dev); |
77 | } | 76 | } |
78 | 77 | ||
79 | static struct net_device * | 78 | struct net_device * |
80 | mac802154_add_iface(struct wpan_phy *phy, const char *name, int type) | 79 | mac802154_add_iface(struct wpan_phy *phy, const char *name, int type) |
81 | { | 80 | { |
82 | struct net_device *dev; | 81 | struct net_device *dev; |
@@ -221,9 +220,6 @@ int ieee802154_register_hw(struct ieee802154_hw *hw) | |||
221 | 220 | ||
222 | wpan_phy_set_dev(local->phy, local->hw.parent); | 221 | wpan_phy_set_dev(local->phy, local->hw.parent); |
223 | 222 | ||
224 | local->phy->add_iface = mac802154_add_iface; | ||
225 | local->phy->del_iface = mac802154_del_iface; | ||
226 | |||
227 | rc = wpan_phy_register(local->phy); | 223 | rc = wpan_phy_register(local->phy); |
228 | if (rc < 0) | 224 | if (rc < 0) |
229 | goto out_wq; | 225 | goto out_wq; |