From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 527667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC988C433FE for ; Thu, 23 Dec 2021 01:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346934AbhLWBQs (ORCPT ); Wed, 22 Dec 2021 20:16:48 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18346 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345761AbhLWBOP (ORCPT ); Wed, 22 Dec 2021 20:14:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=VdSmr7LcH0rW8kHWmZpoh/Ig1LSGlhHmXHB0t3cqZGc=; b=AGJAB9NF2r1y61gG1NFibLyjYqebZYsKzYQcyhYBEKFYqqWwu8BuwSFhK0VCpq+UoUxt Fgfp5X8r6vQtUrMwJp0elicdllDHKLvt1X7EGdEuT0VRQYDHOdRYmpuZHKGWYytmh7nhrg hRMcbf+nteyrDWlChGGdXIyMLM+oYUTGSYy7nDrqIf7DW74x8qEoHJs9AHz+jFRha8lz2A tsJj6HzeIfuluuFGT+CUAwMxLaKtxLJRVkxU7ukN9K2xEdsvXTr/g6so2joTiiveH9o4/F 8sawsJ7aa84oUE3iqZkpuMvkg5C79l8hC6IEfUGQsD0exT3joAie/Pq2I2WiDbFw== Received: by filterdrecv-64fcb979b9-6vbpf with SMTP id filterdrecv-64fcb979b9-6vbpf-1-61C3CD5E-35 2021-12-23 01:14:06.683709228 +0000 UTC m=+8644637.687945467 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id OwzaDxMVSaWpyCRXrQezBA Thu, 23 Dec 2021 01:14:06.542 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 73DAF701488; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 27/50] wilc1000: simplify ac_balance() a bit Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-28-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvFH5jXK85cQtbtZt7SL3jCjJD5yamKyyCopUd3NzO3D/huQ5uOd/defxRnh5BvGJtoyo9c8YpecROwyRILZQe2JFN/JR4IPqMVuKZM9SL/rQskbTbYfOK8iq7Y5p5St869NGsXmi0Q5ehFLNnYxynlaE0whcIQHHamwFuwU4uedrZrDudO7WOtEPBSdXogmfpg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org ac_balance() is never going to fail ("ratio" is always non-NULL), so there is no reason to pretend otherwise. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 5ea9129b36925..287c0843ba152 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -345,21 +345,23 @@ static inline u8 ac_classify(struct wilc *wilc, struct sk_buff *skb) return q_num; } -static inline int ac_balance(struct wilc *wl, u8 *ratio) +/** + * ac_balance() - balance queues by favoring ones with fewer packets pending + * @wl: Pointer to the wilc structure. + * @ratio: Pointer to array of length NQUEUES in which this function + * returns the number of packets that may be scheduled for each + * access category. + */ +static inline void ac_balance(const struct wilc *wl, u8 *ratio) { u8 i, max_count = 0; - if (!ratio) - return -EINVAL; - for (i = 0; i < NQUEUES; i++) if (wl->fw[i].count > max_count) max_count = wl->fw[i].count; for (i = 0; i < NQUEUES; i++) ratio[i] = max_count - wl->fw[i].count; - - return 0; } static inline void ac_update_fw_ac_pkt_info(struct wilc *wl, u32 reg) @@ -894,8 +896,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) if (wilc->quit) goto out_update_cnt; - if (ac_balance(wilc, ac_desired_ratio)) - return -EINVAL; + ac_balance(wilc, ac_desired_ratio); mutex_lock(&wilc->txq_add_to_head_cs);