From patchwork Wed Jan 15 12:13:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11333933 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55004109A for ; Wed, 15 Jan 2020 12:14:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 298FE24671 for ; Wed, 15 Jan 2020 12:14:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="JlEOMjuE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732417AbgAOMOe (ORCPT ); Wed, 15 Jan 2020 07:14:34 -0500 Received: from mail-co1nam11on2064.outbound.protection.outlook.com ([40.107.220.64]:28929 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730835AbgAOMOd (ORCPT ); Wed, 15 Jan 2020 07:14:33 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IVwvLh6+UjY6cNClOasG3tk5BZNz/P1XTQ/aDl42WJKG8cZitL7/d2XoTbq3NvH5sD8tjrcaREZ6/U0npt5kzJSsvinQLF011pUmNACdT33kGnX0cUEzbjQZFXvulY2PyXqMWpqmydFch4qB4AEmF7I0PrghXElxnEuuNq8ybpoXd1a9DjA+gmAjMYqGk6jZAfLg9eOoLTDgOzq8ffCQvDsVxQ+O3h7vu4jFesVTZKlLOE3yfNKSZVkLmeabtKzQ6w0wcJ1PWw4xPs5rsRABP7/Bsmrj5daD8mOopWcU0UkN7Aj7RvKmL/AfXQ0QRt+2ctl+thvHbVFnvfoOtThHiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ro9I2rSIp0iul/hKKxPII0gO0+PaKdaAxCdGr0ktzNc=; b=TCozFyTEuKF5pjoefDduA/ntQCK2+2zS/EjnVIV4st0m3D1lTNOLFh7MWXTXtIuCpEo5R/bU5j1oW38sIDZUaIo5y+zZOuhfyEJahjBdp25PPg67baJ74tGiK60ArqfTsrMSEgbvy4x7uo4DYcsYnzPPaguNxZXy8yFjamVufiSlZwuBijLiLnJGlWRXTrjbBijzogrfkCpGH6zMw6cVjSD3Lw/7t5/JlAD6BYObvcvFAGoCncdVaDEH2K/bVImtG1bXx5RQGjegncaOi7FoShGlR3ZXwdvoJ9BtNbL3sBsLkvUQrXek3hk/ZPZJUyAgwlTR2t5mypa0TihmJWTnhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ro9I2rSIp0iul/hKKxPII0gO0+PaKdaAxCdGr0ktzNc=; b=JlEOMjuE6h/f+n6NbKKGSw95/1ikg0tn1pO/1x0Q3vf7OzTojSMlwXA9syshGN9AOWWJCxFLTeJ45WSCdV8CjCYFWut4Qig+loj0h++sGCG8zlGeB1vxfDebIRKn6DpDzr8RVWW+E3Cid/3XPPrxlGo5/s0BgbfQiyIcayn0Qso= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB3934.namprd11.prod.outlook.com (10.255.180.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20; Wed, 15 Jan 2020 12:14:10 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf%4]) with mapi id 15.20.2623.018; Wed, 15 Jan 2020 12:14:10 +0000 Received: from pc-42.silabs.com (37.71.187.125) by PR2PR09CA0009.eurprd09.prod.outlook.com (2603:10a6:101:16::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18 via Frontend Transport; Wed, 15 Jan 2020 12:13:32 +0000 From: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= To: "devel@driverdev.osuosl.org" , "linux-wireless@vger.kernel.org" CC: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 63/65] staging: wfx: simplify wfx_tx_queue_get_num_queued() Thread-Topic: [PATCH 63/65] staging: wfx: simplify wfx_tx_queue_get_num_queued() Thread-Index: AQHVy500cBdLiMxjj0yOc+OxlTaMWQ== Date: Wed, 15 Jan 2020 12:13:33 +0000 Message-ID: <20200115121041.10863-64-Jerome.Pouiller@silabs.com> References: <20200115121041.10863-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20200115121041.10863-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR2PR09CA0009.eurprd09.prod.outlook.com (2603:10a6:101:16::21) To MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.25.0 x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bd7060b7-2ef7-40db-cefb-08d799b4574a x-ms-traffictypediagnostic: MN2PR11MB3934: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1417; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(136003)(376002)(366004)(346002)(199004)(189003)(54906003)(110136005)(86362001)(956004)(107886003)(2616005)(316002)(36756003)(71200400001)(52116002)(7696005)(478600001)(8936002)(81156014)(8676002)(4326008)(81166006)(6486002)(2906002)(26005)(66946007)(16526019)(186003)(5660300002)(66574012)(1076003)(66556008)(64756008)(66446008)(85182001)(66476007)(85202003);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB3934;H:MN2PR11MB4063.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: H5Vac0nH6cbXeksLaV+Bn2jae/g+nU8b9jrVNjNRfQNnfehvvNeP1fFfF90+pjegiuH1o9EUgxaT6U4E2CeJUExYHuONVuT9cbLmmoQufPdDrq+aZITEX7BVVHyaWP/uWGiNf2L5YCSRvhJbaNI9D/9oYOtG6EbZj3NfgeupX0ThcwiqDXURJu1TjTqgnQjHLp3Wr6RJFpx6F1Vw0Sa51IGGQTX+7KztEaDJKaIbmmm+ZjGNldSLwHXU4Dx8WoyeWykbWkWAI0QHBmbhVaqSBEJJDUNtUxOIJrOQ9hN9RU+3wjeG/E8d1Nmo2OdatdpDA5ll7jJoEj41eT3G4ccaz30TFiU9bstDMbUN+/+PYKXy1jbPNuTnwa8TvRBHVVa5WgFhjV6vhbZKg7ToNhp7UUShbz9SYi+UuJubwGXJpKRddZYEkmXR8l1QN6wKLVQS Content-ID: <97CF986C7242434BA321724AE2F96DFA@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd7060b7-2ef7-40db-cefb-08d799b4574a X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 12:13:33.5806 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 43jk542TTATfS4nuBvrD2lBhNm6HzBBpJYrrEY6+XJiRarXMPBPS8r+ix5A7y6j8OxO9IhS76MPEp8G/IIOQhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3934 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller wfx_tx_queue_get_num_queued() can take advantage of BIT() instead of maintaining one variable for a counter and another for a mask. In add, wfx_tx_queue_get_num_queued() has no real reason to return a size_t instead of an int. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/queue.c | 14 +++++--------- drivers/staging/wfx/queue.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 024497eb19ac..0bcc61feee1d 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -175,11 +175,9 @@ void wfx_tx_queues_deinit(struct wfx_dev *wdev) wfx_tx_queues_clear(wdev); } -size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue, - u32 link_id_map) +int wfx_tx_queue_get_num_queued(struct wfx_queue *queue, u32 link_id_map) { - size_t ret; - int i, bit; + int ret, i; if (!link_id_map) return 0; @@ -189,11 +187,9 @@ size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue, ret = skb_queue_len(&queue->queue); } else { ret = 0; - for (i = 0, bit = 1; i < ARRAY_SIZE(queue->link_map_cache); - ++i, bit <<= 1) { - if (link_id_map & bit) + for (i = 0; i < ARRAY_SIZE(queue->link_map_cache); i++) + if (link_id_map & BIT(i)) ret += queue->link_map_cache[i]; - } } spin_unlock_bh(&queue->queue.lock); return ret; @@ -555,7 +551,7 @@ struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev) /* allow bursting if txop is set */ if (wvif->edca_params[queue_num].txop) - burst = (int)wfx_tx_queue_get_num_queued(queue, tx_allowed_mask) + 1; + burst = wfx_tx_queue_get_num_queued(queue, tx_allowed_mask) + 1; else burst = 1; diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h index 096ae86135cc..90bb060d1204 100644 --- a/drivers/staging/wfx/queue.h +++ b/drivers/staging/wfx/queue.h @@ -51,7 +51,7 @@ struct hif_msg *wfx_tx_queues_get_after_dtim(struct wfx_vif *wvif); void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff *skb); -size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue, u32 link_id_map); +int wfx_tx_queue_get_num_queued(struct wfx_queue *queue, u32 link_id_map); struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id); int wfx_pending_remove(struct wfx_dev *wdev, struct sk_buff *skb);