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

Commit 64abd803 authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville
Browse files

rt2x00: Fix SW antenna diversity



Software antenna tuning is broken because of an function
ordering problem during rt2x00link_tuner().

rt2x00link_precalculate_signal()
rt2x00leds_led_quality()
rt2x00lib_antenna_diversity()

rt2x00link_precalculate_signal() will reset the quality TX/RX counters,
however rt2x00lib_antenna_diversity() requires the RX counter to
see what RSSI value must be used for a particular antenna.
We can't change the ordering since rt2x00lib_antenna_diversity() might
reset other statistics which are needed by the function called earlier.

Move the reset of the quality TX/RX counters into a seperate function
and move the call to after rt2x00lib_antenna_diversity().

Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 14d2aac5
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -302,11 +302,6 @@ static void rt2x00link_precalculate_signal(struct rt2x00_dev *rt2x00dev)
	    PERCENTAGE(qual->rx_success, qual->rx_failed + qual->rx_success);
	link->tx_percentage =
	    PERCENTAGE(qual->tx_success, qual->tx_failed + qual->tx_success);

	qual->rx_success = 0;
	qual->rx_failed = 0;
	qual->tx_success = 0;
	qual->tx_failed = 0;
}

int rt2x00link_calculate_signal(struct rt2x00_dev *rt2x00dev, int rssi)
@@ -392,6 +387,16 @@ void rt2x00link_reset_tuner(struct rt2x00_dev *rt2x00dev, bool antenna)
		rt2x00link_antenna_reset(rt2x00dev);
}

void rt2x00link_reset_qual(struct rt2x00_dev *rt2x00dev)
{
	struct link_qual *qual = &rt2x00dev->link.qual;

	qual->rx_success = 0;
	qual->rx_failed = 0;
	qual->tx_success = 0;
	qual->tx_failed = 0;
}

static void rt2x00link_tuner(struct work_struct *work)
{
	struct rt2x00_dev *rt2x00dev =
@@ -447,6 +452,11 @@ static void rt2x00link_tuner(struct work_struct *work)
	 */
	rt2x00lib_antenna_diversity(rt2x00dev);

	/*
	 * Reset the quality counters which recounted during each period.
	 */
	rt2x00link_reset_qual(rt2x00dev);

	/*
	 * Increase tuner counter, and reschedule the next link tuner run.
	 */