diff options
author | John W. Linville <linville@tuxdriver.com> | 2009-08-25 14:12:25 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-28 14:40:46 -0400 |
commit | b8ecd988b1670035a05035c553c08331214d6603 (patch) | |
tree | 4a6eda87b8b9d8aab7658cfd6f553dc9c86a13be /drivers/net | |
parent | 73f57f8398ed6cba82f9856e20d94d71e6edb3e2 (diff) |
libipw: initiate cfg80211 API conversion
Initiate the conversion of libipw to the new cfg80211 configuration API.
For now, leave CONFIG_IPW2200_PROMISCUOUS stuff alone. Eventually
migrate it to cfg80211 when the add/del/change_virtual_intf methods
are implemented.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/ipw2x00/ipw2100.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/ipw2x00/ipw2200.c | 141 | ||||
-rw-r--r-- | drivers/net/wireless/ipw2x00/libipw.h | 8 | ||||
-rw-r--r-- | drivers/net/wireless/ipw2x00/libipw_module.c | 42 |
4 files changed, 161 insertions, 36 deletions
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c index 8caa07a213be..77457386e0aa 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/ipw2x00/ipw2100.c | |||
@@ -6029,7 +6029,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev, | |||
6029 | struct ipw2100_priv *priv; | 6029 | struct ipw2100_priv *priv; |
6030 | struct net_device *dev; | 6030 | struct net_device *dev; |
6031 | 6031 | ||
6032 | dev = alloc_ieee80211(sizeof(struct ipw2100_priv)); | 6032 | dev = alloc_ieee80211(sizeof(struct ipw2100_priv), 0); |
6033 | if (!dev) | 6033 | if (!dev) |
6034 | return NULL; | 6034 | return NULL; |
6035 | priv = libipw_priv(dev); | 6035 | priv = libipw_priv(dev); |
@@ -6342,7 +6342,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, | |||
6342 | sysfs_remove_group(&pci_dev->dev.kobj, | 6342 | sysfs_remove_group(&pci_dev->dev.kobj, |
6343 | &ipw2100_attribute_group); | 6343 | &ipw2100_attribute_group); |
6344 | 6344 | ||
6345 | free_ieee80211(dev); | 6345 | free_ieee80211(dev, 0); |
6346 | pci_set_drvdata(pci_dev, NULL); | 6346 | pci_set_drvdata(pci_dev, NULL); |
6347 | } | 6347 | } |
6348 | 6348 | ||
@@ -6400,7 +6400,7 @@ static void __devexit ipw2100_pci_remove_one(struct pci_dev *pci_dev) | |||
6400 | if (dev->base_addr) | 6400 | if (dev->base_addr) |
6401 | iounmap((void __iomem *)dev->base_addr); | 6401 | iounmap((void __iomem *)dev->base_addr); |
6402 | 6402 | ||
6403 | free_ieee80211(dev); | 6403 | free_ieee80211(dev, 0); |
6404 | } | 6404 | } |
6405 | 6405 | ||
6406 | pci_release_regions(pci_dev); | 6406 | pci_release_regions(pci_dev); |
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index 0ccec9f9f955..3f8372daf46a 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c | |||
@@ -103,6 +103,25 @@ static int antenna = CFG_SYS_ANTENNA_BOTH; | |||
103 | static int rtap_iface = 0; /* def: 0 -- do not create rtap interface */ | 103 | static int rtap_iface = 0; /* def: 0 -- do not create rtap interface */ |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | static struct ieee80211_rate ipw2200_rates[] = { | ||
107 | { .bitrate = 10 }, | ||
108 | { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
109 | { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
110 | { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
111 | { .bitrate = 60 }, | ||
112 | { .bitrate = 90 }, | ||
113 | { .bitrate = 120 }, | ||
114 | { .bitrate = 180 }, | ||
115 | { .bitrate = 240 }, | ||
116 | { .bitrate = 360 }, | ||
117 | { .bitrate = 480 }, | ||
118 | { .bitrate = 540 } | ||
119 | }; | ||
120 | |||
121 | #define ipw2200_a_rates (ipw2200_rates + 4) | ||
122 | #define ipw2200_num_a_rates 8 | ||
123 | #define ipw2200_bg_rates (ipw2200_rates + 0) | ||
124 | #define ipw2200_num_bg_rates 12 | ||
106 | 125 | ||
107 | #ifdef CONFIG_IPW2200_QOS | 126 | #ifdef CONFIG_IPW2200_QOS |
108 | static int qos_enable = 0; | 127 | static int qos_enable = 0; |
@@ -8640,24 +8659,6 @@ static int ipw_sw_reset(struct ipw_priv *priv, int option) | |||
8640 | * | 8659 | * |
8641 | */ | 8660 | */ |
8642 | 8661 | ||
8643 | static int ipw_wx_get_name(struct net_device *dev, | ||
8644 | struct iw_request_info *info, | ||
8645 | union iwreq_data *wrqu, char *extra) | ||
8646 | { | ||
8647 | struct ipw_priv *priv = libipw_priv(dev); | ||
8648 | mutex_lock(&priv->mutex); | ||
8649 | if (priv->status & STATUS_RF_KILL_MASK) | ||
8650 | strcpy(wrqu->name, "radio off"); | ||
8651 | else if (!(priv->status & STATUS_ASSOCIATED)) | ||
8652 | strcpy(wrqu->name, "unassociated"); | ||
8653 | else | ||
8654 | snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11%c", | ||
8655 | ipw_modes[priv->assoc_request.ieee_mode]); | ||
8656 | IPW_DEBUG_WX("Name: %s\n", wrqu->name); | ||
8657 | mutex_unlock(&priv->mutex); | ||
8658 | return 0; | ||
8659 | } | ||
8660 | |||
8661 | static int ipw_set_channel(struct ipw_priv *priv, u8 channel) | 8662 | static int ipw_set_channel(struct ipw_priv *priv, u8 channel) |
8662 | { | 8663 | { |
8663 | if (channel == 0) { | 8664 | if (channel == 0) { |
@@ -9957,7 +9958,7 @@ static int ipw_wx_sw_reset(struct net_device *dev, | |||
9957 | /* Rebase the WE IOCTLs to zero for the handler array */ | 9958 | /* Rebase the WE IOCTLs to zero for the handler array */ |
9958 | #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] | 9959 | #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] |
9959 | static iw_handler ipw_wx_handlers[] = { | 9960 | static iw_handler ipw_wx_handlers[] = { |
9960 | IW_IOCTL(SIOCGIWNAME) = ipw_wx_get_name, | 9961 | IW_IOCTL(SIOCGIWNAME) = (iw_handler) cfg80211_wext_giwname, |
9961 | IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, | 9962 | IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, |
9962 | IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, | 9963 | IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, |
9963 | IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, | 9964 | IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, |
@@ -11401,16 +11402,100 @@ static void ipw_bg_down(struct work_struct *work) | |||
11401 | /* Called by register_netdev() */ | 11402 | /* Called by register_netdev() */ |
11402 | static int ipw_net_init(struct net_device *dev) | 11403 | static int ipw_net_init(struct net_device *dev) |
11403 | { | 11404 | { |
11405 | int i, rc = 0; | ||
11404 | struct ipw_priv *priv = libipw_priv(dev); | 11406 | struct ipw_priv *priv = libipw_priv(dev); |
11407 | const struct libipw_geo *geo = libipw_get_geo(priv->ieee); | ||
11408 | struct wireless_dev *wdev = &priv->ieee->wdev; | ||
11405 | mutex_lock(&priv->mutex); | 11409 | mutex_lock(&priv->mutex); |
11406 | 11410 | ||
11407 | if (ipw_up(priv)) { | 11411 | if (ipw_up(priv)) { |
11408 | mutex_unlock(&priv->mutex); | 11412 | rc = -EIO; |
11409 | return -EIO; | 11413 | goto out; |
11410 | } | 11414 | } |
11411 | 11415 | ||
11416 | memcpy(wdev->wiphy->perm_addr, priv->mac_addr, ETH_ALEN); | ||
11417 | |||
11418 | /* fill-out priv->ieee->bg_band */ | ||
11419 | if (geo->bg_channels) { | ||
11420 | struct ieee80211_supported_band *bg_band = &priv->ieee->bg_band; | ||
11421 | |||
11422 | bg_band->band = IEEE80211_BAND_2GHZ; | ||
11423 | bg_band->n_channels = geo->bg_channels; | ||
11424 | bg_band->channels = | ||
11425 | kzalloc(geo->bg_channels * | ||
11426 | sizeof(struct ieee80211_channel), GFP_KERNEL); | ||
11427 | /* translate geo->bg to bg_band.channels */ | ||
11428 | for (i = 0; i < geo->bg_channels; i++) { | ||
11429 | bg_band->channels[i].band = IEEE80211_BAND_2GHZ; | ||
11430 | bg_band->channels[i].center_freq = geo->bg[i].freq; | ||
11431 | bg_band->channels[i].hw_value = geo->bg[i].channel; | ||
11432 | bg_band->channels[i].max_power = geo->bg[i].max_power; | ||
11433 | if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY) | ||
11434 | bg_band->channels[i].flags |= | ||
11435 | IEEE80211_CHAN_PASSIVE_SCAN; | ||
11436 | if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS) | ||
11437 | bg_band->channels[i].flags |= | ||
11438 | IEEE80211_CHAN_NO_IBSS; | ||
11439 | if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT) | ||
11440 | bg_band->channels[i].flags |= | ||
11441 | IEEE80211_CHAN_RADAR; | ||
11442 | /* No equivalent for LIBIPW_CH_80211H_RULES, | ||
11443 | LIBIPW_CH_UNIFORM_SPREADING, or | ||
11444 | LIBIPW_CH_B_ONLY... */ | ||
11445 | } | ||
11446 | /* point at bitrate info */ | ||
11447 | bg_band->bitrates = ipw2200_bg_rates; | ||
11448 | bg_band->n_bitrates = ipw2200_num_bg_rates; | ||
11449 | |||
11450 | wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = bg_band; | ||
11451 | } | ||
11452 | |||
11453 | /* fill-out priv->ieee->a_band */ | ||
11454 | if (geo->a_channels) { | ||
11455 | struct ieee80211_supported_band *a_band = &priv->ieee->a_band; | ||
11456 | |||
11457 | a_band->band = IEEE80211_BAND_5GHZ; | ||
11458 | a_band->n_channels = geo->a_channels; | ||
11459 | a_band->channels = | ||
11460 | kzalloc(geo->a_channels * | ||
11461 | sizeof(struct ieee80211_channel), GFP_KERNEL); | ||
11462 | /* translate geo->bg to a_band.channels */ | ||
11463 | for (i = 0; i < geo->a_channels; i++) { | ||
11464 | a_band->channels[i].band = IEEE80211_BAND_2GHZ; | ||
11465 | a_band->channels[i].center_freq = geo->a[i].freq; | ||
11466 | a_band->channels[i].hw_value = geo->a[i].channel; | ||
11467 | a_band->channels[i].max_power = geo->a[i].max_power; | ||
11468 | if (geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY) | ||
11469 | a_band->channels[i].flags |= | ||
11470 | IEEE80211_CHAN_PASSIVE_SCAN; | ||
11471 | if (geo->a[i].flags & LIBIPW_CH_NO_IBSS) | ||
11472 | a_band->channels[i].flags |= | ||
11473 | IEEE80211_CHAN_NO_IBSS; | ||
11474 | if (geo->a[i].flags & LIBIPW_CH_RADAR_DETECT) | ||
11475 | a_band->channels[i].flags |= | ||
11476 | IEEE80211_CHAN_RADAR; | ||
11477 | /* No equivalent for LIBIPW_CH_80211H_RULES, | ||
11478 | LIBIPW_CH_UNIFORM_SPREADING, or | ||
11479 | LIBIPW_CH_B_ONLY... */ | ||
11480 | } | ||
11481 | /* point at bitrate info */ | ||
11482 | a_band->bitrates = ipw2200_a_rates; | ||
11483 | a_band->n_bitrates = ipw2200_num_a_rates; | ||
11484 | |||
11485 | wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = a_band; | ||
11486 | } | ||
11487 | |||
11488 | set_wiphy_dev(wdev->wiphy, &priv->pci_dev->dev); | ||
11489 | |||
11490 | /* With that information in place, we can now register the wiphy... */ | ||
11491 | if (wiphy_register(wdev->wiphy)) { | ||
11492 | rc = -EIO; | ||
11493 | goto out; | ||
11494 | } | ||
11495 | |||
11496 | out: | ||
11412 | mutex_unlock(&priv->mutex); | 11497 | mutex_unlock(&priv->mutex); |
11413 | return 0; | 11498 | return rc; |
11414 | } | 11499 | } |
11415 | 11500 | ||
11416 | /* PCI driver stuff */ | 11501 | /* PCI driver stuff */ |
@@ -11540,7 +11625,7 @@ static int ipw_prom_alloc(struct ipw_priv *priv) | |||
11540 | if (priv->prom_net_dev) | 11625 | if (priv->prom_net_dev) |
11541 | return -EPERM; | 11626 | return -EPERM; |
11542 | 11627 | ||
11543 | priv->prom_net_dev = alloc_ieee80211(sizeof(struct ipw_prom_priv)); | 11628 | priv->prom_net_dev = alloc_ieee80211(sizeof(struct ipw_prom_priv), 1); |
11544 | if (priv->prom_net_dev == NULL) | 11629 | if (priv->prom_net_dev == NULL) |
11545 | return -ENOMEM; | 11630 | return -ENOMEM; |
11546 | 11631 | ||
@@ -11559,7 +11644,7 @@ static int ipw_prom_alloc(struct ipw_priv *priv) | |||
11559 | 11644 | ||
11560 | rc = register_netdev(priv->prom_net_dev); | 11645 | rc = register_netdev(priv->prom_net_dev); |
11561 | if (rc) { | 11646 | if (rc) { |
11562 | free_ieee80211(priv->prom_net_dev); | 11647 | free_ieee80211(priv->prom_net_dev, 1); |
11563 | priv->prom_net_dev = NULL; | 11648 | priv->prom_net_dev = NULL; |
11564 | return rc; | 11649 | return rc; |
11565 | } | 11650 | } |
@@ -11573,7 +11658,7 @@ static void ipw_prom_free(struct ipw_priv *priv) | |||
11573 | return; | 11658 | return; |
11574 | 11659 | ||
11575 | unregister_netdev(priv->prom_net_dev); | 11660 | unregister_netdev(priv->prom_net_dev); |
11576 | free_ieee80211(priv->prom_net_dev); | 11661 | free_ieee80211(priv->prom_net_dev, 1); |
11577 | 11662 | ||
11578 | priv->prom_net_dev = NULL; | 11663 | priv->prom_net_dev = NULL; |
11579 | } | 11664 | } |
@@ -11601,7 +11686,7 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev, | |||
11601 | struct ipw_priv *priv; | 11686 | struct ipw_priv *priv; |
11602 | int i; | 11687 | int i; |
11603 | 11688 | ||
11604 | net_dev = alloc_ieee80211(sizeof(struct ipw_priv)); | 11689 | net_dev = alloc_ieee80211(sizeof(struct ipw_priv), 0); |
11605 | if (net_dev == NULL) { | 11690 | if (net_dev == NULL) { |
11606 | err = -ENOMEM; | 11691 | err = -ENOMEM; |
11607 | goto out; | 11692 | goto out; |
@@ -11749,7 +11834,7 @@ static int __devinit ipw_pci_probe(struct pci_dev *pdev, | |||
11749 | pci_disable_device(pdev); | 11834 | pci_disable_device(pdev); |
11750 | pci_set_drvdata(pdev, NULL); | 11835 | pci_set_drvdata(pdev, NULL); |
11751 | out_free_ieee80211: | 11836 | out_free_ieee80211: |
11752 | free_ieee80211(priv->net_dev); | 11837 | free_ieee80211(priv->net_dev, 0); |
11753 | out: | 11838 | out: |
11754 | return err; | 11839 | return err; |
11755 | } | 11840 | } |
@@ -11816,7 +11901,7 @@ static void __devexit ipw_pci_remove(struct pci_dev *pdev) | |||
11816 | pci_release_regions(pdev); | 11901 | pci_release_regions(pdev); |
11817 | pci_disable_device(pdev); | 11902 | pci_disable_device(pdev); |
11818 | pci_set_drvdata(pdev, NULL); | 11903 | pci_set_drvdata(pdev, NULL); |
11819 | free_ieee80211(priv->net_dev); | 11904 | free_ieee80211(priv->net_dev, 0); |
11820 | free_firmware(); | 11905 | free_firmware(); |
11821 | } | 11906 | } |
11822 | 11907 | ||
diff --git a/drivers/net/wireless/ipw2x00/libipw.h b/drivers/net/wireless/ipw2x00/libipw.h index cefb94262cc2..8f91d3427ce5 100644 --- a/drivers/net/wireless/ipw2x00/libipw.h +++ b/drivers/net/wireless/ipw2x00/libipw.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/ieee80211.h> | 31 | #include <linux/ieee80211.h> |
32 | 32 | ||
33 | #include <net/lib80211.h> | 33 | #include <net/lib80211.h> |
34 | #include <net/cfg80211.h> | ||
34 | 35 | ||
35 | #define LIBIPW_VERSION "git-1.1.13" | 36 | #define LIBIPW_VERSION "git-1.1.13" |
36 | 37 | ||
@@ -783,12 +784,15 @@ struct libipw_geo { | |||
783 | 784 | ||
784 | struct libipw_device { | 785 | struct libipw_device { |
785 | struct net_device *dev; | 786 | struct net_device *dev; |
787 | struct wireless_dev wdev; | ||
786 | struct libipw_security sec; | 788 | struct libipw_security sec; |
787 | 789 | ||
788 | /* Bookkeeping structures */ | 790 | /* Bookkeeping structures */ |
789 | struct libipw_stats ieee_stats; | 791 | struct libipw_stats ieee_stats; |
790 | 792 | ||
791 | struct libipw_geo geo; | 793 | struct libipw_geo geo; |
794 | struct ieee80211_supported_band bg_band; | ||
795 | struct ieee80211_supported_band a_band; | ||
792 | 796 | ||
793 | /* Probe / Beacon management */ | 797 | /* Probe / Beacon management */ |
794 | struct list_head network_free_list; | 798 | struct list_head network_free_list; |
@@ -1014,8 +1018,8 @@ static inline int libipw_is_cck_rate(u8 rate) | |||
1014 | } | 1018 | } |
1015 | 1019 | ||
1016 | /* ieee80211.c */ | 1020 | /* ieee80211.c */ |
1017 | extern void free_ieee80211(struct net_device *dev); | 1021 | extern void free_ieee80211(struct net_device *dev, int monitor); |
1018 | extern struct net_device *alloc_ieee80211(int sizeof_priv); | 1022 | extern struct net_device *alloc_ieee80211(int sizeof_priv, int monitor); |
1019 | extern int libipw_change_mtu(struct net_device *dev, int new_mtu); | 1023 | extern int libipw_change_mtu(struct net_device *dev, int new_mtu); |
1020 | 1024 | ||
1021 | extern void libipw_networks_age(struct libipw_device *ieee, | 1025 | extern void libipw_networks_age(struct libipw_device *ieee, |
diff --git a/drivers/net/wireless/ipw2x00/libipw_module.c b/drivers/net/wireless/ipw2x00/libipw_module.c index eb2b60834c17..a0e9f6aed7da 100644 --- a/drivers/net/wireless/ipw2x00/libipw_module.c +++ b/drivers/net/wireless/ipw2x00/libipw_module.c | |||
@@ -62,6 +62,9 @@ MODULE_DESCRIPTION(DRV_DESCRIPTION); | |||
62 | MODULE_AUTHOR(DRV_COPYRIGHT); | 62 | MODULE_AUTHOR(DRV_COPYRIGHT); |
63 | MODULE_LICENSE("GPL"); | 63 | MODULE_LICENSE("GPL"); |
64 | 64 | ||
65 | struct cfg80211_ops libipw_config_ops = { }; | ||
66 | void *libipw_wiphy_privid = &libipw_wiphy_privid; | ||
67 | |||
65 | static int libipw_networks_allocate(struct libipw_device *ieee) | 68 | static int libipw_networks_allocate(struct libipw_device *ieee) |
66 | { | 69 | { |
67 | if (ieee->networks) | 70 | if (ieee->networks) |
@@ -140,7 +143,7 @@ int libipw_change_mtu(struct net_device *dev, int new_mtu) | |||
140 | } | 143 | } |
141 | EXPORT_SYMBOL(libipw_change_mtu); | 144 | EXPORT_SYMBOL(libipw_change_mtu); |
142 | 145 | ||
143 | struct net_device *alloc_ieee80211(int sizeof_priv) | 146 | struct net_device *alloc_ieee80211(int sizeof_priv, int monitor) |
144 | { | 147 | { |
145 | struct libipw_device *ieee; | 148 | struct libipw_device *ieee; |
146 | struct net_device *dev; | 149 | struct net_device *dev; |
@@ -157,10 +160,31 @@ struct net_device *alloc_ieee80211(int sizeof_priv) | |||
157 | 160 | ||
158 | ieee->dev = dev; | 161 | ieee->dev = dev; |
159 | 162 | ||
163 | if (!monitor) { | ||
164 | ieee->wdev.wiphy = wiphy_new(&libipw_config_ops, 0); | ||
165 | if (!ieee->wdev.wiphy) { | ||
166 | LIBIPW_ERROR("Unable to allocate wiphy.\n"); | ||
167 | goto failed_free_netdev; | ||
168 | } | ||
169 | |||
170 | ieee->dev->ieee80211_ptr = &ieee->wdev; | ||
171 | ieee->wdev.iftype = NL80211_IFTYPE_STATION; | ||
172 | |||
173 | /* Fill-out wiphy structure bits we know... Not enough info | ||
174 | here to call set_wiphy_dev or set MAC address or channel info | ||
175 | -- have to do that in ->ndo_init... */ | ||
176 | ieee->wdev.wiphy->privid = libipw_wiphy_privid; | ||
177 | |||
178 | ieee->wdev.wiphy->max_scan_ssids = 1; | ||
179 | ieee->wdev.wiphy->max_scan_ie_len = 0; | ||
180 | ieee->wdev.wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | ||
181 | | BIT(NL80211_IFTYPE_ADHOC); | ||
182 | } | ||
183 | |||
160 | err = libipw_networks_allocate(ieee); | 184 | err = libipw_networks_allocate(ieee); |
161 | if (err) { | 185 | if (err) { |
162 | LIBIPW_ERROR("Unable to allocate beacon storage: %d\n", err); | 186 | LIBIPW_ERROR("Unable to allocate beacon storage: %d\n", err); |
163 | goto failed_free_netdev; | 187 | goto failed_free_wiphy; |
164 | } | 188 | } |
165 | libipw_networks_initialize(ieee); | 189 | libipw_networks_initialize(ieee); |
166 | 190 | ||
@@ -193,19 +217,31 @@ struct net_device *alloc_ieee80211(int sizeof_priv) | |||
193 | 217 | ||
194 | return dev; | 218 | return dev; |
195 | 219 | ||
220 | failed_free_wiphy: | ||
221 | if (!monitor) | ||
222 | wiphy_free(ieee->wdev.wiphy); | ||
196 | failed_free_netdev: | 223 | failed_free_netdev: |
197 | free_netdev(dev); | 224 | free_netdev(dev); |
198 | failed: | 225 | failed: |
199 | return NULL; | 226 | return NULL; |
200 | } | 227 | } |
201 | 228 | ||
202 | void free_ieee80211(struct net_device *dev) | 229 | void free_ieee80211(struct net_device *dev, int monitor) |
203 | { | 230 | { |
204 | struct libipw_device *ieee = netdev_priv(dev); | 231 | struct libipw_device *ieee = netdev_priv(dev); |
205 | 232 | ||
206 | lib80211_crypt_info_free(&ieee->crypt_info); | 233 | lib80211_crypt_info_free(&ieee->crypt_info); |
207 | 234 | ||
208 | libipw_networks_free(ieee); | 235 | libipw_networks_free(ieee); |
236 | |||
237 | /* free cfg80211 resources */ | ||
238 | if (!monitor) { | ||
239 | wiphy_unregister(ieee->wdev.wiphy); | ||
240 | kfree(ieee->a_band.channels); | ||
241 | kfree(ieee->bg_band.channels); | ||
242 | wiphy_free(ieee->wdev.wiphy); | ||
243 | } | ||
244 | |||
209 | free_netdev(dev); | 245 | free_netdev(dev); |
210 | } | 246 | } |
211 | 247 | ||