From patchwork Thu Feb 2 15:42:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Fitzgerald X-Patchwork-Id: 649674 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAA07C05027 for ; Thu, 2 Feb 2023 15:43:40 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2911BE96; Thu, 2 Feb 2023 16:42:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2911BE96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1675352618; bh=X0iIGUlUCiu9UMGQlIecnpMbvDH/zQf5dAi8eM3tICI=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=uX8G4UshXqCT6jPgXqr01pvQaPGY2EfzsDAmE/VU1NDFeCj4/JkeozoFA3X3FEJEG /fY+MgauVle9DuaUNMx24xFOix0C3uNNXjYDde8Gx7MlhszTV7RKyoQ3oEqQ+Yrwhg PFu9uTEiSOaWHRSe8nNX2QkELBdergbj/psenbqo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 81A66F804C2; Thu, 2 Feb 2023 16:42:25 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 30B4DF80528; Thu, 2 Feb 2023 16:42:23 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 33B30F804C2 for ; Thu, 2 Feb 2023 16:42:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 33B30F804C2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=cirrus.com header.i=@cirrus.com header.a=rsa-sha256 header.s=PODMain02222019 header.b=G4zay/Ev Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3128sUnb006230; Thu, 2 Feb 2023 09:42:15 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=qHX4Vtwm/1eGcLZA2epkScZnQv8rS+tXSdtmt+QwEQQ=; b=G4zay/EvBXtFIUwSz/uCferu0OcgNSslHqNRcMCrO9UWDt/KXeImhfPeEvMPI1K0Yxb+ k5mYZiTIujY9ylkIBue1DuDL1KJzQfuwhuIH/A9LZn8u39yCA++uaLFRl9M0XcyFc2zK VUoF9KhQKXjCQQKTv/DhdpwHigvUr0QPEDMcM7AmjPJlPtLE0yVTweX2qur8obwdKIIh XdathYKjvsaC35Q/yRlhQNt+WFLbxwDlokD8p3B7ewQUg7XbMIbKi3PmJnIMneX+aCh4 FST9pvmd6oQGxXrRS68CiRBe7HnyE1bS6TvLbcJK8j/uqU3tlwMQFoYofxhuyMe4nQiO jw== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3nfqvj1qk6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Feb 2023 09:42:14 -0600 Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.21; Thu, 2 Feb 2023 09:42:12 -0600 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.21 via Frontend Transport; Thu, 2 Feb 2023 09:42:12 -0600 Received: from edi-sw-dsktp-006.ad.cirrus.com (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.127]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 377BD15A0; Thu, 2 Feb 2023 15:42:12 +0000 (UTC) From: Richard Fitzgerald To: , , , Subject: [PATCH 2/2] soundwire: bandwidth allocation: Use hweight32() to calculate set bits Date: Thu, 2 Feb 2023 15:42:12 +0000 Message-ID: <20230202154212.1098736-3-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230202154212.1098736-1-rf@opensource.cirrus.com> References: <20230202154212.1098736-1-rf@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: uqgusPKHeFYIjWDNcIzxx8WygJvQTzXu X-Proofpoint-ORIG-GUID: uqgusPKHeFYIjWDNcIzxx8WygJvQTzXu X-Proofpoint-Spam-Reason: safe X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, Richard Fitzgerald , linux-kernel@vger.kernel.org Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Replace the call to sdw_ch_mask_to_ch() with a call to hweight32(). sdw_ch_mask_to_ch() is counting the number of set bits. The hweight() family of functions already do this, and they have an advantage of using a bit-counting instruction if it is available on the target CPU. Signed-off-by: Richard Fitzgerald --- drivers/soundwire/bus.h | 11 ----------- drivers/soundwire/generic_bandwidth_allocation.c | 3 ++- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h index 28bedc919b78..4ce8d708a39c 100644 --- a/drivers/soundwire/bus.h +++ b/drivers/soundwire/bus.h @@ -159,17 +159,6 @@ int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg, int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave, u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf); -/* Retrieve and return channel count from channel mask */ -static inline int sdw_ch_mask_to_ch(unsigned int ch_mask) -{ - int c = 0; - - for (c = 0; ch_mask; ch_mask >>= 1) - c += ch_mask & 1; - - return c; -} - /* Fill transport parameter data structure */ static inline void sdw_fill_xport_params(struct sdw_transport_params *params, int port_num, bool grp_ctrl_valid, diff --git a/drivers/soundwire/generic_bandwidth_allocation.c b/drivers/soundwire/generic_bandwidth_allocation.c index f7c66083a4dd..ea3e8ef408e4 100644 --- a/drivers/soundwire/generic_bandwidth_allocation.c +++ b/drivers/soundwire/generic_bandwidth_allocation.c @@ -6,6 +6,7 @@ * */ +#include #include #include #include @@ -54,7 +55,7 @@ static void sdw_compute_slave_ports(struct sdw_master_runtime *m_rt, slave_total_ch = 0; list_for_each_entry(p_rt, &s_rt->port_list, port_node) { - ch = sdw_ch_mask_to_ch(p_rt->ch_mask); + ch = hweight32(p_rt->ch_mask); sdw_fill_xport_params(&p_rt->transport_params, p_rt->num, false,