diff options
author | Stefano Brivio <stefano.brivio@polimi.it> | 2007-12-22 22:41:19 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:00:52 -0500 |
commit | fa44327c06492c9bd625dbc8dbe35e5d5965fec6 (patch) | |
tree | f13a2e0faf5b15457d125461495561da017c84c2 /net/mac80211 | |
parent | ca5fbca924b845863ab9da00ac90b3384445f497 (diff) |
rc80211-pid: simplify and fix shift_adjust
Simplify and fix rate_control_pid_shift_adjust(). A bug prevented correct
mapping of sorted rates, and readability was seriously flawed.
Signed-off-by: Stefano Brivio <stefano.brivio@polimi.it>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/rc80211_pid_algo.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/net/mac80211/rc80211_pid_algo.c b/net/mac80211/rc80211_pid_algo.c index b84e51480c84..3e26280d3142 100644 --- a/net/mac80211/rc80211_pid_algo.c +++ b/net/mac80211/rc80211_pid_algo.c | |||
@@ -74,29 +74,27 @@ static int rate_control_pid_shift_adjust(struct rc_pid_rateinfo *r, | |||
74 | { | 74 | { |
75 | int i, j, k, tmp; | 75 | int i, j, k, tmp; |
76 | 76 | ||
77 | if (cur + adj < 0) | 77 | j = r[cur].rev_index; |
78 | return 0; | 78 | i = j + adj; |
79 | if (cur + adj >= l) | ||
80 | return l - 1; | ||
81 | 79 | ||
82 | i = r[cur + adj].rev_index; | 80 | if (i < 0) |
81 | return r[0].index; | ||
82 | if (i >= l - 1) | ||
83 | return r[l - 1].index; | ||
83 | 84 | ||
84 | j = r[cur].rev_index; | 85 | tmp = i; |
85 | 86 | ||
86 | if (adj < 0) { | 87 | if (adj < 0) { |
87 | tmp = i; | 88 | for (k = j; k >= i; k--) |
88 | for (k = j; k >= i; k--) | 89 | if (r[k].diff <= r[j].diff) |
89 | if (r[k].diff <= r[j].diff) | 90 | tmp = k; |
90 | tmp = k; | 91 | } else { |
91 | return r[tmp].index; | 92 | for (k = i + 1; k + i < l; k++) |
92 | } else if (adj > 0) { | 93 | if (r[k].diff <= r[i].diff) |
93 | tmp = i; | 94 | tmp = k; |
94 | for (k = i + 1; k + i < l; k++) | ||
95 | if (r[k].diff <= r[i].diff) | ||
96 | tmp = k; | ||
97 | return r[tmp].index; | ||
98 | } | 95 | } |
99 | return cur + adj; | 96 | |
97 | return r[tmp].index; | ||
100 | } | 98 | } |
101 | 99 | ||
102 | static void rate_control_pid_adjust_rate(struct ieee80211_local *local, | 100 | static void rate_control_pid_adjust_rate(struct ieee80211_local *local, |