Commit 5fd64673 authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman

staging: wfx: simplify hif_set_output_power() usage

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: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200115135338.14374-7-Jerome.Pouiller@silabs.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c360f1cc
...@@ -15,13 +15,15 @@ ...@@ -15,13 +15,15 @@
#include "hif_tx.h" #include "hif_tx.h"
#include "hif_api_mib.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, return hif_write_mib(wvif->wdev, wvif->id,
HIF_MIB_ID_CURRENT_TX_POWER_LEVEL, 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, static inline int hif_set_beacon_wakeup_period(struct wfx_vif *wvif,
......
...@@ -61,7 +61,7 @@ static int send_scan_req(struct wfx_vif *wvif, ...@@ -61,7 +61,7 @@ static int send_scan_req(struct wfx_vif *wvif,
return timeout; return timeout;
ret = wait_for_completion_timeout(&wvif->scan_complete, timeout); ret = wait_for_completion_timeout(&wvif->scan_complete, timeout);
if (req->channels[start_idx]->max_power != wvif->wdev->output_power) 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); wfx_tx_unlock(wvif->wdev);
if (!ret) { if (!ret) {
dev_notice(wvif->wdev->dev, "scan timeout\n"); dev_notice(wvif->wdev->dev, "scan timeout\n");
......
...@@ -503,7 +503,7 @@ static void wfx_do_unjoin(struct wfx_vif *wvif) ...@@ -503,7 +503,7 @@ static void wfx_do_unjoin(struct wfx_vif *wvif)
hif_keep_alive_period(wvif, 0); hif_keep_alive_period(wvif, 0);
hif_reset(wvif, false); hif_reset(wvif, false);
wfx_tx_policy_init(wvif); 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; wvif->dtim_period = 0;
hif_set_macaddr(wvif, wvif->vif->addr); hif_set_macaddr(wvif, wvif->vif->addr);
wfx_free_event_queue(wvif); wfx_free_event_queue(wvif);
...@@ -1063,7 +1063,7 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, ...@@ -1063,7 +1063,7 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw,
if (changed & BSS_CHANGED_TXPOWER && if (changed & BSS_CHANGED_TXPOWER &&
info->txpower != wdev->output_power) { info->txpower != wdev->output_power) {
wdev->output_power = info->txpower; 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); mutex_unlock(&wdev->conf_mutex);
...@@ -1317,7 +1317,7 @@ int wfx_config(struct ieee80211_hw *hw, u32 changed) ...@@ -1317,7 +1317,7 @@ int wfx_config(struct ieee80211_hw *hw, u32 changed)
mutex_lock(&wdev->conf_mutex); mutex_lock(&wdev->conf_mutex);
if (changed & IEEE80211_CONF_CHANGE_POWER) { if (changed & IEEE80211_CONF_CHANGE_POWER) {
wdev->output_power = conf->power_level; 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) { if (changed & IEEE80211_CONF_CHANGE_PS) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment