[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <45fa162856814176045ffbb49ee64cf0ea7e00bc.1637592133.git.geert+renesas@glider.be>
Date: Mon, 22 Nov 2021 16:54:09 +0100
From: Geert Uytterhoeven <geert+renesas@...der.be>
To: Tony Lindgren <tony@...mide.com>,
Russell King <linux@...linux.org.uk>,
Rajendra Nayak <rnayak@...eaurora.org>,
Paul Walmsley <paul@...an.com>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Ludovic Desroches <ludovic.desroches@...rochip.com>,
Tero Kristo <kristo@...nel.org>,
Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>,
Lorenzo Bianconi <lorenzo.bianconi83@...il.com>,
Benoit Parrot <bparrot@...com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Andrew Jeffery <andrew@...id.au>,
Ulf Hansson <ulf.hansson@...aro.org>,
Joel Stanley <joel@....id.au>,
Ping-Ke Shih <pkshih@...ltek.com>,
Kalle Valo <kvalo@...eaurora.org>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Magnus Damm <magnus.damm@...il.com>,
Eduardo Valentin <edubezval@...il.com>,
Keerthy <j-keerthy@...com>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>
Cc: linux-arm-kernel@...ts.infradead.org, linux-omap@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-clk@...r.kernel.org,
linux-renesas-soc@...r.kernel.org, linux-iio@...r.kernel.org,
linux-media@...r.kernel.org, linux-mmc@...r.kernel.org,
linux-aspeed@...ts.ozlabs.org, openbmc@...ts.ozlabs.org,
linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
linux-gpio@...r.kernel.org, linux-pm@...r.kernel.org,
alsa-devel@...a-project.org,
Geert Uytterhoeven <geert+renesas@...der.be>
Subject: [PATCH/RFC 16/17] ALSA: ice1724: Use bitfield helpers
Use the field_{get,prep}() helpers, instead of open-coding the same
operations.
Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
---
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 <linux@...nbow-software.org>
*/
+#include <linux/bitfield.h>
#include <linux/delay.h>
#include <sound/core.h>
#include <sound/control.h>
@@ -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 <linux@...nbow-software.org>
*/
+#include <linux/bitfield.h>
#include <linux/delay.h>
#include <sound/core.h>
#include <sound/control.h>
@@ -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);
--
2.25.1
Powered by blists - more mailing lists