wifi: ath10k: simplify ath10k_peer_create()
authorDmitry Antipov <dmantipov@yandex.ru>
Mon, 2 Oct 2023 17:03:57 +0000 (20:03 +0300)
committerKalle Valo <quic_kvalo@quicinc.com>
Tue, 3 Oct 2023 14:21:20 +0000 (17:21 +0300)
Use convenient 'list_count_nodes()' in 'ath10k_peer_create()',
thus making the latter a bit smaller and simpler.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230704180617.84948-1-dmantipov@yandex.ru
drivers/net/wireless/ath/ath10k/mac.c

index b33f87b9ad0b8e0142b92415b5c67fa37e4769ff..2cf693f3fea96e10fca84996d35d7b1a1bad2245 100644 (file)
@@ -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);