2023-07-04 18:10:41

by Dmitry Antipov

[permalink] [raw]
Subject: [PATCH] wifi: ath10k: simplify ath10k_peer_create()

Use convenient 'list_count_nodes()' in 'ath10k_peer_create()',
thus making the latter a bit smaller and simpler.

Signed-off-by: Dmitry Antipov <[email protected]>
---
drivers/net/wireless/ath/ath10k/mac.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 03e7bc5b6c0b..6d14e58b98af 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -728,20 +728,13 @@ static int ath10k_peer_create(struct ath10k *ar,
const u8 *addr,
enum wmi_peer_type peer_type)
{
- struct ath10k_vif *arvif;
struct ath10k_peer *peer;
- int num_peers = 0;
int ret;

lockdep_assert_held(&ar->conf_mutex);

- num_peers = ar->num_peers;
-
- /* Each vdev consumes a peer entry as well */
- list_for_each_entry(arvif, &ar->arvifs, list)
- num_peers++;
-
- if (num_peers >= ar->max_num_peers)
+ /* Each vdev consumes a peer entry as well. */
+ if (ar->num_peers + list_count_nodes(&ar->arvifs) >= ar->max_num_peers)
return -ENOBUFS;

ret = ath10k_wmi_peer_create(ar, vdev_id, addr, peer_type);
--
2.41.0



2023-10-03 14:21:54

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] wifi: ath10k: simplify ath10k_peer_create()

Dmitry Antipov <[email protected]> wrote:

> Use convenient 'list_count_nodes()' in 'ath10k_peer_create()',
> thus making the latter a bit smaller and simpler.
>
> Signed-off-by: Dmitry Antipov <[email protected]>
> Signed-off-by: Kalle Valo <[email protected]>

Patch applied to ath-next branch of ath.git, thanks.

322a487c53f8 wifi: ath10k: simplify ath10k_peer_create()

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches