From: Peng Fan 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 --- net/mac80211/agg-tx.c | 5 +---- net/mac80211/rx.c | 5 +---- net/mac80211/tests/chan-mode.c | 6 ++---- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c index ce9fb19d8c18..f3ecdd8601a0 100644 --- a/net/mac80211/agg-tx.c +++ b/net/mac80211/agg-tx.c @@ -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(); diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index d6755a4c7d3c..b3990b7a7299 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -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); diff --git a/net/mac80211/tests/chan-mode.c b/net/mac80211/tests/chan-mode.c index ab7d38ef6a3a..85dc87215d23 100644 --- a/net/mac80211/tests/chan-mode.c +++ b/net/mac80211/tests/chan-mode.c @@ -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; -- 2.51.0