wifi: mac80211: use assign_bit() where applicable

Convert open-coded if/else with set_bit/clear_bit the assign_bit API.

Done with Coccinelle semantic patch:
    // set_bit -> clear_bit => assign_bit

    @@
    expression cond, bit, addr;
    @@

    -if (cond)
    -        set_bit(bit, addr);
    -else
    -        clear_bit(bit, addr);
    +assign_bit(bit, addr, cond);

    @@
    expression cond, bit, addr;
    @@

    -if (cond)
    -        clear_bit(bit, addr);
    -else
    -        set_bit(bit, addr);
    +assign_bit(bit, addr, !cond);

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://patch.msgid.link/20260920022822.3145944-1-peng.fan@oss.nxp.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Peng Fan 2026-09-20 10:28:18 +08:00 committed by Johannes Berg
parent 8e74ad5b2a
commit 8a673c8944
3 changed files with 4 additions and 12 deletions

View File

@ -212,10 +212,7 @@ ieee80211_agg_start_txq(struct sta_info *sta, int tid, bool enable)
txqi = to_txq_info(txq);
if (enable)
set_bit(IEEE80211_TXQ_AMPDU, &txqi->flags);
else
clear_bit(IEEE80211_TXQ_AMPDU, &txqi->flags);
assign_bit(IEEE80211_TXQ_AMPDU, &txqi->flags, enable);
clear_bit(IEEE80211_TXQ_STOP, &txqi->flags);
local_bh_disable();

View File

@ -1692,10 +1692,7 @@ static void sta_ps_start(struct sta_info *sta)
list_del_init(&txqi->schedule_order);
spin_unlock(&local->active_txq_lock[txq->ac]);
if (txq_has_queue(txq))
set_bit(tid, &sta->txq_buffered_tids);
else
clear_bit(tid, &sta->txq_buffered_tids);
assign_bit(tid, &sta->txq_buffered_tids, txq_has_queue(txq));
}
sta_info_recalc_tim(sta);

View File

@ -219,10 +219,8 @@ static void test_determine_chan_mode(struct kunit *test)
/* To force EHT downgrade to HE on punctured 80 MHz downgraded to 40 MHz */
set_bit(IEEE80211_HW_DISALLOW_PUNCTURING, t_sdata->local.hw.flags);
if (params->strict)
set_bit(IEEE80211_HW_STRICT, t_sdata->local.hw.flags);
else
clear_bit(IEEE80211_HW_STRICT, t_sdata->local.hw.flags);
assign_bit(IEEE80211_HW_STRICT, t_sdata->local.hw.flags,
params->strict);
t_sdata->sdata->u.mgd.ht_capa_mask = params->ht_capa_mask;
t_sdata->sdata->u.mgd.vht_capa = params->vht_capa;