[alsa-devel] [PATCH 6/7] ASoC: wm8962: remove bitwise operations involving GPIO level value

Vladimir Zapolskiy vz at mleia.com
Tue Jun 2 01:09:17 CEST 2015


The main intention of the change is to remove bitwise operations on
GPIO level value as a preceding change before updating gpiolib
callbacks to utilize bool type to represent GPIO level.

No functional change.

Signed-off-by: Vladimir Zapolskiy <vz at mleia.com>
Cc: Charles Keepax <ckeepax at opensource.wolfsonmicro.com>
Cc: Lars-Peter Clausen <lars at metafoo.de>
Cc: Axel Lin <axel.lin at ingics.com>
Cc: patches at opensource.wolfsonmicro.com
---
 sound/soc/codecs/wm8962.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index c5748fd..ad619e6 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3341,9 +3341,13 @@ static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
 	struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
 	struct snd_soc_codec *codec = wm8962->codec;
+	unsigned int val = 0;
+
+	if (value)
+		val = 0x1 << WM8962_GP2_LVL_SHIFT;
 
 	snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset,
-			    WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT);
+			    WM8962_GP2_LVL, val);
 }
 
 static int wm8962_gpio_direction_out(struct gpio_chip *chip,
@@ -3351,10 +3355,11 @@ static int wm8962_gpio_direction_out(struct gpio_chip *chip,
 {
 	struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
 	struct snd_soc_codec *codec = wm8962->codec;
-	int ret, val;
+	unsigned int val = 0x1 << WM8962_GP2_FN_SHIFT;
+	int ret;
 
-	/* Force function 1 (logic output) */
-	val = (1 << WM8962_GP2_FN_SHIFT) | (value << WM8962_GP2_LVL_SHIFT);
+	if (value)
+		val |= 0x1 << WM8962_GP2_LVL_SHIFT;
 
 	ret = snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset,
 				  WM8962_GP2_FN_MASK | WM8962_GP2_LVL, val);
-- 
2.1.4



More information about the Alsa-devel mailing list