OLD | NEW |
1 /* | 1 /* |
2 * This is the linux wireless configuration interface. | 2 * This is the linux wireless configuration interface. |
3 * | 3 * |
4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> | 4 * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> |
5 */ | 5 */ |
6 | 6 |
7 #include <linux/if.h> | 7 #include <linux/if.h> |
8 #include <linux/module.h> | 8 #include <linux/module.h> |
9 #include <linux/err.h> | 9 #include <linux/err.h> |
10 #include <linux/list.h> | 10 #include <linux/list.h> |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 WARN_ON(1); | 468 WARN_ON(1); |
469 return -EINVAL; | 469 return -EINVAL; |
470 } | 470 } |
471 | 471 |
472 /* check and set up bitrates */ | 472 /* check and set up bitrates */ |
473 ieee80211_set_bitrate_flags(wiphy); | 473 ieee80211_set_bitrate_flags(wiphy); |
474 | 474 |
475 mutex_lock(&cfg80211_mutex); | 475 mutex_lock(&cfg80211_mutex); |
476 | 476 |
477 res = device_add(&rdev->wiphy.dev); | 477 res = device_add(&rdev->wiphy.dev); |
478 » if (res) | 478 » if (res) { |
479 » » goto out_unlock; | 479 » » mutex_unlock(&cfg80211_mutex); |
480 | 480 » » return res; |
481 » res = rfkill_register(rdev->rfkill); | 481 » } |
482 » if (res) | |
483 » » goto out_rm_dev; | |
484 | 482 |
485 /* set up regulatory info */ | 483 /* set up regulatory info */ |
486 wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE); | 484 wiphy_update_regulatory(wiphy, NL80211_REGDOM_SET_BY_CORE); |
487 | 485 |
488 list_add_rcu(&rdev->list, &cfg80211_rdev_list); | 486 list_add_rcu(&rdev->list, &cfg80211_rdev_list); |
489 cfg80211_rdev_list_generation++; | 487 cfg80211_rdev_list_generation++; |
490 | 488 |
491 /* add to debugfs */ | 489 /* add to debugfs */ |
492 rdev->wiphy.debugfsdir = | 490 rdev->wiphy.debugfsdir = |
493 debugfs_create_dir(wiphy_name(&rdev->wiphy), | 491 debugfs_create_dir(wiphy_name(&rdev->wiphy), |
494 ieee80211_debugfs_dir); | 492 ieee80211_debugfs_dir); |
495 if (IS_ERR(rdev->wiphy.debugfsdir)) | 493 if (IS_ERR(rdev->wiphy.debugfsdir)) |
496 rdev->wiphy.debugfsdir = NULL; | 494 rdev->wiphy.debugfsdir = NULL; |
497 | 495 |
498 if (wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) { | 496 if (wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) { |
499 struct regulatory_request request; | 497 struct regulatory_request request; |
500 | 498 |
501 request.wiphy_idx = get_wiphy_idx(wiphy); | 499 request.wiphy_idx = get_wiphy_idx(wiphy); |
502 request.initiator = NL80211_REGDOM_SET_BY_DRIVER; | 500 request.initiator = NL80211_REGDOM_SET_BY_DRIVER; |
503 request.alpha2[0] = '9'; | 501 request.alpha2[0] = '9'; |
504 request.alpha2[1] = '9'; | 502 request.alpha2[1] = '9'; |
505 | 503 |
506 nl80211_send_reg_change_event(&request); | 504 nl80211_send_reg_change_event(&request); |
507 } | 505 } |
508 | 506 |
509 cfg80211_debugfs_rdev_add(rdev); | 507 cfg80211_debugfs_rdev_add(rdev); |
510 mutex_unlock(&cfg80211_mutex); | 508 mutex_unlock(&cfg80211_mutex); |
511 | 509 |
| 510 /* |
| 511 * due to a locking dependency this has to be outside of the |
| 512 * cfg80211_mutex lock |
| 513 */ |
| 514 res = rfkill_register(rdev->rfkill); |
| 515 if (res) |
| 516 goto out_rm_dev; |
| 517 |
512 return 0; | 518 return 0; |
513 | 519 |
514 out_rm_dev: | 520 out_rm_dev: |
515 device_del(&rdev->wiphy.dev); | 521 device_del(&rdev->wiphy.dev); |
516 | |
517 out_unlock: | |
518 mutex_unlock(&cfg80211_mutex); | |
519 return res; | 522 return res; |
520 } | 523 } |
521 EXPORT_SYMBOL(wiphy_register); | 524 EXPORT_SYMBOL(wiphy_register); |
522 | 525 |
523 void wiphy_rfkill_start_polling(struct wiphy *wiphy) | 526 void wiphy_rfkill_start_polling(struct wiphy *wiphy) |
524 { | 527 { |
525 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); | 528 struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); |
526 | 529 |
527 if (!rdev->ops->rfkill_poll) | 530 if (!rdev->ops->rfkill_poll) |
528 return; | 531 return; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 nl80211_exit(); | 917 nl80211_exit(); |
915 unregister_netdevice_notifier(&cfg80211_netdev_notifier); | 918 unregister_netdevice_notifier(&cfg80211_netdev_notifier); |
916 wiphy_sysfs_exit(); | 919 wiphy_sysfs_exit(); |
917 regulatory_exit(); | 920 regulatory_exit(); |
918 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) | 921 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) |
919 unregister_pernet_device(&cfg80211_pernet_ops); | 922 unregister_pernet_device(&cfg80211_pernet_ops); |
920 #endif | 923 #endif |
921 destroy_workqueue(cfg80211_wq); | 924 destroy_workqueue(cfg80211_wq); |
922 } | 925 } |
923 module_exit(cfg80211_exit); | 926 module_exit(cfg80211_exit); |
924 | |
925 static int ___wiphy_printk(const char *level, const struct wiphy *wiphy, | |
926 struct va_format *vaf) | |
927 { | |
928 if (!wiphy) | |
929 return printk("%s(NULL wiphy *): %pV", level, vaf); | |
930 | |
931 return printk("%s%s: %pV", level, wiphy_name(wiphy), vaf); | |
932 } | |
933 | |
934 int __wiphy_printk(const char *level, const struct wiphy *wiphy, | |
935 const char *fmt, ...) | |
936 { | |
937 struct va_format vaf; | |
938 va_list args; | |
939 int r; | |
940 | |
941 va_start(args, fmt); | |
942 | |
943 vaf.fmt = fmt; | |
944 vaf.va = &args; | |
945 | |
946 r = ___wiphy_printk(level, wiphy, &vaf); | |
947 va_end(args); | |
948 | |
949 return r; | |
950 } | |
951 EXPORT_SYMBOL(__wiphy_printk); | |
952 | |
953 #define define_wiphy_printk_level(func, kern_level) \ | |
954 int func(const struct wiphy *wiphy, const char *fmt, ...) \ | |
955 { \ | |
956 struct va_format vaf; \ | |
957 va_list args; \ | |
958 int r; \ | |
959 \ | |
960 va_start(args, fmt); \ | |
961 \ | |
962 vaf.fmt = fmt; \ | |
963 vaf.va = &args; \ | |
964 \ | |
965 r = ___wiphy_printk(kern_level, wiphy, &vaf); \ | |
966 va_end(args); \ | |
967 \ | |
968 return r; \ | |
969 } \ | |
970 EXPORT_SYMBOL(func); | |
971 | |
972 define_wiphy_printk_level(wiphy_debug, KERN_DEBUG); | |
OLD | NEW |