OSDN Git Service

staging: wfx: simplify hif_set_rcpi_rssi_threshold() usage
authorJérôme Pouiller <jerome.pouiller@silabs.com>
Wed, 15 Jan 2020 13:54:12 +0000 (13:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Jan 2020 19:59:46 +0000 (20:59 +0100)
The structure hif_mib_rcpi_rssi_threshold come from hardware API. It is
not intended to be manipulated in upper layers of the driver.

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

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200115135338.14374-8-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wfx/hif_tx_mib.h
drivers/staging/wfx/sta.c

index 749df67..a808250 100644 (file)
@@ -44,10 +44,25 @@ static inline int hif_set_beacon_wakeup_period(struct wfx_vif *wvif,
 }
 
 static inline int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif,
-                                             struct hif_mib_rcpi_rssi_threshold *arg)
+                                             int rssi_thold, int rssi_hyst)
 {
+       struct hif_mib_rcpi_rssi_threshold arg = {
+               .rolling_average_count = 8,
+               .detection = 1,
+       };
+
+       if (!rssi_thold && !rssi_hyst) {
+               arg.upperthresh = 1;
+               arg.lowerthresh = 1;
+       } else {
+               arg.upper_threshold = rssi_thold + rssi_hyst;
+               arg.upper_threshold = (arg.upper_threshold + 110) * 2;
+               arg.lower_threshold = rssi_thold;
+               arg.lower_threshold = (arg.lower_threshold + 110) * 2;
+       }
+
        return hif_write_mib(wvif->wdev, wvif->id,
-                            HIF_MIB_ID_RCPI_RSSI_THRESHOLD, arg, sizeof(*arg));
+                            HIF_MIB_ID_RCPI_RSSI_THRESHOLD, &arg, sizeof(arg));
 }
 
 static inline int hif_get_counters_table(struct wfx_dev *wdev,
index 11e33a6..339acbc 100644 (file)
@@ -1033,31 +1033,9 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw,
                hif_slot_time(wvif, info->use_short_slot ? 9 : 20);
 
        if (changed & BSS_CHANGED_ASSOC || changed & BSS_CHANGED_CQM) {
-               struct hif_mib_rcpi_rssi_threshold th = {
-                       .rolling_average_count = 8,
-                       .detection = 1,
-               };
-
                wvif->cqm_rssi_thold = info->cqm_rssi_thold;
-
-               if (!info->cqm_rssi_thold && !info->cqm_rssi_hyst) {
-                       th.upperthresh = 1;
-                       th.lowerthresh = 1;
-               } else {
-                       /* FIXME It's not a correct way of setting threshold.
-                        * Upper and lower must be set equal here and adjusted
-                        * in callback. However current implementation is much
-                        * more reliable and stable.
-                        */
-                       /* RSSI: signed Q8.0, RCPI: unsigned Q7.1
-                        * RSSI = RCPI / 2 - 110
-                        */
-                       th.upper_threshold = info->cqm_rssi_thold + info->cqm_rssi_hyst;
-                       th.upper_threshold = (th.upper_threshold + 110) * 2;
-                       th.lower_threshold = info->cqm_rssi_thold;
-                       th.lower_threshold = (th.lower_threshold + 110) * 2;
-               }
-               hif_set_rcpi_rssi_threshold(wvif, &th);
+               hif_set_rcpi_rssi_threshold(wvif, info->cqm_rssi_thold,
+                                           info->cqm_rssi_hyst);
        }
 
        if (changed & BSS_CHANGED_TXPOWER &&