Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28008489rwd; Tue, 4 Jul 2023 11:10:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUWnZQut9wYpTdNQY2+/08kFtgTI3MUEN9hJlNH6BmFyzSo4nAXHp+w/iCAE1wnDAe15sP X-Received: by 2002:a17:903:230b:b0:1b8:a70e:8a7e with SMTP id d11-20020a170903230b00b001b8a70e8a7emr2551507plh.66.1688494241684; Tue, 04 Jul 2023 11:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688494241; cv=none; d=google.com; s=arc-20160816; b=rcnzNaC2pFAE/hJfZQyng5D54mFaUOQcaDHbQilfXA6b45TbeY9BchM72Xhtu0GVdB Pw5dBCeMFWuQz58sRl4VShnevMQsF8UlVd2JYAkQo42c+/Ja2GvtHbtjhEcDz+X3Koh8 GMHu+FY9xT+CCfTlvIbFOkAK9uYYySVvRpYTBnI6NphbF0T3g1mpmMJwXgumdDmzn+Kc 2X5vQtU5jupS6CmxARCrzTHHdyznjHQ+pWmMLd7I4BLY0EDQkonhSAQ7Cim4mocF/a6j 6+vpARqVnNLALzE28Ii7C5qmD8a2lGX4IJcvY2AYtZHZz7JrGQmuONzbdeBAuSm4kZpK 2wpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=22mY0QPEck0fiKlwWh2OEii0jnfSb0ptV2wwb92Gw+o=; fh=BnILszgCJyWcb3K7WG3TE9K5XgKwfdDNxTJXcDnfIKU=; b=c6Z0KzquUQDJ08EGamn4JO38lvvcH5A9x7Qer+1VNAdpEQEhR9P2LByywngW55wa7l mP637sdQkqfIL+iHjF7OWUEIPA6Ah7RZBnV25B8V46cwTq7T6iyYr0LYSGMKoqJkJlb5 yaTCyynKQsQJTuuUb2XlfdC6eMH5YX1qNH+LxH+BuZ/nwFNJA+VFAfo+9pED+cxptelM YKlrHYZE6etWDq/K9hN+GhQLO7/bdTTD5BGr04ZGEiv0FrsjD5BW1L1WZkan5wczqDbb 6vicIxvnTe1vZa9V4djScO+j1SvEaV/Nxx1FjgLe2wA0Mjv73Y426BqyImxzzioiIMB5 39ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=pbar2clB; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jj13-20020a170903048d00b001b89baba4f6si4079238plb.408.2023.07.04.11.10.33; Tue, 04 Jul 2023 11:10:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=pbar2clB; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231268AbjGDSHo (ORCPT + 60 others); Tue, 4 Jul 2023 14:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230232AbjGDSHn (ORCPT ); Tue, 4 Jul 2023 14:07:43 -0400 Received: from forward100a.mail.yandex.net (forward100a.mail.yandex.net [178.154.239.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7429210C9 for ; Tue, 4 Jul 2023 11:07:42 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net [IPv6:2a02:6b8:c18:4001:0:640:bc2:0]) by forward100a.mail.yandex.net (Yandex) with ESMTP id 5062F4230E; Tue, 4 Jul 2023 21:07:40 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id d7X30KGDciE0-3V3oOaun; Tue, 04 Jul 2023 21:07:39 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1688494060; bh=22mY0QPEck0fiKlwWh2OEii0jnfSb0ptV2wwb92Gw+o=; h=Message-ID:Date:Cc:Subject:To:From; b=pbar2clBj4tbVzM+7O9PCdpm+rhtBLA/6kSZp2Eq5KdRSF5Ws7qWni9stMh4K3Ixc RSSupVOTK4PQ92rcdNlnzhfqD+ZVMB8Jct9AS7OrpeWcW9ynIqruzyDzoVKyYfczMS dAgMTj+mq1FFZNtwP1tN6VsC/mSeiTm0ub0ZIPZg= Authentication-Results: mail-nwsmtp-smtp-production-main-81.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Kalle Valo Cc: linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH] wifi: ath10k: simplify ath10k_peer_create() Date: Tue, 4 Jul 2023 21:06:07 +0300 Message-ID: <20230704180617.84948-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Use convenient 'list_count_nodes()' in 'ath10k_peer_create()', thus making the latter a bit smaller and simpler. Signed-off-by: Dmitry Antipov --- 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