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

Vladimir Zapolskiy vz at mleia.com
Tue Jun 2 01:09:16 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/wm5100.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c
index 4c10cd8..fae9d13 100644
--- a/sound/soc/codecs/wm5100.c
+++ b/sound/soc/codecs/wm5100.c
@@ -2244,26 +2244,27 @@ static inline struct wm5100_priv *gpio_to_wm5100(struct gpio_chip *chip)
 static void wm5100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
 	struct wm5100_priv *wm5100 = gpio_to_wm5100(chip);
+	unsigned int val = 0;
+
+	if (value)
+		val = 0x1 << WM5100_GP1_LVL_SHIFT;
 
 	regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset,
-			   WM5100_GP1_LVL, !!value << WM5100_GP1_LVL_SHIFT);
+			   WM5100_GP1_LVL, val);
 }
 
 static int wm5100_gpio_direction_out(struct gpio_chip *chip,
 				     unsigned offset, int value)
 {
 	struct wm5100_priv *wm5100 = gpio_to_wm5100(chip);
-	int val, ret;
+	unsigned int val = 0x1 << WM5100_GP1_FN_SHIFT;
 
-	val = (1 << WM5100_GP1_FN_SHIFT) | (!!value << WM5100_GP1_LVL_SHIFT);
+	if (value)
+		val |= 0x1 << WM5100_GP1_LVL_SHIFT;
 
-	ret = regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset,
-				 WM5100_GP1_FN_MASK | WM5100_GP1_DIR |
-				 WM5100_GP1_LVL, val);
-	if (ret < 0)
-		return ret;
-	else
-		return 0;
+	return regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset,
+				  WM5100_GP1_FN_MASK | WM5100_GP1_DIR |
+				  WM5100_GP1_LVL, val);
 }
 
 static int wm5100_gpio_get(struct gpio_chip *chip, unsigned offset)
-- 
2.1.4



More information about the Alsa-devel mailing list