Search Linux Wireless

[PATCH v2 38/55] staging: wfx: prefer a bitmask instead of an array of boolean

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jérôme Pouiller <jerome.pouiller@xxxxxxxxxx>

It is easier to manipulate a int than an array of booleans.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@xxxxxxxxxx>
---
 drivers/staging/wfx/sta.c | 17 +++++++----------
 drivers/staging/wfx/sta.h |  2 +-
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 045d3916ada8..e59560f499ea 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -119,22 +119,22 @@ static int wfx_set_uapsd_param(struct wfx_vif *wvif,
 	 *  VO [0,3], VI [1, 2], BE [2, 1], BK [3, 0]
 	 */
 
-	if (arg->uapsd_enable[IEEE80211_AC_VO])
+	if (arg->uapsd_mask & BIT(IEEE80211_AC_VO))
 		wvif->uapsd_info.trig_voice = 1;
 	else
 		wvif->uapsd_info.trig_voice = 0;
 
-	if (arg->uapsd_enable[IEEE80211_AC_VI])
+	if (arg->uapsd_mask & BIT(IEEE80211_AC_VI))
 		wvif->uapsd_info.trig_video = 1;
 	else
 		wvif->uapsd_info.trig_video = 0;
 
-	if (arg->uapsd_enable[IEEE80211_AC_BE])
+	if (arg->uapsd_mask & BIT(IEEE80211_AC_BE))
 		wvif->uapsd_info.trig_be = 1;
 	else
 		wvif->uapsd_info.trig_be = 0;
 
-	if (arg->uapsd_enable[IEEE80211_AC_BK])
+	if (arg->uapsd_mask & BIT(IEEE80211_AC_BK))
 		wvif->uapsd_info.trig_bckgrnd = 1;
 	else
 		wvif->uapsd_info.trig_bckgrnd = 0;
@@ -330,7 +330,6 @@ static int wfx_update_pm(struct wfx_vif *wvif)
 {
 	struct ieee80211_conf *conf = &wvif->wdev->hw->conf;
 	struct hif_req_set_pm_mode pm;
-	u16 uapsd_flags;
 
 	if (wvif->state != WFX_STATE_STA || !wvif->bss_params.aid)
 		return 0;
@@ -345,9 +344,7 @@ static int wfx_update_pm(struct wfx_vif *wvif)
 			pm.pm_mode.fast_psm = 1;
 	}
 
-	memcpy(&uapsd_flags, &wvif->uapsd_info, sizeof(uapsd_flags));
-
-	if (uapsd_flags != 0)
+	if (wvif->edca.uapsd_mask)
 		pm.pm_mode.fast_psm = 0;
 
 	// Kernel disable PowerSave when multiple vifs are in use. In contrary,
@@ -375,7 +372,7 @@ int wfx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	WARN_ON(queue >= hw->queues);
 
 	mutex_lock(&wdev->conf_mutex);
-	wvif->edca.uapsd_enable[queue] = params->uapsd;
+	assign_bit(queue, &wvif->edca.uapsd_mask, params->uapsd);
 	edca = &wvif->edca.params[queue];
 	edca->aifsn = params->aifs;
 	edca->cw_min = params->cw_min;
@@ -1552,9 +1549,9 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 	for (i = 0; i < IEEE80211_NUM_ACS; i++) {
 		memcpy(&wvif->edca.params[i], &default_edca_params[i],
 		       sizeof(default_edca_params[i]));
-		wvif->edca.uapsd_enable[i] = false;
 		hif_set_edca_queue_params(wvif, &wvif->edca.params[i]);
 	}
+	wvif->edca.uapsd_mask = 0;
 	wfx_set_uapsd_param(wvif, &wvif->edca);
 
 	wfx_tx_policy_init(wvif);
diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
index 4719807bc25a..74755f6fa030 100644
--- a/drivers/staging/wfx/sta.h
+++ b/drivers/staging/wfx/sta.h
@@ -37,7 +37,7 @@ struct wfx_hif_event {
 struct wfx_edca_params {
 	/* NOTE: index is a linux queue id. */
 	struct hif_req_edca_queue_params params[IEEE80211_NUM_ACS];
-	bool uapsd_enable[IEEE80211_NUM_ACS];
+	unsigned long uapsd_mask;
 };
 
 struct wfx_grp_addr_table {
-- 
2.24.0





[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux