diff options
author | John W. Linville <linville@tuxdriver.com> | 2008-11-11 16:00:06 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-11-21 11:08:17 -0500 |
commit | 2ba4b32ecf748d5f45f298fc9677fa46d1dd9aff (patch) | |
tree | ebdf68be060014d9f5c799cf1cb54462bc896140 /drivers/net/wireless/hostap | |
parent | 274bfb8dc5ffa16cb073801bebe76ab7f4e2e73d (diff) |
lib80211: consolidate crypt init routines
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/hostap')
-rw-r--r-- | drivers/net/wireless/hostap/hostap_hw.c | 61 | ||||
-rw-r--r-- | drivers/net/wireless/hostap/hostap_ioctl.c | 43 |
2 files changed, 11 insertions, 93 deletions
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c index 066299fc9259..0f27059bbe85 100644 --- a/drivers/net/wireless/hostap/hostap_hw.c +++ b/drivers/net/wireless/hostap/hostap_hw.c | |||
@@ -2788,46 +2788,6 @@ static void prism2_check_sta_fw_version(local_info_t *local) | |||
2788 | } | 2788 | } |
2789 | 2789 | ||
2790 | 2790 | ||
2791 | static void prism2_crypt_deinit_entries(local_info_t *local, int force) | ||
2792 | { | ||
2793 | struct list_head *ptr, *n; | ||
2794 | struct lib80211_crypt_data *entry; | ||
2795 | |||
2796 | for (ptr = local->crypt_info.crypt_deinit_list.next, n = ptr->next; | ||
2797 | ptr != &local->crypt_info.crypt_deinit_list; | ||
2798 | ptr = n, n = ptr->next) { | ||
2799 | entry = list_entry(ptr, struct lib80211_crypt_data, list); | ||
2800 | |||
2801 | if (atomic_read(&entry->refcnt) != 0 && !force) | ||
2802 | continue; | ||
2803 | |||
2804 | list_del(ptr); | ||
2805 | |||
2806 | if (entry->ops) | ||
2807 | entry->ops->deinit(entry->priv); | ||
2808 | kfree(entry); | ||
2809 | } | ||
2810 | } | ||
2811 | |||
2812 | |||
2813 | static void prism2_crypt_deinit_handler(unsigned long data) | ||
2814 | { | ||
2815 | local_info_t *local = (local_info_t *) data; | ||
2816 | unsigned long flags; | ||
2817 | |||
2818 | spin_lock_irqsave(&local->lock, flags); | ||
2819 | prism2_crypt_deinit_entries(local, 0); | ||
2820 | if (!list_empty(&local->crypt_info.crypt_deinit_list)) { | ||
2821 | printk(KERN_DEBUG "%s: entries remaining in delayed crypt " | ||
2822 | "deletion list\n", local->dev->name); | ||
2823 | local->crypt_info.crypt_deinit_timer.expires = jiffies + HZ; | ||
2824 | add_timer(&local->crypt_info.crypt_deinit_timer); | ||
2825 | } | ||
2826 | spin_unlock_irqrestore(&local->lock, flags); | ||
2827 | |||
2828 | } | ||
2829 | |||
2830 | |||
2831 | static void hostap_passive_scan(unsigned long data) | 2791 | static void hostap_passive_scan(unsigned long data) |
2832 | { | 2792 | { |
2833 | local_info_t *local = (local_info_t *) data; | 2793 | local_info_t *local = (local_info_t *) data; |
@@ -3252,12 +3212,7 @@ while (0) | |||
3252 | INIT_LIST_HEAD(&local->cmd_queue); | 3212 | INIT_LIST_HEAD(&local->cmd_queue); |
3253 | init_waitqueue_head(&local->hostscan_wq); | 3213 | init_waitqueue_head(&local->hostscan_wq); |
3254 | 3214 | ||
3255 | local->crypt_info.name = dev->name; | 3215 | lib80211_crypt_info_init(&local->crypt_info, dev->name, &local->lock); |
3256 | local->crypt_info.lock = &local->lock; | ||
3257 | INIT_LIST_HEAD(&local->crypt_info.crypt_deinit_list); | ||
3258 | init_timer(&local->crypt_info.crypt_deinit_timer); | ||
3259 | local->crypt_info.crypt_deinit_timer.data = (unsigned long) local; | ||
3260 | local->crypt_info.crypt_deinit_timer.function = prism2_crypt_deinit_handler; | ||
3261 | 3216 | ||
3262 | init_timer(&local->passive_scan_timer); | 3217 | init_timer(&local->passive_scan_timer); |
3263 | local->passive_scan_timer.data = (unsigned long) local; | 3218 | local->passive_scan_timer.data = (unsigned long) local; |
@@ -3358,9 +3313,7 @@ static void prism2_free_local_data(struct net_device *dev) | |||
3358 | 3313 | ||
3359 | flush_scheduled_work(); | 3314 | flush_scheduled_work(); |
3360 | 3315 | ||
3361 | if (timer_pending(&local->crypt_info.crypt_deinit_timer)) | 3316 | lib80211_crypt_info_free(&local->crypt_info); |
3362 | del_timer(&local->crypt_info.crypt_deinit_timer); | ||
3363 | prism2_crypt_deinit_entries(local, 1); | ||
3364 | 3317 | ||
3365 | if (timer_pending(&local->passive_scan_timer)) | 3318 | if (timer_pending(&local->passive_scan_timer)) |
3366 | del_timer(&local->passive_scan_timer); | 3319 | del_timer(&local->passive_scan_timer); |
@@ -3377,16 +3330,6 @@ static void prism2_free_local_data(struct net_device *dev) | |||
3377 | if (local->dev_enabled) | 3330 | if (local->dev_enabled) |
3378 | prism2_callback(local, PRISM2_CALLBACK_DISABLE); | 3331 | prism2_callback(local, PRISM2_CALLBACK_DISABLE); |
3379 | 3332 | ||
3380 | for (i = 0; i < WEP_KEYS; i++) { | ||
3381 | struct lib80211_crypt_data *crypt = local->crypt_info.crypt[i]; | ||
3382 | if (crypt) { | ||
3383 | if (crypt->ops) | ||
3384 | crypt->ops->deinit(crypt->priv); | ||
3385 | kfree(crypt); | ||
3386 | local->crypt_info.crypt[i] = NULL; | ||
3387 | } | ||
3388 | } | ||
3389 | |||
3390 | if (local->ap != NULL) | 3333 | if (local->ap != NULL) |
3391 | hostap_free_data(local->ap); | 3334 | hostap_free_data(local->ap); |
3392 | 3335 | ||
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index 29aebb679099..c40fdf4c79de 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c | |||
@@ -116,32 +116,6 @@ static int prism2_get_name(struct net_device *dev, | |||
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | static void prism2_crypt_delayed_deinit(local_info_t *local, | ||
120 | struct lib80211_crypt_data **crypt) | ||
121 | { | ||
122 | struct lib80211_crypt_data *tmp; | ||
123 | unsigned long flags; | ||
124 | |||
125 | tmp = *crypt; | ||
126 | *crypt = NULL; | ||
127 | |||
128 | if (tmp == NULL) | ||
129 | return; | ||
130 | |||
131 | /* must not run ops->deinit() while there may be pending encrypt or | ||
132 | * decrypt operations. Use a list of delayed deinits to avoid needing | ||
133 | * locking. */ | ||
134 | |||
135 | spin_lock_irqsave(&local->lock, flags); | ||
136 | list_add(&tmp->list, &local->crypt_info.crypt_deinit_list); | ||
137 | if (!timer_pending(&local->crypt_info.crypt_deinit_timer)) { | ||
138 | local->crypt_info.crypt_deinit_timer.expires = jiffies + HZ; | ||
139 | add_timer(&local->crypt_info.crypt_deinit_timer); | ||
140 | } | ||
141 | spin_unlock_irqrestore(&local->lock, flags); | ||
142 | } | ||
143 | |||
144 | |||
145 | static int prism2_ioctl_siwencode(struct net_device *dev, | 119 | static int prism2_ioctl_siwencode(struct net_device *dev, |
146 | struct iw_request_info *info, | 120 | struct iw_request_info *info, |
147 | struct iw_point *erq, char *keybuf) | 121 | struct iw_point *erq, char *keybuf) |
@@ -166,14 +140,14 @@ static int prism2_ioctl_siwencode(struct net_device *dev, | |||
166 | 140 | ||
167 | if (erq->flags & IW_ENCODE_DISABLED) { | 141 | if (erq->flags & IW_ENCODE_DISABLED) { |
168 | if (*crypt) | 142 | if (*crypt) |
169 | prism2_crypt_delayed_deinit(local, crypt); | 143 | lib80211_crypt_delayed_deinit(&local->crypt_info, crypt); |
170 | goto done; | 144 | goto done; |
171 | } | 145 | } |
172 | 146 | ||
173 | if (*crypt != NULL && (*crypt)->ops != NULL && | 147 | if (*crypt != NULL && (*crypt)->ops != NULL && |
174 | strcmp((*crypt)->ops->name, "WEP") != 0) { | 148 | strcmp((*crypt)->ops->name, "WEP") != 0) { |
175 | /* changing to use WEP; deinit previously used algorithm */ | 149 | /* changing to use WEP; deinit previously used algorithm */ |
176 | prism2_crypt_delayed_deinit(local, crypt); | 150 | lib80211_crypt_delayed_deinit(&local->crypt_info, crypt); |
177 | } | 151 | } |
178 | 152 | ||
179 | if (*crypt == NULL) { | 153 | if (*crypt == NULL) { |
@@ -189,7 +163,7 @@ static int prism2_ioctl_siwencode(struct net_device *dev, | |||
189 | request_module("lib80211_crypt_wep"); | 163 | request_module("lib80211_crypt_wep"); |
190 | new_crypt->ops = lib80211_get_crypto_ops("WEP"); | 164 | new_crypt->ops = lib80211_get_crypto_ops("WEP"); |
191 | } | 165 | } |
192 | if (new_crypt->ops) | 166 | if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) |
193 | new_crypt->priv = new_crypt->ops->init(i); | 167 | new_crypt->priv = new_crypt->ops->init(i); |
194 | if (!new_crypt->ops || !new_crypt->priv) { | 168 | if (!new_crypt->ops || !new_crypt->priv) { |
195 | kfree(new_crypt); | 169 | kfree(new_crypt); |
@@ -3269,7 +3243,7 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev, | |||
3269 | if ((erq->flags & IW_ENCODE_DISABLED) || | 3243 | if ((erq->flags & IW_ENCODE_DISABLED) || |
3270 | ext->alg == IW_ENCODE_ALG_NONE) { | 3244 | ext->alg == IW_ENCODE_ALG_NONE) { |
3271 | if (*crypt) | 3245 | if (*crypt) |
3272 | prism2_crypt_delayed_deinit(local, crypt); | 3246 | lib80211_crypt_delayed_deinit(&local->crypt_info, crypt); |
3273 | goto done; | 3247 | goto done; |
3274 | } | 3248 | } |
3275 | 3249 | ||
@@ -3317,7 +3291,7 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev, | |||
3317 | if (*crypt == NULL || (*crypt)->ops != ops) { | 3291 | if (*crypt == NULL || (*crypt)->ops != ops) { |
3318 | struct lib80211_crypt_data *new_crypt; | 3292 | struct lib80211_crypt_data *new_crypt; |
3319 | 3293 | ||
3320 | prism2_crypt_delayed_deinit(local, crypt); | 3294 | lib80211_crypt_delayed_deinit(&local->crypt_info, crypt); |
3321 | 3295 | ||
3322 | new_crypt = kzalloc(sizeof(struct lib80211_crypt_data), | 3296 | new_crypt = kzalloc(sizeof(struct lib80211_crypt_data), |
3323 | GFP_KERNEL); | 3297 | GFP_KERNEL); |
@@ -3326,7 +3300,8 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev, | |||
3326 | goto done; | 3300 | goto done; |
3327 | } | 3301 | } |
3328 | new_crypt->ops = ops; | 3302 | new_crypt->ops = ops; |
3329 | new_crypt->priv = new_crypt->ops->init(i); | 3303 | if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) |
3304 | new_crypt->priv = new_crypt->ops->init(i); | ||
3330 | if (new_crypt->priv == NULL) { | 3305 | if (new_crypt->priv == NULL) { |
3331 | kfree(new_crypt); | 3306 | kfree(new_crypt); |
3332 | ret = -EINVAL; | 3307 | ret = -EINVAL; |
@@ -3503,7 +3478,7 @@ static int prism2_ioctl_set_encryption(local_info_t *local, | |||
3503 | 3478 | ||
3504 | if (strcmp(param->u.crypt.alg, "none") == 0) { | 3479 | if (strcmp(param->u.crypt.alg, "none") == 0) { |
3505 | if (crypt) | 3480 | if (crypt) |
3506 | prism2_crypt_delayed_deinit(local, crypt); | 3481 | lib80211_crypt_delayed_deinit(&local->crypt_info, crypt); |
3507 | goto done; | 3482 | goto done; |
3508 | } | 3483 | } |
3509 | 3484 | ||
@@ -3533,7 +3508,7 @@ static int prism2_ioctl_set_encryption(local_info_t *local, | |||
3533 | if (*crypt == NULL || (*crypt)->ops != ops) { | 3508 | if (*crypt == NULL || (*crypt)->ops != ops) { |
3534 | struct lib80211_crypt_data *new_crypt; | 3509 | struct lib80211_crypt_data *new_crypt; |
3535 | 3510 | ||
3536 | prism2_crypt_delayed_deinit(local, crypt); | 3511 | lib80211_crypt_delayed_deinit(&local->crypt_info, crypt); |
3537 | 3512 | ||
3538 | new_crypt = kzalloc(sizeof(struct lib80211_crypt_data), | 3513 | new_crypt = kzalloc(sizeof(struct lib80211_crypt_data), |
3539 | GFP_KERNEL); | 3514 | GFP_KERNEL); |