mt76: unify channel survey update code

Host time is used to calculate the channel active time on mt7603 and mt7615.
Use the same on mt76x02 and move the lock to core code to get rid of some
duplicated code.

Signed-off-by: Felix Fietkau <[email protected]>
This commit is contained in:
Felix Fietkau
2019-09-26 14:59:06 +02:00
parent fdf0163fd1
commit de118bb403
8 changed files with 33 additions and 52 deletions
+1 -14
View File
@@ -1571,22 +1571,9 @@ void mt7603_update_channel(struct mt76_dev *mdev)
{
struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
struct mt76_channel_state *state;
ktime_t cur_time;
u32 busy;
if (!test_bit(MT76_STATE_RUNNING, &dev->mt76.state))
return;
state = mdev->chan_state;
busy = mt76_rr(dev, MT_MIB_STAT_CCA);
spin_lock_bh(&dev->mt76.cc_lock);
cur_time = ktime_get_boottime();
state->cc_busy += busy;
state->cc_active += ktime_to_us(ktime_sub(cur_time,
dev->mt76.survey_time));
dev->mt76.survey_time = cur_time;
spin_unlock_bh(&dev->mt76.cc_lock);
state->cc_busy += mt76_rr(dev, MT_MIB_STAT_CCA);
}
void