Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa44327c authored by Stefano Brivio's avatar Stefano Brivio Committed by David S. Miller
Browse files

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: default avatarStefano Brivio <stefano.brivio@polimi.it>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ca5fbca9
Loading
Loading
Loading
Loading
+16 −18
Original line number Diff line number Diff line
@@ -74,29 +74,27 @@ static int rate_control_pid_shift_adjust(struct rc_pid_rateinfo *r,
{
	int i, j, k, tmp;

	if (cur + adj < 0)
		return 0;
	if (cur + adj >= l)
		return l - 1;
	j = r[cur].rev_index;
	i = j + adj;

	i = r[cur + adj].rev_index;
	if (i < 0)
		return r[0].index;
	if (i >= l - 1)
		return r[l - 1].index;

	j = r[cur].rev_index;
	tmp = i;

	if (adj < 0) {
			tmp = i;
		for (k = j; k >= i; k--)
			if (r[k].diff <= r[j].diff)
				tmp = k;
			return r[tmp].index;
	} else if (adj > 0) {
			tmp = i;
	} else {
		for (k = i + 1; k + i < l; k++)
			if (r[k].diff <= r[i].diff)
				tmp = k;
			return r[tmp].index;
	}
	return cur + adj;

	return r[tmp].index;
}

static void rate_control_pid_adjust_rate(struct ieee80211_local *local,