]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: wfx: simplify hif_set_output_power() usage
authorJérôme Pouiller <jerome.pouiller@silabs.com>
Wed, 15 Jan 2020 13:54:10 +0000 (13:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Jan 2020 19:59:46 +0000 (20:59 +0100)
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>
Link: https://lore.kernel.org/r/20200115135338.14374-7-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wfx/hif_tx_mib.h
drivers/staging/wfx/scan.c
drivers/staging/wfx/sta.c

index ef033a40938198dd759ecbd9fb3cdc4ad3a7d627..749df67131c3c7224ba54aca851d6b84488b52c3 100644 (file)
 #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,
index 9b3674b3226a34f2ff891e7891e1130b1bf371cc..8e0ac89fd28fa12fa50a7d0688c34dd2a23950d2 100644 (file)
@@ -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");
index 8f53a78d72152af10f8acab8593b46d144d6e9b1..11e33a6d5bb5e226c41533a081a8325969de40fd 100644 (file)
@@ -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) {