From patchwork Wed Jan 15 13:55:35 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: 216637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A30B1C33CB3 for ; Wed, 15 Jan 2020 13:57:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7781D2467C for ; Wed, 15 Jan 2020 13:57:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="Z09up+tM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730040AbgAON4r (ORCPT ); Wed, 15 Jan 2020 08:56:47 -0500 Received: from mail-eopbgr770085.outbound.protection.outlook.com ([40.107.77.85]:39089 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730364AbgAON4o (ORCPT ); Wed, 15 Jan 2020 08:56:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PNm1BBELvuNsVLdXyoA2aXFSVBDnRpZmT5ui+UEEsZTCeDe1PdCvFRcOktH+5iNlYsCk3Wy/kFqUczNTcYl4KBYXLkzLCxHQFW7osnLK0/MW2IDFmCbdiuTpCx8h8yueP0s5ICqoq1+GaYvY3D/VSYi59dKsFbxZpxIndOw6lJw+H+y313btoGaG+rG2maMU+VGCnUtCHNMF9kNhAhKoM0vHcDtbRq0gaTGTCV11twgWgY3YvcQBcNEfwic+Rn79v13Nr9bqtNDmBu2w7K1WEzdqA6tt+JhTNtNu8uE/rEzCL54RQOPJ+GS1mwyX8rP1mvNqC9TwgQbS6FZs2jj3tQ== 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=dHh97vpsjApJ3e070TGVuAIarzks6NFpFzFNXDcpnMpw3uvhH+TqYOaYHmVAeRO8EvpU//8bqw6mAUSuDW4EE3S57iGOUXDCIaysIPbgb5YIKargLt5c0WXJ9ihSLk2ShgJmeTPLWrvwLogVNYomY5ehWFyKocqff0ftBI0rNPA1mqSvsm/cDmslpb2cFipslJLfrMLIPEizLeQAWciHIbMilRJxLS6DxtjLSeToS0L5DxMZGyWOWwnBuhv4K0diNnIJSU7cFz1Ebd9PQIYWkZFgCDYBp6Wask04loUKUrfJ/AgfHVTYaXyj6Viptls31CEM0GySk4A0/2g9k7P86g== 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=Z09up+tMnLty2rxdXcN80lJQr4shv5s3tP2UeVj75FwFVM9OaQ/RdzOMZRKCDQmAlq2Sk3HShhv/Ud4L7PSMc8/LShW0/ezer5Rdouh0mpVp8+9P/fa0FR8hdnHl5c16ymahtCvx8hFpT6ZMNi+rf2a2LsfX+7H2XjJzdFqiWF4= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB3661.namprd11.prod.outlook.com (20.178.252.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18; Wed, 15 Jan 2020 13:56:04 +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 13:56:04 +0000 Received: from pc-42.home (2a01:e35:8bf5:66a0:3dbe:4cb5:6059:a948) by PR2P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::20) 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 13:55:34 +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?SsOpcsO0bWUgUG91?= =?utf-8?q?iller?= Subject: [PATCH v2 63/65] staging: wfx: simplify wfx_tx_queue_get_num_queued() Thread-Topic: [PATCH v2 63/65] staging: wfx: simplify wfx_tx_queue_get_num_queued() Thread-Index: AQHVy6t1PPmnEE1x50GLb9uE8oi/Yg== Date: Wed, 15 Jan 2020 13:55:35 +0000 Message-ID: <20200115135338.14374-64-Jerome.Pouiller@silabs.com> References: <20200115135338.14374-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20200115135338.14374-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR2P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::20) 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: [2a01:e35:8bf5:66a0:3dbe:4cb5:6059:a948] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 307eabdb-5377-470b-1438-08d799c2985a x-ms-traffictypediagnostic: MN2PR11MB3661: 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)(39860400002)(376002)(396003)(136003)(346002)(366004)(199004)(189003)(8886007)(6486002)(316002)(54906003)(71200400001)(36756003)(6506007)(66476007)(66446008)(66946007)(110136005)(8676002)(81166006)(81156014)(478600001)(86362001)(2616005)(4326008)(66574012)(2906002)(107886003)(1076003)(16526019)(186003)(85202003)(5660300002)(6512007)(52116002)(64756008)(66556008)(85182001)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3661; 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: ljB7x66vmeW27kItOGJAseYpfeJk7XiV9tT317bKvBCLkIm9/LRf7gg81Au88pdNj/PBmbtrSaweh35/vInNIUM5FAnnyHfhqC7bAnuB/02FgsA8f7TEn+XJA3Z8Hk+ZnGOrgCHsEYyslCbKjv5ibLTnJIQOwLjZHBxgv0UhaN+p81Mid4lG5gkePt5U3KatUPtrY08wV5hd76QYnlIDj0kbprE9U0y6htfuhFX+BqgFoudiIwf5HY9e4xzxUIVIkyxywIahAZoOy2YG9PIsXdmN45jPX+6lO6h0apSpa34K7LSRMFzKBTB6OcFFpBaIavZDz0+J6WgXHqx50hVuBrRRiRmgktBog9hurXF8HWpYqJJ05CbMNDMt5nRYtDHpd9ncmlWThZPsZ+s8+Ro5Nkk4+jcTSXkMfTO7RYDULdEewNo2FiObmCBCH++b9ovA Content-ID: MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 307eabdb-5377-470b-1438-08d799c2985a X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 13:55:35.6848 (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: EyCR1W6kuKpqcgsgGLYX82BQRgEIRlLeQXus+EWEZ0nFHDkFiDKaSXOjrFxev0/h/9VRfFxbjrEef7yc1XZk5g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3661 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);