Currently, the ath12k_get_num_hw() helper function takes the device handle as an argument. Here, the number of hardware is retrieved from the group handle. Demanding the device handle from the caller is unnecessary since in some cases the group handle is already available. Therefore, change this helper function argument from the device handle to the group handle. This also fixes the below Smatch static checker warning. Smatch warning: ath12k_mac_destroy() error: we previously assumed 'ab' could be null Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Closes: https://lore.kernel.org/ath12k/3e705de0-67d1-4437-97ff-4828d83ae2af@stanley.mountain/ Closes: https://scan7.scan.coverity.com/#/project-view/52682/11354?selectedIssue=1602340 Fixes: a343d97f27f5 ("wifi: ath12k: move struct ath12k_hw from per device to group") Signed-off-by: Karthikeyan Periyasamy <quic_periyasa@xxxxxxxxxxx> --- drivers/net/wireless/ath/ath12k/core.c | 8 ++++---- drivers/net/wireless/ath/ath12k/core.h | 4 ++-- drivers/net/wireless/ath/ath12k/mac.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/core.c b/drivers/net/wireless/ath/ath12k/core.c index bf391e6e8f72..54309602eda4 100644 --- a/drivers/net/wireless/ath/ath12k/core.c +++ b/drivers/net/wireless/ath/ath12k/core.c @@ -1108,7 +1108,7 @@ static void ath12k_rfkill_work(struct work_struct *work) rfkill_radio_on = ab->rfkill_radio_on; spin_unlock_bh(&ab->base_lock); - for (i = 0; i < ath12k_get_num_hw(ab); i++) { + for (i = 0; i < ath12k_get_num_hw(ab->ag); i++) { ah = ath12k_ag_to_ah(ab->ag, i); if (!ah) continue; @@ -1160,7 +1160,7 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab) if (ab->is_reset) set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); - for (i = 0; i < ath12k_get_num_hw(ab); i++) { + for (i = 0; i < ath12k_get_num_hw(ab->ag); i++) { ah = ath12k_ag_to_ah(ab->ag, i); if (!ah || ah->state == ATH12K_HW_STATE_OFF) continue; @@ -1199,7 +1199,7 @@ static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab) struct ath12k *ar; int i, j; - for (i = 0; i < ath12k_get_num_hw(ab); i++) { + for (i = 0; i < ath12k_get_num_hw(ab->ag); i++) { ah = ath12k_ag_to_ah(ab->ag, i); if (!ah || ah->state == ATH12K_HW_STATE_OFF) continue; @@ -1261,7 +1261,7 @@ static void ath12k_core_restart(struct work_struct *work) ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset success\n"); } - for (i = 0; i < ath12k_get_num_hw(ab); i++) { + for (i = 0; i < ath12k_get_num_hw(ab->ag); i++) { ah = ath12k_ag_to_ah(ab->ag, i); ieee80211_restart_hw(ah->hw); } diff --git a/drivers/net/wireless/ath/ath12k/core.h b/drivers/net/wireless/ath/ath12k/core.h index 56e740ec61e8..6756bbb8a09b 100644 --- a/drivers/net/wireless/ath/ath12k/core.h +++ b/drivers/net/wireless/ath/ath12k/core.h @@ -1181,9 +1181,9 @@ static inline void ath12k_ag_set_ah(struct ath12k_hw_group *ag, int idx, ag->ah[idx] = ah; } -static inline int ath12k_get_num_hw(struct ath12k_base *ab) +static inline int ath12k_get_num_hw(struct ath12k_hw_group *ag) { - return ab->ag->num_hw; + return ag->num_hw; } static inline struct ath12k_hw_group *ath12k_ab_to_ag(struct ath12k_base *ab) diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c index 7116516b4c01..5cdc1c38b049 100644 --- a/drivers/net/wireless/ath/ath12k/mac.c +++ b/drivers/net/wireless/ath/ath12k/mac.c @@ -10825,7 +10825,7 @@ int ath12k_mac_register(struct ath12k_hw_group *ag) int i; int ret; - for (i = 0; i < ath12k_get_num_hw(ab); i++) { + for (i = 0; i < ath12k_get_num_hw(ag); i++) { ah = ath12k_ag_to_ah(ag, i); ret = ath12k_mac_hw_register(ah); @@ -10857,7 +10857,7 @@ void ath12k_mac_unregister(struct ath12k_hw_group *ag) clear_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); - for (i = ath12k_get_num_hw(ab) - 1; i >= 0; i--) { + for (i = ath12k_get_num_hw(ag) - 1; i >= 0; i--) { ah = ath12k_ag_to_ah(ag, i); if (!ah) continue; @@ -10935,7 +10935,7 @@ void ath12k_mac_destroy(struct ath12k_hw_group *ag) } } - for (i = 0; i < ath12k_get_num_hw(ab); i++) { + for (i = 0; i < ath12k_get_num_hw(ag); i++) { ah = ath12k_ag_to_ah(ag, i); if (!ah) continue; -- 2.34.1