aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2008-11-11 16:00:06 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-11-21 11:08:17 -0500
commit2ba4b32ecf748d5f45f298fc9677fa46d1dd9aff (patch)
treeebdf68be060014d9f5c799cf1cb54462bc896140 /net
parent274bfb8dc5ffa16cb073801bebe76ab7f4e2e73d (diff)
lib80211: consolidate crypt init routines
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net')
-rw-r--r--net/ieee80211/ieee80211_module.c26
-rw-r--r--net/wireless/lib80211.c38
2 files changed, 40 insertions, 24 deletions
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
index cf21f0bd8569..a2f5616d5b09 100644
--- a/net/ieee80211/ieee80211_module.c
+++ b/net/ieee80211/ieee80211_module.c
@@ -182,13 +182,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
182 182
183 spin_lock_init(&ieee->lock); 183 spin_lock_init(&ieee->lock);
184 184
185 ieee->crypt_info.name = dev->name; 185 lib80211_crypt_info_init(&ieee->crypt_info, dev->name, &ieee->lock);
186 ieee->crypt_info.lock = &ieee->lock;
187 INIT_LIST_HEAD(&ieee->crypt_info.crypt_deinit_list);
188 setup_timer(&ieee->crypt_info.crypt_deinit_timer,
189 lib80211_crypt_deinit_handler,
190 (unsigned long)&ieee->crypt_info);
191 ieee->crypt_info.crypt_quiesced = 0;
192 186
193 ieee->wpa_enabled = 0; 187 ieee->wpa_enabled = 0;
194 ieee->drop_unencrypted = 0; 188 ieee->drop_unencrypted = 0;
@@ -206,23 +200,7 @@ void free_ieee80211(struct net_device *dev)
206{ 200{
207 struct ieee80211_device *ieee = netdev_priv(dev); 201 struct ieee80211_device *ieee = netdev_priv(dev);
208 202
209 int i; 203 lib80211_crypt_info_free(&ieee->crypt_info);
210
211 lib80211_crypt_quiescing(&ieee->crypt_info);
212 del_timer_sync(&ieee->crypt_info.crypt_deinit_timer);
213 lib80211_crypt_deinit_entries(&ieee->crypt_info, 1);
214
215 for (i = 0; i < WEP_KEYS; i++) {
216 struct lib80211_crypt_data *crypt = ieee->crypt_info.crypt[i];
217 if (crypt) {
218 if (crypt->ops) {
219 crypt->ops->deinit(crypt->priv);
220 module_put(crypt->ops->owner);
221 }
222 kfree(crypt);
223 ieee->crypt_info.crypt[i] = NULL;
224 }
225 }
226 204
227 ieee80211_networks_free(ieee); 205 ieee80211_networks_free(ieee);
228 free_netdev(dev); 206 free_netdev(dev);
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
index d681721f4acb..97d411f74507 100644
--- a/net/wireless/lib80211.c
+++ b/net/wireless/lib80211.c
@@ -71,6 +71,44 @@ const char *print_ssid(char *buf, const char *ssid, u8 ssid_len)
71} 71}
72EXPORT_SYMBOL(print_ssid); 72EXPORT_SYMBOL(print_ssid);
73 73
74int lib80211_crypt_info_init(struct lib80211_crypt_info *info, char *name,
75 spinlock_t *lock)
76{
77 memset(info, 0, sizeof(*info));
78
79 info->name = name;
80 info->lock = lock;
81
82 INIT_LIST_HEAD(&info->crypt_deinit_list);
83 setup_timer(&info->crypt_deinit_timer, lib80211_crypt_deinit_handler,
84 (unsigned long)info);
85
86 return 0;
87}
88EXPORT_SYMBOL(lib80211_crypt_info_init);
89
90void lib80211_crypt_info_free(struct lib80211_crypt_info *info)
91{
92 int i;
93
94 lib80211_crypt_quiescing(info);
95 del_timer_sync(&info->crypt_deinit_timer);
96 lib80211_crypt_deinit_entries(info, 1);
97
98 for (i = 0; i < NUM_WEP_KEYS; i++) {
99 struct lib80211_crypt_data *crypt = info->crypt[i];
100 if (crypt) {
101 if (crypt->ops) {
102 crypt->ops->deinit(crypt->priv);
103 module_put(crypt->ops->owner);
104 }
105 kfree(crypt);
106 info->crypt[i] = NULL;
107 }
108 }
109}
110EXPORT_SYMBOL(lib80211_crypt_info_free);
111
74void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info, int force) 112void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info, int force)
75{ 113{
76 struct lib80211_crypt_data *entry, *next; 114 struct lib80211_crypt_data *entry, *next;