Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 801a16bf authored by Jeff Johnson's avatar Jeff Johnson Committed by nshrivas
Browse files

qcacld-3.0: Fix power units in wlan_hdd_cfg80211_set_txpower()

wlan_hdd_cfg80211_set_txpower() currently expects the input power to
be in units of dBm. However cfg80211 specifies the set_tx_power()
method will pass the power in mBm, and that to get dBm the driver
should use MBM_TO_DBM(). The userspace tool "iw" also expects the
power to be in mBm.

In order to comply with the definition of cfg80211, change the
implementation of wlan_hdd_cfg80211_set_txpower() to expect the power
in mBm and use MBM_TO_DBM() to convert the power to dBm. But for
backward compatibility with userspace entities which are expecting the
current implementation, if the converted power is 0 then assume the
input power is already in dBm and use it without conversion.

Change-Id: I7c64f7ac14249a307357c91f8bea4dad8d59ff28
CRs-Fixed: 2331003
parent 2c9593a3
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -2037,14 +2037,14 @@ int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
 * @wiphy: Pointer to wiphy
 * @wdev: Pointer to network device
 * @type: TX power setting type
 * @dbm: TX power in dbm
 * @mbm: TX power in mBm
 *
 * Return: 0 for success, non-zero for failure
 */
static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
					   struct wireless_dev *wdev,
					   enum nl80211_tx_power_setting type,
					   int dbm)
					   int mbm)
{
	struct hdd_context *hdd_ctx = (struct hdd_context *) wiphy_priv(wiphy);
	mac_handle_t mac_handle;
@@ -2052,6 +2052,7 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
	struct qdf_mac_addr selfMac = QDF_MAC_ADDR_BCAST_INIT;
	QDF_STATUS status;
	int errno;
	int dbm;

	hdd_enter();

@@ -2070,6 +2071,16 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,

	mac_handle = hdd_ctx->mac_handle;

	dbm = MBM_TO_DBM(mbm);

	/*
	 * the original implementation of this function expected power
	 * values in dBm instead of mBm. If the conversion from mBm to
	 * dBm is zero, then assume dBm was passed.
	 */
	if (!dbm)
		dbm = mbm;

	status = sme_cfg_set_int(mac_handle, WNI_CFG_CURRENT_TX_POWER_LEVEL,
				 dbm);
	if (QDF_IS_STATUS_ERROR(status)) {
@@ -2109,14 +2120,14 @@ static int __wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
				  struct wireless_dev *wdev,
				  enum nl80211_tx_power_setting type,
				  int dbm)
				  int mbm)
{
	int ret;

	cds_ssr_protect(__func__);
	ret = __wlan_hdd_cfg80211_set_txpower(wiphy,
					      wdev,
					      type, dbm);
					      type, mbm);
	cds_ssr_unprotect(__func__);

	return ret;