Commit 5a5251b8 authored by Ivan Safonov's avatar Ivan Safonov Committed by Greg Kroah-Hartman

staging:r8192u: replace request_module with try_then_request_module

Return value of request_module() does not handled,
so it is possible to use shorter try_then_request_module().
Signed-off-by: default avatarIvan Safonov <insafonov@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a7e58591
...@@ -2948,8 +2948,9 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, ...@@ -2948,8 +2948,9 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
struct ieee_param *param, int param_len) struct ieee_param *param, int param_len)
{ {
int ret = 0; int ret = 0;
const char *module = NULL;
struct ieee80211_crypto_ops *ops; struct ieee80211_crypto_ops *ops = NULL;
struct ieee80211_crypt_data **crypt; struct ieee80211_crypt_data **crypt;
struct ieee80211_security sec = { struct ieee80211_security sec = {
...@@ -2995,19 +2996,17 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, ...@@ -2995,19 +2996,17 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
strcmp(param->u.crypt.alg, "TKIP")) strcmp(param->u.crypt.alg, "TKIP"))
goto skip_host_crypt; goto skip_host_crypt;
ops = ieee80211_get_crypto_ops(param->u.crypt.alg); //set WEP40 first, it will be modified according to WEP104 or WEP40 at other place
if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { if (!strcmp(param->u.crypt.alg, "WEP"))
request_module("ieee80211_crypt_wep"); module = "ieee80211_crypt_wep";
ops = ieee80211_get_crypto_ops(param->u.crypt.alg); else if (!strcmp(param->u.crypt.alg, "TKIP"))
//set WEP40 first, it will be modified according to WEP104 or WEP40 at other place module = "ieee80211_crypt_tkip";
} else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { else if (!strcmp(param->u.crypt.alg, "CCMP"))
request_module("ieee80211_crypt_tkip"); module = "ieee80211_crypt_ccmp";
ops = ieee80211_get_crypto_ops(param->u.crypt.alg); if (module)
} else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { ops = try_then_request_module(ieee80211_get_crypto_ops(param->u.crypt.alg),
request_module("ieee80211_crypt_ccmp"); module);
ops = ieee80211_get_crypto_ops(param->u.crypt.alg); if (!ops) {
}
if (ops == NULL) {
printk("unknown crypto alg '%s'\n", param->u.crypt.alg); printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG;
ret = -EINVAL; ret = -EINVAL;
......
...@@ -364,11 +364,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, ...@@ -364,11 +364,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
GFP_KERNEL); GFP_KERNEL);
if (!new_crypt) if (!new_crypt)
return -ENOMEM; return -ENOMEM;
new_crypt->ops = ieee80211_get_crypto_ops("WEP"); new_crypt->ops = try_then_request_module(ieee80211_get_crypto_ops("WEP"),
if (!new_crypt->ops) { "ieee80211_crypt_wep");
request_module("ieee80211_crypt_wep");
new_crypt->ops = ieee80211_get_crypto_ops("WEP");
}
if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
new_crypt->priv = new_crypt->ops->init(key); new_crypt->priv = new_crypt->ops->init(key);
...@@ -591,12 +588,8 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, ...@@ -591,12 +588,8 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
} }
printk("alg name:%s\n",alg); printk("alg name:%s\n",alg);
ops = ieee80211_get_crypto_ops(alg); ops = try_then_request_module(ieee80211_get_crypto_ops(alg), module);
if (ops == NULL) { if (!ops) {
request_module(module);
ops = ieee80211_get_crypto_ops(alg);
}
if (ops == NULL) {
IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n",
dev->name, ext->alg); dev->name, ext->alg);
printk("========>unknown crypto alg %d\n", ext->alg); printk("========>unknown crypto alg %d\n", ext->alg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment