[PATCH 06/65] staging: wfx: simplify hif_set_output_power() usage

Jérôme Pouiller
2020-01-15T12:19:31Z

Hardware API use 10th of dBm for output power unit. Upper layers should
use same units than mac80211 and the conversion should be done by low
level layer of the driver (hif_set_output_power())

In add, current code of hif_set_output_power() use a __le32 while the
device API specify a specific structure for this.

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

diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h
index ef033a409381..749df67131c3 100644
--- a/drivers/staging/wfx/hif_tx_mib.h
+++ b/drivers/staging/wfx/hif_tx_mib.h
@@ -15,13 +15,15 @@
#include "hif_tx.h"
#include "hif_api_mib.h"

-static inline int hif_set_output_power(struct wfx_vif *wvif, int power_level)
+static inline int hif_set_output_power(struct wfx_vif *wvif, int val)
{
- __le32 val = cpu_to_le32(power_level);
+ struct hif_mib_current_tx_power_level arg = {
+ .power_level = cpu_to_le32(val * 10),
+ };

return hif_write_mib(wvif->wdev, wvif->id,
HIF_MIB_ID_CURRENT_TX_POWER_LEVEL,
- &val, sizeof(val));
+ &arg, sizeof(arg));
}

static inline int hif_set_beacon_wakeup_period(struct wfx_vif *wvif,
diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c
index 9b3674b3226a..8e0ac89fd28f 100644
--- a/drivers/staging/wfx/scan.c
+++ b/drivers/staging/wfx/scan.c
@@ -61,7 +61,7 @@ static int send_scan_req(struct wfx_vif *wvif,
return timeout;
ret = wait_for_completion_timeout(&wvif->scan_complete, timeout);
if (req->channels[start_idx]->max_power != wvif->wdev->output_power)
- hif_set_output_power(wvif, wvif->wdev->output_power * 10);
+ hif_set_output_power(wvif, wvif->wdev->output_power);
wfx_tx_unlock(wvif->wdev);
if (!ret) {
dev_notice(wvif->wdev->dev, "scan timeout\n");
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 8f53a78d7215..11e33a6d5bb5 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -503,7 +503,7 @@ static void wfx_do_unjoin(struct wfx_vif *wvif)
hif_keep_alive_period(wvif, 0);
hif_reset(wvif, false);
wfx_tx_policy_init(wvif);
- hif_set_output_power(wvif, wvif->wdev->output_power * 10);
+ hif_set_output_power(wvif, wvif->wdev->output_power);
wvif->dtim_period = 0;
hif_set_macaddr(wvif, wvif->vif->addr);
wfx_free_event_queue(wvif);
@@ -1063,7 +1063,7 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw,
if (changed & BSS_CHANGED_TXPOWER &&
info->txpower != wdev->output_power) {
wdev->output_power = info->txpower;
- hif_set_output_power(wvif, wdev->output_power * 10);
+ hif_set_output_power(wvif, wdev->output_power);
}
mutex_unlock(&wdev->conf_mutex);

@@ -1317,7 +1317,7 @@ int wfx_config(struct ieee80211_hw *hw, u32 changed)
mutex_lock(&wdev->conf_mutex);
if (changed & IEEE80211_CONF_CHANGE_POWER) {
wdev->output_power = conf->power_level;
- hif_set_output_power(wvif, wdev->output_power * 10);
+ hif_set_output_power(wvif, wdev->output_power);
}

if (changed & IEEE80211_CONF_CHANGE_PS) {
--
2.25.0