Skip to content

Commit 54fcdcf

Browse files
Karthikeyan PeriyasamyJeff Johnson
authored andcommitted
wifi: ath12k: Remove ath12k_get_num_hw() helper function
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. Additionally, there is no longer a need for multiple indirections to get the number of hardware. Therefore, remove this helper function and directly use ag->num_hw. This change 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 <[email protected]> Closes: https://lore.kernel.org/ath12k/[email protected]/ Closes: https://scan7.scan.coverity.com/#/project-view/52682/11354?selectedIssue=1602340 Fixes: a343d97 ("wifi: ath12k: move struct ath12k_hw from per device to group") Signed-off-by: Karthikeyan Periyasamy <[email protected]> Acked-by: Kalle Valo <[email protected]> Acked-by: Jeff Johnson <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jeff Johnson <[email protected]>
1 parent 812a302 commit 54fcdcf

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

drivers/net/wireless/ath/ath12k/core.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#include <linux/module.h>
@@ -1173,6 +1173,7 @@ static int ath12k_core_reconfigure_on_crash(struct ath12k_base *ab)
11731173
static void ath12k_rfkill_work(struct work_struct *work)
11741174
{
11751175
struct ath12k_base *ab = container_of(work, struct ath12k_base, rfkill_work);
1176+
struct ath12k_hw_group *ag = ab->ag;
11761177
struct ath12k *ar;
11771178
struct ath12k_hw *ah;
11781179
struct ieee80211_hw *hw;
@@ -1183,8 +1184,8 @@ static void ath12k_rfkill_work(struct work_struct *work)
11831184
rfkill_radio_on = ab->rfkill_radio_on;
11841185
spin_unlock_bh(&ab->base_lock);
11851186

1186-
for (i = 0; i < ath12k_get_num_hw(ab); i++) {
1187-
ah = ath12k_ag_to_ah(ab->ag, i);
1187+
for (i = 0; i < ag->num_hw; i++) {
1188+
ah = ath12k_ag_to_ah(ag, i);
11881189
if (!ah)
11891190
continue;
11901191

@@ -1224,6 +1225,7 @@ void ath12k_core_halt(struct ath12k *ar)
12241225

12251226
static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
12261227
{
1228+
struct ath12k_hw_group *ag = ab->ag;
12271229
struct ath12k *ar;
12281230
struct ath12k_hw *ah;
12291231
int i, j;
@@ -1235,8 +1237,8 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
12351237
if (ab->is_reset)
12361238
set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags);
12371239

1238-
for (i = 0; i < ath12k_get_num_hw(ab); i++) {
1239-
ah = ath12k_ag_to_ah(ab->ag, i);
1240+
for (i = 0; i < ag->num_hw; i++) {
1241+
ah = ath12k_ag_to_ah(ag, i);
12401242
if (!ah || ah->state == ATH12K_HW_STATE_OFF)
12411243
continue;
12421244

@@ -1270,12 +1272,13 @@ static void ath12k_core_pre_reconfigure_recovery(struct ath12k_base *ab)
12701272

12711273
static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab)
12721274
{
1275+
struct ath12k_hw_group *ag = ab->ag;
12731276
struct ath12k_hw *ah;
12741277
struct ath12k *ar;
12751278
int i, j;
12761279

1277-
for (i = 0; i < ath12k_get_num_hw(ab); i++) {
1278-
ah = ath12k_ag_to_ah(ab->ag, i);
1280+
for (i = 0; i < ag->num_hw; i++) {
1281+
ah = ath12k_ag_to_ah(ag, i);
12791282
if (!ah || ah->state == ATH12K_HW_STATE_OFF)
12801283
continue;
12811284

@@ -1318,6 +1321,7 @@ static void ath12k_core_post_reconfigure_recovery(struct ath12k_base *ab)
13181321
static void ath12k_core_restart(struct work_struct *work)
13191322
{
13201323
struct ath12k_base *ab = container_of(work, struct ath12k_base, restart_work);
1324+
struct ath12k_hw_group *ag = ab->ag;
13211325
struct ath12k_hw *ah;
13221326
int ret, i;
13231327

@@ -1336,7 +1340,7 @@ static void ath12k_core_restart(struct work_struct *work)
13361340
ath12k_dbg(ab, ATH12K_DBG_BOOT, "reset success\n");
13371341
}
13381342

1339-
for (i = 0; i < ath12k_get_num_hw(ab); i++) {
1343+
for (i = 0; i < ag->num_hw; i++) {
13401344
ah = ath12k_ag_to_ah(ab->ag, i);
13411345
ieee80211_restart_hw(ah->hw);
13421346
}

drivers/net/wireless/ath/ath12k/core.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: BSD-3-Clause-Clear */
22
/*
33
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#ifndef ATH12K_CORE_H
@@ -1205,11 +1205,6 @@ static inline void ath12k_ag_set_ah(struct ath12k_hw_group *ag, int idx,
12051205
ag->ah[idx] = ah;
12061206
}
12071207

1208-
static inline int ath12k_get_num_hw(struct ath12k_base *ab)
1209-
{
1210-
return ab->ag->num_hw;
1211-
}
1212-
12131208
static inline struct ath12k_hw_group *ath12k_ab_to_ag(struct ath12k_base *ab)
12141209
{
12151210
return ab->ag;

drivers/net/wireless/ath/ath12k/mac.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#include <net/mac80211.h>
@@ -11243,7 +11243,7 @@ int ath12k_mac_register(struct ath12k_hw_group *ag)
1124311243
int i;
1124411244
int ret;
1124511245

11246-
for (i = 0; i < ath12k_get_num_hw(ab); i++) {
11246+
for (i = 0; i < ag->num_hw; i++) {
1124711247
ah = ath12k_ag_to_ah(ag, i);
1124811248

1124911249
ret = ath12k_mac_hw_register(ah);
@@ -11275,7 +11275,7 @@ void ath12k_mac_unregister(struct ath12k_hw_group *ag)
1127511275

1127611276
clear_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags);
1127711277

11278-
for (i = ath12k_get_num_hw(ab) - 1; i >= 0; i--) {
11278+
for (i = ag->num_hw - 1; i >= 0; i--) {
1127911279
ah = ath12k_ag_to_ah(ag, i);
1128011280
if (!ah)
1128111281
continue;
@@ -11356,7 +11356,7 @@ void ath12k_mac_destroy(struct ath12k_hw_group *ag)
1135611356
}
1135711357
}
1135811358

11359-
for (i = 0; i < ath12k_get_num_hw(ab); i++) {
11359+
for (i = 0; i < ag->num_hw; i++) {
1136011360
ah = ath12k_ag_to_ah(ag, i);
1136111361
if (!ah)
1136211362
continue;

0 commit comments

Comments
 (0)