diff options
author | Jérôme Pouiller <jerome.pouiller@silabs.com> | 2020-01-15 13:54:12 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-01-16 20:59:46 +0100 |
commit | 9ed8b0d0f27cf7ba183d8e8e7c5cc47afb7a00ae (patch) | |
tree | 8687db6748a4b8845af28d58287b4c24fed8e8a5 /drivers/staging/wfx/hif_tx_mib.h | |
parent | 5fd64673cf6e2ca08447a77de3d2fe7e73d54915 (diff) |
staging: wfx: simplify hif_set_rcpi_rssi_threshold() usage
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>
Diffstat (limited to 'drivers/staging/wfx/hif_tx_mib.h')
-rw-r--r-- | drivers/staging/wfx/hif_tx_mib.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index 749df67131c3..a8082508fbfd 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -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, |