diff options
Diffstat (limited to 'net/mac80211/ieee80211_rate.c')
| -rw-r--r-- | net/mac80211/ieee80211_rate.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/net/mac80211/ieee80211_rate.c b/net/mac80211/ieee80211_rate.c index 93abb8fff141..7254bd609839 100644 --- a/net/mac80211/ieee80211_rate.c +++ b/net/mac80211/ieee80211_rate.c | |||
| @@ -25,13 +25,25 @@ int ieee80211_rate_control_register(struct rate_control_ops *ops) | |||
| 25 | { | 25 | { |
| 26 | struct rate_control_alg *alg; | 26 | struct rate_control_alg *alg; |
| 27 | 27 | ||
| 28 | if (!ops->name) | ||
| 29 | return -EINVAL; | ||
| 30 | |||
| 31 | mutex_lock(&rate_ctrl_mutex); | ||
| 32 | list_for_each_entry(alg, &rate_ctrl_algs, list) { | ||
| 33 | if (!strcmp(alg->ops->name, ops->name)) { | ||
| 34 | /* don't register an algorithm twice */ | ||
| 35 | WARN_ON(1); | ||
| 36 | return -EALREADY; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 28 | alg = kzalloc(sizeof(*alg), GFP_KERNEL); | 40 | alg = kzalloc(sizeof(*alg), GFP_KERNEL); |
| 29 | if (alg == NULL) { | 41 | if (alg == NULL) { |
| 42 | mutex_unlock(&rate_ctrl_mutex); | ||
| 30 | return -ENOMEM; | 43 | return -ENOMEM; |
| 31 | } | 44 | } |
| 32 | alg->ops = ops; | 45 | alg->ops = ops; |
| 33 | 46 | ||
| 34 | mutex_lock(&rate_ctrl_mutex); | ||
| 35 | list_add_tail(&alg->list, &rate_ctrl_algs); | 47 | list_add_tail(&alg->list, &rate_ctrl_algs); |
| 36 | mutex_unlock(&rate_ctrl_mutex); | 48 | mutex_unlock(&rate_ctrl_mutex); |
| 37 | 49 | ||
| @@ -61,9 +73,12 @@ ieee80211_try_rate_control_ops_get(const char *name) | |||
| 61 | struct rate_control_alg *alg; | 73 | struct rate_control_alg *alg; |
| 62 | struct rate_control_ops *ops = NULL; | 74 | struct rate_control_ops *ops = NULL; |
| 63 | 75 | ||
| 76 | if (!name) | ||
| 77 | return NULL; | ||
| 78 | |||
| 64 | mutex_lock(&rate_ctrl_mutex); | 79 | mutex_lock(&rate_ctrl_mutex); |
| 65 | list_for_each_entry(alg, &rate_ctrl_algs, list) { | 80 | list_for_each_entry(alg, &rate_ctrl_algs, list) { |
| 66 | if (!name || !strcmp(alg->ops->name, name)) | 81 | if (!strcmp(alg->ops->name, name)) |
| 67 | if (try_module_get(alg->ops->module)) { | 82 | if (try_module_get(alg->ops->module)) { |
| 68 | ops = alg->ops; | 83 | ops = alg->ops; |
| 69 | break; | 84 | break; |
| @@ -80,9 +95,12 @@ ieee80211_rate_control_ops_get(const char *name) | |||
| 80 | { | 95 | { |
| 81 | struct rate_control_ops *ops; | 96 | struct rate_control_ops *ops; |
| 82 | 97 | ||
| 98 | if (!name) | ||
| 99 | name = "simple"; | ||
| 100 | |||
| 83 | ops = ieee80211_try_rate_control_ops_get(name); | 101 | ops = ieee80211_try_rate_control_ops_get(name); |
| 84 | if (!ops) { | 102 | if (!ops) { |
| 85 | request_module("rc80211_%s", name ? name : "default"); | 103 | request_module("rc80211_%s", name); |
| 86 | ops = ieee80211_try_rate_control_ops_get(name); | 104 | ops = ieee80211_try_rate_control_ops_get(name); |
| 87 | } | 105 | } |
| 88 | return ops; | 106 | return ops; |
