core.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) | core.c (66e5c2672cd11b9310008099faf6a4ffb9dfb6d0) |
---|---|
1/* 2 * Copyright (C) 2007, 2008, 2009 Siemens AG 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 6 * as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 126 unchanged lines hidden (view full) --- 135 136 INIT_LIST_HEAD(&rdev->wpan_dev_list); 137 device_initialize(&rdev->wpan_phy.dev); 138 dev_set_name(&rdev->wpan_phy.dev, PHY_NAME "%d", rdev->wpan_phy_idx); 139 140 rdev->wpan_phy.dev.class = &wpan_phy_class; 141 rdev->wpan_phy.dev.platform_data = rdev; 142 | 1/* 2 * Copyright (C) 2007, 2008, 2009 Siemens AG 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 6 * as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 126 unchanged lines hidden (view full) --- 135 136 INIT_LIST_HEAD(&rdev->wpan_dev_list); 137 device_initialize(&rdev->wpan_phy.dev); 138 dev_set_name(&rdev->wpan_phy.dev, PHY_NAME "%d", rdev->wpan_phy_idx); 139 140 rdev->wpan_phy.dev.class = &wpan_phy_class; 141 rdev->wpan_phy.dev.platform_data = rdev; 142 |
143 wpan_phy_net_set(&rdev->wpan_phy, &init_net); 144 |
|
143 init_waitqueue_head(&rdev->dev_wait); 144 145 return &rdev->wpan_phy; 146} 147EXPORT_SYMBOL(wpan_phy_new); 148 149int wpan_phy_register(struct wpan_phy *phy) 150{ --- 51 unchanged lines hidden (view full) --- 202EXPORT_SYMBOL(wpan_phy_unregister); 203 204void wpan_phy_free(struct wpan_phy *phy) 205{ 206 put_device(&phy->dev); 207} 208EXPORT_SYMBOL(wpan_phy_free); 209 | 145 init_waitqueue_head(&rdev->dev_wait); 146 147 return &rdev->wpan_phy; 148} 149EXPORT_SYMBOL(wpan_phy_new); 150 151int wpan_phy_register(struct wpan_phy *phy) 152{ --- 51 unchanged lines hidden (view full) --- 204EXPORT_SYMBOL(wpan_phy_unregister); 205 206void wpan_phy_free(struct wpan_phy *phy) 207{ 208 put_device(&phy->dev); 209} 210EXPORT_SYMBOL(wpan_phy_free); 211 |
212int cfg802154_switch_netns(struct cfg802154_registered_device *rdev, 213 struct net *net) 214{ 215 struct wpan_dev *wpan_dev; 216 int err = 0; 217 218 list_for_each_entry(wpan_dev, &rdev->wpan_dev_list, list) { 219 if (!wpan_dev->netdev) 220 continue; 221 wpan_dev->netdev->features &= ~NETIF_F_NETNS_LOCAL; 222 err = dev_change_net_namespace(wpan_dev->netdev, net, "wpan%d"); 223 if (err) 224 break; 225 wpan_dev->netdev->features |= NETIF_F_NETNS_LOCAL; 226 } 227 228 if (err) { 229 /* failed -- clean up to old netns */ 230 net = wpan_phy_net(&rdev->wpan_phy); 231 232 list_for_each_entry_continue_reverse(wpan_dev, 233 &rdev->wpan_dev_list, 234 list) { 235 if (!wpan_dev->netdev) 236 continue; 237 wpan_dev->netdev->features &= ~NETIF_F_NETNS_LOCAL; 238 err = dev_change_net_namespace(wpan_dev->netdev, net, 239 "wpan%d"); 240 WARN_ON(err); 241 wpan_dev->netdev->features |= NETIF_F_NETNS_LOCAL; 242 } 243 244 return err; 245 } 246 247 wpan_phy_net_set(&rdev->wpan_phy, net); 248 249 err = device_rename(&rdev->wpan_phy.dev, dev_name(&rdev->wpan_phy.dev)); 250 WARN_ON(err); 251 252 return 0; 253} 254 |
|
210void cfg802154_dev_free(struct cfg802154_registered_device *rdev) 211{ 212 kfree(rdev); 213} 214 215static void 216cfg802154_update_iface_num(struct cfg802154_registered_device *rdev, 217 int iftype, int num) --- 63 unchanged lines hidden (view full) --- 281 282 return NOTIFY_OK; 283} 284 285static struct notifier_block cfg802154_netdev_notifier = { 286 .notifier_call = cfg802154_netdev_notifier_call, 287}; 288 | 255void cfg802154_dev_free(struct cfg802154_registered_device *rdev) 256{ 257 kfree(rdev); 258} 259 260static void 261cfg802154_update_iface_num(struct cfg802154_registered_device *rdev, 262 int iftype, int num) --- 63 unchanged lines hidden (view full) --- 326 327 return NOTIFY_OK; 328} 329 330static struct notifier_block cfg802154_netdev_notifier = { 331 .notifier_call = cfg802154_netdev_notifier_call, 332}; 333 |
334static void __net_exit cfg802154_pernet_exit(struct net *net) 335{ 336 struct cfg802154_registered_device *rdev; 337 338 rtnl_lock(); 339 list_for_each_entry(rdev, &cfg802154_rdev_list, list) { 340 if (net_eq(wpan_phy_net(&rdev->wpan_phy), net)) 341 WARN_ON(cfg802154_switch_netns(rdev, &init_net)); 342 } 343 rtnl_unlock(); 344} 345 346static struct pernet_operations cfg802154_pernet_ops = { 347 .exit = cfg802154_pernet_exit, 348}; 349 |
|
289static int __init wpan_phy_class_init(void) 290{ 291 int rc; 292 | 350static int __init wpan_phy_class_init(void) 351{ 352 int rc; 353 |
293 rc = wpan_phy_sysfs_init(); | 354 rc = register_pernet_device(&cfg802154_pernet_ops); |
294 if (rc) 295 goto err; 296 | 355 if (rc) 356 goto err; 357 |
358 rc = wpan_phy_sysfs_init(); 359 if (rc) 360 goto err_sysfs; 361 |
|
297 rc = register_netdevice_notifier(&cfg802154_netdev_notifier); 298 if (rc) 299 goto err_nl; 300 301 rc = ieee802154_nl_init(); 302 if (rc) 303 goto err_notifier; 304 --- 5 unchanged lines hidden (view full) --- 310 311err_ieee802154_nl: 312 ieee802154_nl_exit(); 313 314err_notifier: 315 unregister_netdevice_notifier(&cfg802154_netdev_notifier); 316err_nl: 317 wpan_phy_sysfs_exit(); | 362 rc = register_netdevice_notifier(&cfg802154_netdev_notifier); 363 if (rc) 364 goto err_nl; 365 366 rc = ieee802154_nl_init(); 367 if (rc) 368 goto err_notifier; 369 --- 5 unchanged lines hidden (view full) --- 375 376err_ieee802154_nl: 377 ieee802154_nl_exit(); 378 379err_notifier: 380 unregister_netdevice_notifier(&cfg802154_netdev_notifier); 381err_nl: 382 wpan_phy_sysfs_exit(); |
383err_sysfs: 384 unregister_pernet_device(&cfg802154_pernet_ops); |
|
318err: 319 return rc; 320} 321subsys_initcall(wpan_phy_class_init); 322 323static void __exit wpan_phy_class_exit(void) 324{ 325 nl802154_exit(); 326 ieee802154_nl_exit(); 327 unregister_netdevice_notifier(&cfg802154_netdev_notifier); 328 wpan_phy_sysfs_exit(); | 385err: 386 return rc; 387} 388subsys_initcall(wpan_phy_class_init); 389 390static void __exit wpan_phy_class_exit(void) 391{ 392 nl802154_exit(); 393 ieee802154_nl_exit(); 394 unregister_netdevice_notifier(&cfg802154_netdev_notifier); 395 wpan_phy_sysfs_exit(); |
396 unregister_pernet_device(&cfg802154_pernet_ops); |
|
329} 330module_exit(wpan_phy_class_exit); 331 332MODULE_LICENSE("GPL v2"); 333MODULE_DESCRIPTION("IEEE 802.15.4 configuration interface"); 334MODULE_AUTHOR("Dmitry Eremin-Solenikov"); 335 | 397} 398module_exit(wpan_phy_class_exit); 399 400MODULE_LICENSE("GPL v2"); 401MODULE_DESCRIPTION("IEEE 802.15.4 configuration interface"); 402MODULE_AUTHOR("Dmitry Eremin-Solenikov"); 403 |