summaryrefslogtreecommitdiff
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 cf21f0bd856..a2f5616d5b0 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)
spin_lock_init(&ieee->lock);
- ieee->crypt_info.name = dev->name;
- ieee->crypt_info.lock = &ieee->lock;
- INIT_LIST_HEAD(&ieee->crypt_info.crypt_deinit_list);
- setup_timer(&ieee->crypt_info.crypt_deinit_timer,
- lib80211_crypt_deinit_handler,
- (unsigned long)&ieee->crypt_info);
- ieee->crypt_info.crypt_quiesced = 0;
+ lib80211_crypt_info_init(&ieee->crypt_info, dev->name, &ieee->lock);
ieee->wpa_enabled = 0;
ieee->drop_unencrypted = 0;
@@ -206,23 +200,7 @@ void free_ieee80211(struct net_device *dev)
{
struct ieee80211_device *ieee = netdev_priv(dev);
- int i;
-
- lib80211_crypt_quiescing(&ieee->crypt_info);
- del_timer_sync(&ieee->crypt_info.crypt_deinit_timer);
- lib80211_crypt_deinit_entries(&ieee->crypt_info, 1);
-
- for (i = 0; i < WEP_KEYS; i++) {
- struct lib80211_crypt_data *crypt = ieee->crypt_info.crypt[i];
- if (crypt) {
- if (crypt->ops) {
- crypt->ops->deinit(crypt->priv);
- module_put(crypt->ops->owner);
- }
- kfree(crypt);
- ieee->crypt_info.crypt[i] = NULL;
- }
- }
+ lib80211_crypt_info_free(&ieee->crypt_info);
ieee80211_networks_free(ieee);
free_netdev(dev);
diff --git a/net/wireless/lib80211.c b/net/wireless/lib80211.c
index d681721f4ac..97d411f7450 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)
}
EXPORT_SYMBOL(print_ssid);
+int lib80211_crypt_info_init(struct lib80211_crypt_info *info, char *name,
+ spinlock_t *lock)
+{
+ memset(info, 0, sizeof(*info));
+
+ info->name = name;
+ info->lock = lock;
+
+ INIT_LIST_HEAD(&info->crypt_deinit_list);
+ setup_timer(&info->crypt_deinit_timer, lib80211_crypt_deinit_handler,
+ (unsigned long)info);
+
+ return 0;
+}
+EXPORT_SYMBOL(lib80211_crypt_info_init);
+
+void lib80211_crypt_info_free(struct lib80211_crypt_info *info)
+{
+ int i;
+
+ lib80211_crypt_quiescing(info);
+ del_timer_sync(&info->crypt_deinit_timer);
+ lib80211_crypt_deinit_entries(info, 1);
+
+ for (i = 0; i < NUM_WEP_KEYS; i++) {
+ struct lib80211_crypt_data *crypt = info->crypt[i];
+ if (crypt) {
+ if (crypt->ops) {
+ crypt->ops->deinit(crypt->priv);
+ module_put(crypt->ops->owner);
+ }
+ kfree(crypt);
+ info->crypt[i] = NULL;
+ }
+ }
+}
+EXPORT_SYMBOL(lib80211_crypt_info_free);
+
void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *info, int force)
{
struct lib80211_crypt_data *entry, *next;