From patchwork Mon Nov 22 15:54:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12632267 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 C38E9C4321E for ; Mon, 22 Nov 2021 15:55:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240126AbhKVP6T (ORCPT ); Mon, 22 Nov 2021 10:58:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240113AbhKVP6M (ORCPT ); Mon, 22 Nov 2021 10:58:12 -0500 Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A12EAC061757 for ; Mon, 22 Nov 2021 07:55:04 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed20:e4da:38c:79e9:48bf]) by laurent.telenet-ops.be with bizsmtp id MTuK2600N4yPVd601TuKeF; Mon, 22 Nov 2021 16:55:02 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1mpBe6-00EL3q-UU; Mon, 22 Nov 2021 16:54:18 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1mpBe5-00HH2H-UD; Mon, 22 Nov 2021 16:54:17 +0100 From: Geert Uytterhoeven To: Tony Lindgren , Russell King , Rajendra Nayak , Paul Walmsley , Michael Turquette , Stephen Boyd , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Tero Kristo , Jonathan Cameron , Lars-Peter Clausen , Lorenzo Bianconi , Benoit Parrot , Mauro Carvalho Chehab , Adrian Hunter , Andrew Jeffery , Ulf Hansson , Joel Stanley , Ping-Ke Shih , Kalle Valo , "David S . Miller" , Jakub Kicinski , Linus Walleij , Liam Girdwood , Mark Brown , Magnus Damm , Eduardo Valentin , Keerthy , "Rafael J . Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Jaroslav Kysela , Takashi Iwai Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-iio@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-pm@vger.kernel.org, alsa-devel@alsa-project.org, Geert Uytterhoeven Subject: [PATCH/RFC 16/17] ALSA: ice1724: Use bitfield helpers Date: Mon, 22 Nov 2021 16:54:09 +0100 Message-Id: <45fa162856814176045ffbb49ee64cf0ea7e00bc.1637592133.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use the field_{get,prep}() helpers, instead of open-coding the same operations. Signed-off-by: Geert Uytterhoeven Acked-by: Takashi Iwai --- Compile-tested only. Marked RFC, as this depends on [PATCH 01/17], but follows a different path to upstream. --- sound/pci/ice1712/wm8766.c | 14 +++++++------- sound/pci/ice1712/wm8776.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sound/pci/ice1712/wm8766.c b/sound/pci/ice1712/wm8766.c index fe3e243b38549035..3e4d7f8f692785b0 100644 --- a/sound/pci/ice1712/wm8766.c +++ b/sound/pci/ice1712/wm8766.c @@ -7,6 +7,7 @@ * Copyright (c) 2012 Ondrej Zary */ +#include #include #include #include @@ -212,11 +213,10 @@ static int snd_wm8766_ctl_get(struct snd_kcontrol *kcontrol, if (wm->ctl[n].get) wm->ctl[n].get(wm, &val1, &val2); else { - val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1; - val1 >>= __ffs(wm->ctl[n].mask1); + val1 = field_get(wm->ctl[n].mask1, wm->regs[wm->ctl[n].reg1]); if (wm->ctl[n].flags & WM8766_FLAG_STEREO) { - val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2; - val2 >>= __ffs(wm->ctl[n].mask2); + val2 = field_get(wm->ctl[n].mask2, + wm->regs[wm->ctl[n].reg2]); if (wm->ctl[n].flags & WM8766_FLAG_VOL_UPDATE) val2 &= ~WM8766_VOL_UPDATE; } @@ -251,19 +251,19 @@ static int snd_wm8766_ctl_put(struct snd_kcontrol *kcontrol, wm->ctl[n].set(wm, regval1, regval2); else { val = wm->regs[wm->ctl[n].reg1] & ~wm->ctl[n].mask1; - val |= regval1 << __ffs(wm->ctl[n].mask1); + val |= field_prep(wm->ctl[n].mask1, regval1); /* both stereo controls in one register */ if (wm->ctl[n].flags & WM8766_FLAG_STEREO && wm->ctl[n].reg1 == wm->ctl[n].reg2) { val &= ~wm->ctl[n].mask2; - val |= regval2 << __ffs(wm->ctl[n].mask2); + val |= field_prep(wm->ctl[n].mask2, regval2); } snd_wm8766_write(wm, wm->ctl[n].reg1, val); /* stereo controls in different registers */ if (wm->ctl[n].flags & WM8766_FLAG_STEREO && wm->ctl[n].reg1 != wm->ctl[n].reg2) { val = wm->regs[wm->ctl[n].reg2] & ~wm->ctl[n].mask2; - val |= regval2 << __ffs(wm->ctl[n].mask2); + val |= field_prep(wm->ctl[n].mask2, regval2); if (wm->ctl[n].flags & WM8766_FLAG_VOL_UPDATE) val |= WM8766_VOL_UPDATE; snd_wm8766_write(wm, wm->ctl[n].reg2, val); diff --git a/sound/pci/ice1712/wm8776.c b/sound/pci/ice1712/wm8776.c index 6eda86119dff60b3..b4edf8a03c342351 100644 --- a/sound/pci/ice1712/wm8776.c +++ b/sound/pci/ice1712/wm8776.c @@ -7,6 +7,7 @@ * Copyright (c) 2012 Ondrej Zary */ +#include #include #include #include @@ -486,11 +487,10 @@ static int snd_wm8776_ctl_get(struct snd_kcontrol *kcontrol, if (wm->ctl[n].get) wm->ctl[n].get(wm, &val1, &val2); else { - val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1; - val1 >>= __ffs(wm->ctl[n].mask1); + val1 = field_get(wm->ctl[n].mask1, wm->regs[wm->ctl[n].reg1]); if (wm->ctl[n].flags & WM8776_FLAG_STEREO) { - val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2; - val2 >>= __ffs(wm->ctl[n].mask2); + val2 = field_get(wm->ctl[n].mask2, + wm->regs[wm->ctl[n].reg2]); if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE) val2 &= ~WM8776_VOL_UPDATE; } @@ -525,19 +525,19 @@ static int snd_wm8776_ctl_put(struct snd_kcontrol *kcontrol, wm->ctl[n].set(wm, regval1, regval2); else { val = wm->regs[wm->ctl[n].reg1] & ~wm->ctl[n].mask1; - val |= regval1 << __ffs(wm->ctl[n].mask1); + val |= field_prep(wm->ctl[n].mask1, regval1); /* both stereo controls in one register */ if (wm->ctl[n].flags & WM8776_FLAG_STEREO && wm->ctl[n].reg1 == wm->ctl[n].reg2) { val &= ~wm->ctl[n].mask2; - val |= regval2 << __ffs(wm->ctl[n].mask2); + val |= field_prep(wm->ctl[n].mask2, regval2); } snd_wm8776_write(wm, wm->ctl[n].reg1, val); /* stereo controls in different registers */ if (wm->ctl[n].flags & WM8776_FLAG_STEREO && wm->ctl[n].reg1 != wm->ctl[n].reg2) { val = wm->regs[wm->ctl[n].reg2] & ~wm->ctl[n].mask2; - val |= regval2 << __ffs(wm->ctl[n].mask2); + val |= field_prep(wm->ctl[n].mask2, regval2); if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE) val |= WM8776_VOL_UPDATE; snd_wm8776_write(wm, wm->ctl[n].reg2, val);