From: Aditya Kumar Singh Date: Fri, 17 Oct 2025 04:07:58 +0000 (+0530) Subject: wifi: ath11k: wrap ath11k_mac_op_get_txpower() with lock-aware internal helper X-Git-Tag: v6.19-rc1~170^2~227^2^2~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c243d5e44f6ecbb29bf55b82e6dd92bca4fde0b1;p=thirdparty%2Fkernel%2Flinux.git wifi: ath11k: wrap ath11k_mac_op_get_txpower() with lock-aware internal helper Refactor ath11k_mac_op_get_txpower() by introducing a new internal function ath11k_mac_handle_get_txpower(), which assumes the caller holds the appropriate lock. This prepares the codebase for future change where the internal function may be invoked directly with the lock already acquired, improving modularity and lock handling consistency. No functional change intended. Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-02146-QCAHKSWPL_SILICONZ-1 Signed-off-by: Aditya Kumar Singh Reviewed-by: Vasanthakumar Thiagarajan Reviewed-by: Baochen Qiang Link: https://patch.msgid.link/20251017-add_tx_power_insertion_support-v1-2-f08feacfca93@oss.qualcomm.com Signed-off-by: Jeff Johnson --- diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 99dea865e31ea..319b4cfeb368a 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -4103,12 +4103,10 @@ static int ath11k_mac_get_fw_stats(struct ath11k *ar, u32 pdev_id, return ret; } -static int ath11k_mac_op_get_txpower(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - unsigned int link_id, - int *dbm) +static int ath11k_mac_handle_get_txpower(struct ath11k *ar, + struct ieee80211_vif *vif, + int *dbm) { - struct ath11k *ar = hw->priv; struct ath11k_base *ab = ar->ab; struct ath11k_fw_stats_pdev *pdev; int ret; @@ -4119,15 +4117,13 @@ static int ath11k_mac_op_get_txpower(struct ieee80211_hw *hw, * of these. Hence, we request the FW pdev stats in which FW reports * the minimum of all vdev's channel Tx power. */ - mutex_lock(&ar->conf_mutex); + lockdep_assert_held(&ar->conf_mutex); /* Firmware doesn't provide Tx power during CAC hence no need to fetch * the stats. */ - if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) { - mutex_unlock(&ar->conf_mutex); + if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) return -EAGAIN; - } ret = ath11k_mac_get_fw_stats(ar, ar->pdev->pdev_id, 0, WMI_REQUEST_PDEV_STAT); @@ -4148,14 +4144,12 @@ static int ath11k_mac_op_get_txpower(struct ieee80211_hw *hw, *dbm = pdev->chan_tx_power / 2; spin_unlock_bh(&ar->data_lock); - mutex_unlock(&ar->conf_mutex); ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "txpower from firmware %d, reported %d dBm\n", pdev->chan_tx_power, *dbm); return 0; err_fallback: - mutex_unlock(&ar->conf_mutex); /* We didn't get txpower from FW. Hence, relying on vif->bss_conf.txpower */ *dbm = vif->bss_conf.txpower; ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "txpower from firmware NaN, reported %d dBm\n", @@ -4163,6 +4157,21 @@ err_fallback: return 0; } +static int ath11k_mac_op_get_txpower(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + unsigned int link_id, + int *dbm) +{ + struct ath11k *ar = hw->priv; + int ret; + + mutex_lock(&ar->conf_mutex); + ret = ath11k_mac_handle_get_txpower(ar, vif, dbm); + mutex_unlock(&ar->conf_mutex); + + return ret; +} + static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_scan_request *hw_req)