Thomas Gleixner | 1802d0b | 2019-05-27 08:55:21 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2007, 2008, 2009 Siemens AG |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 4 | */ |
| 5 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 6 | #include <linux/slab.h> |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 7 | #include <linux/kernel.h> |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/device.h> |
| 10 | |
Alexander Aring | 5ad60d3 | 2014-10-25 09:41:02 +0200 | [diff] [blame] | 11 | #include <net/cfg802154.h> |
Alexander Aring | f3ada64 | 2014-11-09 08:36:48 +0100 | [diff] [blame] | 12 | #include <net/rtnetlink.h> |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 13 | |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 14 | #include "ieee802154.h" |
Alexander Aring | 79fe1a2 | 2014-11-09 08:36:53 +0100 | [diff] [blame] | 15 | #include "nl802154.h" |
Alexander Aring | e23e9ec | 2014-10-28 18:21:32 +0100 | [diff] [blame] | 16 | #include "sysfs.h" |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 17 | #include "core.h" |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 18 | |
Alexander Aring | c4dd747 | 2015-03-02 15:10:04 +0100 | [diff] [blame] | 19 | /* name for sysfs, %d is appended */ |
| 20 | #define PHY_NAME "phy" |
| 21 | |
Alexander Aring | f3ada64 | 2014-11-09 08:36:48 +0100 | [diff] [blame] | 22 | /* RCU-protected (and RTNL for writers) */ |
Alexander Aring | 79fe1a2 | 2014-11-09 08:36:53 +0100 | [diff] [blame] | 23 | LIST_HEAD(cfg802154_rdev_list); |
Alexander Aring | ca20ce20 | 2014-11-09 08:36:54 +0100 | [diff] [blame] | 24 | int cfg802154_rdev_list_generation; |
Alexander Aring | f3ada64 | 2014-11-09 08:36:48 +0100 | [diff] [blame] | 25 | |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 26 | struct wpan_phy *wpan_phy_find(const char *str) |
| 27 | { |
| 28 | struct device *dev; |
| 29 | |
| 30 | if (WARN_ON(!str)) |
| 31 | return NULL; |
| 32 | |
Suzuki K Poulose | 6cda08a | 2019-07-23 23:18:32 +0100 | [diff] [blame] | 33 | dev = class_find_device_by_name(&wpan_phy_class, str); |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 34 | if (!dev) |
| 35 | return NULL; |
| 36 | |
| 37 | return container_of(dev, struct wpan_phy, dev); |
| 38 | } |
| 39 | EXPORT_SYMBOL(wpan_phy_find); |
| 40 | |
Dmitry Eremin-Solenikov | 1c889f4 | 2009-09-15 16:57:04 +0400 | [diff] [blame] | 41 | struct wpan_phy_iter_data { |
| 42 | int (*fn)(struct wpan_phy *phy, void *data); |
| 43 | void *data; |
| 44 | }; |
| 45 | |
| 46 | static int wpan_phy_iter(struct device *dev, void *_data) |
| 47 | { |
| 48 | struct wpan_phy_iter_data *wpid = _data; |
| 49 | struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev); |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 50 | |
Dmitry Eremin-Solenikov | 1c889f4 | 2009-09-15 16:57:04 +0400 | [diff] [blame] | 51 | return wpid->fn(phy, wpid->data); |
| 52 | } |
| 53 | |
| 54 | int wpan_phy_for_each(int (*fn)(struct wpan_phy *phy, void *data), |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 55 | void *data) |
Dmitry Eremin-Solenikov | 1c889f4 | 2009-09-15 16:57:04 +0400 | [diff] [blame] | 56 | { |
| 57 | struct wpan_phy_iter_data wpid = { |
| 58 | .fn = fn, |
| 59 | .data = data, |
| 60 | }; |
| 61 | |
| 62 | return class_for_each_device(&wpan_phy_class, NULL, |
| 63 | &wpid, wpan_phy_iter); |
| 64 | } |
| 65 | EXPORT_SYMBOL(wpan_phy_for_each); |
| 66 | |
Alexander Aring | 79fe1a2 | 2014-11-09 08:36:53 +0100 | [diff] [blame] | 67 | struct cfg802154_registered_device * |
| 68 | cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx) |
| 69 | { |
| 70 | struct cfg802154_registered_device *result = NULL, *rdev; |
| 71 | |
| 72 | ASSERT_RTNL(); |
| 73 | |
| 74 | list_for_each_entry(rdev, &cfg802154_rdev_list, list) { |
| 75 | if (rdev->wpan_phy_idx == wpan_phy_idx) { |
| 76 | result = rdev; |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | return result; |
| 82 | } |
| 83 | |
Alexander Aring | a26c5fd | 2015-09-28 09:00:25 +0200 | [diff] [blame] | 84 | struct wpan_phy *wpan_phy_idx_to_wpan_phy(int wpan_phy_idx) |
| 85 | { |
| 86 | struct cfg802154_registered_device *rdev; |
| 87 | |
| 88 | ASSERT_RTNL(); |
| 89 | |
| 90 | rdev = cfg802154_rdev_by_wpan_phy_idx(wpan_phy_idx); |
| 91 | if (!rdev) |
| 92 | return NULL; |
| 93 | return &rdev->wpan_phy; |
| 94 | } |
| 95 | |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 96 | struct wpan_phy * |
Alexander Aring | f601379 | 2014-11-09 08:36:47 +0100 | [diff] [blame] | 97 | wpan_phy_new(const struct cfg802154_ops *ops, size_t priv_size) |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 98 | { |
Alexander Aring | 53f9ee61 | 2014-11-05 20:51:12 +0100 | [diff] [blame] | 99 | static atomic_t wpan_phy_counter = ATOMIC_INIT(0); |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 100 | struct cfg802154_registered_device *rdev; |
| 101 | size_t alloc_size; |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 102 | |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 103 | alloc_size = sizeof(*rdev) + priv_size; |
| 104 | rdev = kzalloc(alloc_size, GFP_KERNEL); |
| 105 | if (!rdev) |
| 106 | return NULL; |
| 107 | |
| 108 | rdev->ops = ops; |
| 109 | |
Alexander Aring | 53f9ee61 | 2014-11-05 20:51:12 +0100 | [diff] [blame] | 110 | rdev->wpan_phy_idx = atomic_inc_return(&wpan_phy_counter); |
| 111 | |
| 112 | if (unlikely(rdev->wpan_phy_idx < 0)) { |
| 113 | /* ugh, wrapped! */ |
| 114 | atomic_dec(&wpan_phy_counter); |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 115 | kfree(rdev); |
Alexander Aring | 53f9ee61 | 2014-11-05 20:51:12 +0100 | [diff] [blame] | 116 | return NULL; |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 117 | } |
Alexander Aring | 53f9ee61 | 2014-11-05 20:51:12 +0100 | [diff] [blame] | 118 | |
| 119 | /* atomic_inc_return makes it start at 1, make it start at 0 */ |
| 120 | rdev->wpan_phy_idx--; |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 121 | |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 122 | INIT_LIST_HEAD(&rdev->wpan_dev_list); |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 123 | device_initialize(&rdev->wpan_phy.dev); |
Alexander Aring | c4dd747 | 2015-03-02 15:10:04 +0100 | [diff] [blame] | 124 | dev_set_name(&rdev->wpan_phy.dev, PHY_NAME "%d", rdev->wpan_phy_idx); |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 125 | |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 126 | rdev->wpan_phy.dev.class = &wpan_phy_class; |
| 127 | rdev->wpan_phy.dev.platform_data = rdev; |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 128 | |
Alexander Aring | 66e5c26 | 2016-06-18 10:45:34 +0200 | [diff] [blame] | 129 | wpan_phy_net_set(&rdev->wpan_phy, &init_net); |
| 130 | |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 131 | init_waitqueue_head(&rdev->dev_wait); |
| 132 | |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 133 | return &rdev->wpan_phy; |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 134 | } |
Alexander Aring | f601379 | 2014-11-09 08:36:47 +0100 | [diff] [blame] | 135 | EXPORT_SYMBOL(wpan_phy_new); |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 136 | |
Dmitry Eremin-Solenikov | e9cf356 | 2009-09-28 19:01:20 +0400 | [diff] [blame] | 137 | int wpan_phy_register(struct wpan_phy *phy) |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 138 | { |
Alexander Aring | f3ada64 | 2014-11-09 08:36:48 +0100 | [diff] [blame] | 139 | struct cfg802154_registered_device *rdev = wpan_phy_to_rdev(phy); |
| 140 | int ret; |
| 141 | |
| 142 | rtnl_lock(); |
| 143 | ret = device_add(&phy->dev); |
| 144 | if (ret) { |
| 145 | rtnl_unlock(); |
| 146 | return ret; |
| 147 | } |
| 148 | |
| 149 | list_add_rcu(&rdev->list, &cfg802154_rdev_list); |
| 150 | cfg802154_rdev_list_generation++; |
| 151 | |
| 152 | /* TODO phy registered lock */ |
| 153 | rtnl_unlock(); |
| 154 | |
| 155 | /* TODO nl802154 phy notify */ |
| 156 | |
| 157 | return 0; |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 158 | } |
| 159 | EXPORT_SYMBOL(wpan_phy_register); |
| 160 | |
| 161 | void wpan_phy_unregister(struct wpan_phy *phy) |
| 162 | { |
Alexander Aring | f3ada64 | 2014-11-09 08:36:48 +0100 | [diff] [blame] | 163 | struct cfg802154_registered_device *rdev = wpan_phy_to_rdev(phy); |
| 164 | |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 165 | wait_event(rdev->dev_wait, ({ |
| 166 | int __count; |
| 167 | rtnl_lock(); |
| 168 | __count = rdev->opencount; |
| 169 | rtnl_unlock(); |
| 170 | __count == 0; })); |
Alexander Aring | f3ada64 | 2014-11-09 08:36:48 +0100 | [diff] [blame] | 171 | |
| 172 | rtnl_lock(); |
| 173 | /* TODO nl802154 phy notify */ |
| 174 | /* TODO phy registered lock */ |
| 175 | |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 176 | WARN_ON(!list_empty(&rdev->wpan_dev_list)); |
Alexander Aring | f3ada64 | 2014-11-09 08:36:48 +0100 | [diff] [blame] | 177 | |
| 178 | /* First remove the hardware from everywhere, this makes |
| 179 | * it impossible to find from userspace. |
| 180 | */ |
| 181 | list_del_rcu(&rdev->list); |
| 182 | synchronize_rcu(); |
| 183 | |
| 184 | cfg802154_rdev_list_generation++; |
| 185 | |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 186 | device_del(&phy->dev); |
Alexander Aring | f3ada64 | 2014-11-09 08:36:48 +0100 | [diff] [blame] | 187 | |
| 188 | rtnl_unlock(); |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 189 | } |
| 190 | EXPORT_SYMBOL(wpan_phy_unregister); |
| 191 | |
| 192 | void wpan_phy_free(struct wpan_phy *phy) |
| 193 | { |
| 194 | put_device(&phy->dev); |
| 195 | } |
| 196 | EXPORT_SYMBOL(wpan_phy_free); |
| 197 | |
Alexander Aring | 66e5c26 | 2016-06-18 10:45:34 +0200 | [diff] [blame] | 198 | int cfg802154_switch_netns(struct cfg802154_registered_device *rdev, |
| 199 | struct net *net) |
| 200 | { |
| 201 | struct wpan_dev *wpan_dev; |
| 202 | int err = 0; |
| 203 | |
| 204 | list_for_each_entry(wpan_dev, &rdev->wpan_dev_list, list) { |
| 205 | if (!wpan_dev->netdev) |
| 206 | continue; |
| 207 | wpan_dev->netdev->features &= ~NETIF_F_NETNS_LOCAL; |
| 208 | err = dev_change_net_namespace(wpan_dev->netdev, net, "wpan%d"); |
| 209 | if (err) |
| 210 | break; |
| 211 | wpan_dev->netdev->features |= NETIF_F_NETNS_LOCAL; |
| 212 | } |
| 213 | |
| 214 | if (err) { |
| 215 | /* failed -- clean up to old netns */ |
| 216 | net = wpan_phy_net(&rdev->wpan_phy); |
| 217 | |
| 218 | list_for_each_entry_continue_reverse(wpan_dev, |
| 219 | &rdev->wpan_dev_list, |
| 220 | list) { |
| 221 | if (!wpan_dev->netdev) |
| 222 | continue; |
| 223 | wpan_dev->netdev->features &= ~NETIF_F_NETNS_LOCAL; |
| 224 | err = dev_change_net_namespace(wpan_dev->netdev, net, |
| 225 | "wpan%d"); |
| 226 | WARN_ON(err); |
| 227 | wpan_dev->netdev->features |= NETIF_F_NETNS_LOCAL; |
| 228 | } |
| 229 | |
| 230 | return err; |
| 231 | } |
| 232 | |
| 233 | wpan_phy_net_set(&rdev->wpan_phy, net); |
| 234 | |
| 235 | err = device_rename(&rdev->wpan_phy.dev, dev_name(&rdev->wpan_phy.dev)); |
| 236 | WARN_ON(err); |
| 237 | |
| 238 | return 0; |
| 239 | } |
| 240 | |
Alexander Aring | a5dd1d7 | 2014-11-02 04:18:35 +0100 | [diff] [blame] | 241 | void cfg802154_dev_free(struct cfg802154_registered_device *rdev) |
| 242 | { |
| 243 | kfree(rdev); |
| 244 | } |
| 245 | |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 246 | static void |
| 247 | cfg802154_update_iface_num(struct cfg802154_registered_device *rdev, |
| 248 | int iftype, int num) |
| 249 | { |
| 250 | ASSERT_RTNL(); |
| 251 | |
| 252 | rdev->num_running_ifaces += num; |
| 253 | } |
| 254 | |
| 255 | static int cfg802154_netdev_notifier_call(struct notifier_block *nb, |
| 256 | unsigned long state, void *ptr) |
| 257 | { |
| 258 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
| 259 | struct wpan_dev *wpan_dev = dev->ieee802154_ptr; |
| 260 | struct cfg802154_registered_device *rdev; |
| 261 | |
| 262 | if (!wpan_dev) |
| 263 | return NOTIFY_DONE; |
| 264 | |
| 265 | rdev = wpan_phy_to_rdev(wpan_dev->wpan_phy); |
| 266 | |
| 267 | /* TODO WARN_ON unspec type */ |
| 268 | |
| 269 | switch (state) { |
| 270 | /* TODO NETDEV_DEVTYPE */ |
| 271 | case NETDEV_REGISTER: |
Nicolas Dichtel | f9d1ce8 | 2015-02-05 18:21:30 +0100 | [diff] [blame] | 272 | dev->features |= NETIF_F_NETNS_LOCAL; |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 273 | wpan_dev->identifier = ++rdev->wpan_dev_id; |
| 274 | list_add_rcu(&wpan_dev->list, &rdev->wpan_dev_list); |
| 275 | rdev->devlist_generation++; |
| 276 | |
| 277 | wpan_dev->netdev = dev; |
| 278 | break; |
| 279 | case NETDEV_DOWN: |
| 280 | cfg802154_update_iface_num(rdev, wpan_dev->iftype, -1); |
| 281 | |
| 282 | rdev->opencount--; |
| 283 | wake_up(&rdev->dev_wait); |
| 284 | break; |
| 285 | case NETDEV_UP: |
| 286 | cfg802154_update_iface_num(rdev, wpan_dev->iftype, 1); |
| 287 | |
| 288 | rdev->opencount++; |
| 289 | break; |
| 290 | case NETDEV_UNREGISTER: |
| 291 | /* It is possible to get NETDEV_UNREGISTER |
| 292 | * multiple times. To detect that, check |
| 293 | * that the interface is still on the list |
| 294 | * of registered interfaces, and only then |
| 295 | * remove and clean it up. |
| 296 | */ |
| 297 | if (!list_empty(&wpan_dev->list)) { |
| 298 | list_del_rcu(&wpan_dev->list); |
| 299 | rdev->devlist_generation++; |
| 300 | } |
| 301 | /* synchronize (so that we won't find this netdev |
| 302 | * from other code any more) and then clear the list |
| 303 | * head so that the above code can safely check for |
| 304 | * !list_empty() to avoid double-cleanup. |
| 305 | */ |
| 306 | synchronize_rcu(); |
| 307 | INIT_LIST_HEAD(&wpan_dev->list); |
| 308 | break; |
| 309 | default: |
| 310 | return NOTIFY_DONE; |
| 311 | } |
| 312 | |
| 313 | return NOTIFY_OK; |
| 314 | } |
| 315 | |
| 316 | static struct notifier_block cfg802154_netdev_notifier = { |
| 317 | .notifier_call = cfg802154_netdev_notifier_call, |
| 318 | }; |
| 319 | |
Alexander Aring | 66e5c26 | 2016-06-18 10:45:34 +0200 | [diff] [blame] | 320 | static void __net_exit cfg802154_pernet_exit(struct net *net) |
| 321 | { |
| 322 | struct cfg802154_registered_device *rdev; |
| 323 | |
| 324 | rtnl_lock(); |
| 325 | list_for_each_entry(rdev, &cfg802154_rdev_list, list) { |
| 326 | if (net_eq(wpan_phy_net(&rdev->wpan_phy), net)) |
| 327 | WARN_ON(cfg802154_switch_netns(rdev, &init_net)); |
| 328 | } |
| 329 | rtnl_unlock(); |
| 330 | } |
| 331 | |
| 332 | static struct pernet_operations cfg802154_pernet_ops = { |
| 333 | .exit = cfg802154_pernet_exit, |
| 334 | }; |
| 335 | |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 336 | static int __init wpan_phy_class_init(void) |
| 337 | { |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 338 | int rc; |
Varka Bhadram | 4710d80 | 2014-07-02 09:01:09 +0530 | [diff] [blame] | 339 | |
Alexander Aring | 66e5c26 | 2016-06-18 10:45:34 +0200 | [diff] [blame] | 340 | rc = register_pernet_device(&cfg802154_pernet_ops); |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 341 | if (rc) |
| 342 | goto err; |
| 343 | |
Alexander Aring | 66e5c26 | 2016-06-18 10:45:34 +0200 | [diff] [blame] | 344 | rc = wpan_phy_sysfs_init(); |
| 345 | if (rc) |
| 346 | goto err_sysfs; |
| 347 | |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 348 | rc = register_netdevice_notifier(&cfg802154_netdev_notifier); |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 349 | if (rc) |
| 350 | goto err_nl; |
| 351 | |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 352 | rc = ieee802154_nl_init(); |
| 353 | if (rc) |
| 354 | goto err_notifier; |
| 355 | |
Alexander Aring | 79fe1a2 | 2014-11-09 08:36:53 +0100 | [diff] [blame] | 356 | rc = nl802154_init(); |
| 357 | if (rc) |
| 358 | goto err_ieee802154_nl; |
| 359 | |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 360 | return 0; |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 361 | |
Alexander Aring | 79fe1a2 | 2014-11-09 08:36:53 +0100 | [diff] [blame] | 362 | err_ieee802154_nl: |
| 363 | ieee802154_nl_exit(); |
| 364 | |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 365 | err_notifier: |
| 366 | unregister_netdevice_notifier(&cfg802154_netdev_notifier); |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 367 | err_nl: |
Alexander Aring | e23e9ec | 2014-10-28 18:21:32 +0100 | [diff] [blame] | 368 | wpan_phy_sysfs_exit(); |
Alexander Aring | 66e5c26 | 2016-06-18 10:45:34 +0200 | [diff] [blame] | 369 | err_sysfs: |
| 370 | unregister_pernet_device(&cfg802154_pernet_ops); |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 371 | err: |
| 372 | return rc; |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 373 | } |
Dmitry Eremin-Solenikov | 282a395 | 2009-11-12 23:58:23 +0300 | [diff] [blame] | 374 | subsys_initcall(wpan_phy_class_init); |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 375 | |
| 376 | static void __exit wpan_phy_class_exit(void) |
| 377 | { |
Alexander Aring | 79fe1a2 | 2014-11-09 08:36:53 +0100 | [diff] [blame] | 378 | nl802154_exit(); |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 379 | ieee802154_nl_exit(); |
Alexander Aring | fcf39e6 | 2014-11-09 08:36:50 +0100 | [diff] [blame] | 380 | unregister_netdevice_notifier(&cfg802154_netdev_notifier); |
Alexander Aring | e23e9ec | 2014-10-28 18:21:32 +0100 | [diff] [blame] | 381 | wpan_phy_sysfs_exit(); |
Alexander Aring | 66e5c26 | 2016-06-18 10:45:34 +0200 | [diff] [blame] | 382 | unregister_pernet_device(&cfg802154_pernet_ops); |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 383 | } |
| 384 | module_exit(wpan_phy_class_exit); |
| 385 | |
Dmitry Eremin-Solenikov | 2bfb107 | 2009-08-14 16:13:12 +0400 | [diff] [blame] | 386 | MODULE_LICENSE("GPL v2"); |
Dmitry Eremin-Solenikov | cb6b376 | 2009-09-10 17:50:12 +0400 | [diff] [blame] | 387 | MODULE_DESCRIPTION("IEEE 802.15.4 configuration interface"); |
| 388 | MODULE_AUTHOR("Dmitry Eremin-Solenikov"); |