From patchwork Mon Dec 29 18:41:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 5550271 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0BFB5BF6C3 for ; Mon, 29 Dec 2014 19:47:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A00F2016C for ; Mon, 29 Dec 2014 19:47:41 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0FC5C20121 for ; Mon, 29 Dec 2014 19:47:40 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2F43726516B; Mon, 29 Dec 2014 20:47:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D1E882606C2; Mon, 29 Dec 2014 20:32:44 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 22BC62606BD; Mon, 29 Dec 2014 20:32:42 +0100 (CET) Received: from smtp-out-184.synserver.de (smtp-out-184.synserver.de [212.40.185.184]) by alsa0.perex.cz (Postfix) with ESMTP id B5928261A50 for ; Mon, 29 Dec 2014 19:41:54 +0100 (CET) Received: (qmail 19231 invoked by uid 0); 29 Dec 2014 18:41:54 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 18895 Received: from ppp-88-217-12-186.dynamic.mnet-online.de (HELO lars-adi-laptop.fritz.box) [88.217.12.186] by 217.119.54.96 with SMTP; 29 Dec 2014 18:41:54 -0000 From: Lars-Peter Clausen To: Jaroslav Kysela , Takashi Iwai Date: Mon, 29 Dec 2014 19:41:46 +0100 Message-Id: <1419878506-28684-9-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1419878506-28684-1-git-send-email-lars@metafoo.de> References: <1419878506-28684-1-git-send-email-lars@metafoo.de> Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen Subject: [alsa-devel] [PATCH 9/9] ALSA: pcm: Replace custom ld2 function with __fls X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP __fls has the same semantics as ld2, so there is no need to re-implement it. Furthermore a lot of architectures have custom implementations of __fls that are able to use special hardware instructions to compute the result. This makes the code slightly shorter and faster. Signed-off-by: Lars-Peter Clausen --- include/sound/pcm_params.h | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h index c99e20b..3c45f39 100644 --- a/include/sound/pcm_params.h +++ b/include/sound/pcm_params.h @@ -38,31 +38,6 @@ int snd_pcm_hw_param_value(const struct snd_pcm_hw_params *params, #define MASK_OFS(i) ((i) >> 5) #define MASK_BIT(i) (1U << ((i) & 31)) -static inline unsigned int ld2(u_int32_t v) -{ - unsigned r = 0; - - if (v >= 0x10000) { - v >>= 16; - r += 16; - } - if (v >= 0x100) { - v >>= 8; - r += 8; - } - if (v >= 0x10) { - v >>= 4; - r += 4; - } - if (v >= 4) { - v >>= 2; - r += 2; - } - if (v >= 2) - r++; - return r; -} - static inline size_t snd_mask_sizeof(void) { return sizeof(struct snd_mask); @@ -102,7 +77,7 @@ static inline unsigned int snd_mask_max(const struct snd_mask *mask) int i; for (i = SNDRV_MASK_SIZE - 1; i >= 0; i--) { if (mask->bits[i]) - return ld2(mask->bits[i]) + (i << 5); + return __fls(mask->bits[i]) + (i << 5); } return 0; }