diff mbox series

[v2,31/65] staging: wfx: simplify hif_set_uc_mc_bc_condition()

Message ID 20200115135338.14374-32-Jerome.Pouiller@silabs.com
State New
Headers show
Series Simplify and improve the wfx driver | expand

Commit Message

Jérôme Pouiller Jan. 15, 2020, 1:54 p.m. UTC
From: Jérôme Pouiller <jerome.pouiller@silabs.com>

The structure hif_mib_uc_mc_bc_data_frame_condition come from hardware
API. It is not intended to be manipulated in upper layers of the driver.

In add, current code for hif_set_uc_mc_bc_condition() is too dumb. It
should pack data with hardware representation instead of leaving all
work to the caller.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/hif_tx_mib.h | 14 +++++++++++---
 drivers/staging/wfx/sta.c        |  6 +-----
 2 files changed, 12 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h
index eec6f4157e60..4d171e6cfc9a 100644
--- a/drivers/staging/wfx/hif_tx_mib.h
+++ b/drivers/staging/wfx/hif_tx_mib.h
@@ -246,12 +246,20 @@  static inline int hif_set_mac_addr_condition(struct wfx_vif *wvif,
 			     arg, sizeof(*arg));
 }
 
-static inline int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif,
-					     struct hif_mib_uc_mc_bc_data_frame_condition *arg)
+// FIXME: use a bitfield instead of 3 boolean values
+static inline int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif, int idx,
+					     bool unic, bool multic, bool broadc)
 {
+	struct hif_mib_uc_mc_bc_data_frame_condition val = {
+		.condition_idx = idx,
+		.param.bits.type_unicast = unic,
+		.param.bits.type_multicast = multic,
+		.param.bits.type_broadcast = broadc,
+	};
+
 	return hif_write_mib(wvif->wdev, wvif->id,
 			     HIF_MIB_ID_UC_MC_BC_DATAFRAME_CONDITION,
-			     arg, sizeof(*arg));
+			     &val, sizeof(val));
 }
 
 static inline int hif_set_config_data_filter(struct wfx_vif *wvif,
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 9030681858bb..79285927c7bf 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -120,7 +120,6 @@  static int wfx_set_mcast_filter(struct wfx_vif *wvif,
 	struct hif_mib_config_data_filter config = { };
 	struct hif_mib_set_data_filtering filter_data = { };
 	struct hif_mib_mac_addr_data_frame_condition filter_addr_val = { };
-	struct hif_mib_uc_mc_bc_data_frame_condition filter_addr_type = { };
 
 	// Temporary workaround for filters
 	return hif_set_data_filtering(wvif, &filter_data);
@@ -144,10 +143,7 @@  static int wfx_set_mcast_filter(struct wfx_vif *wvif,
 	}
 
 	// Accept unicast and broadcast
-	filter_addr_type.condition_idx = 0;
-	filter_addr_type.param.bits.type_unicast = 1;
-	filter_addr_type.param.bits.type_broadcast = 1;
-	ret = hif_set_uc_mc_bc_condition(wvif, &filter_addr_type);
+	ret = hif_set_uc_mc_bc_condition(wvif, 0, true, false, true);
 	if (ret)
 		return ret;