[PATCH 4/7] ASoC: wm8903: simplify gpiolib callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The change cleans up gpiolib callbacks, and the main intention is to
remove bitwise operations on GPIO level value as a preceding change to
switch gpiolib callbacks to utilize bool type to represent GPIO level.

No functional change.

Signed-off-by: Vladimir Zapolskiy <vz@xxxxxxxxx>
Cc: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Cc: Lars-Peter Clausen <lars@xxxxxxxxxx>
Cc: Axel Lin <axel.lin@xxxxxxxxxx>
Cc: patches@xxxxxxxxxxxxxxxxxxxxxxxxxxx
---
 sound/soc/codecs/wm8903.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 93f1ce0..efac26b 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -1783,18 +1783,13 @@ static int wm8903_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
 {
 	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
 	unsigned int mask, val;
-	int ret;
 
 	mask = WM8903_GPn_FN_MASK | WM8903_GPn_DIR_MASK;
 	val = (WM8903_GPn_FN_GPIO_INPUT << WM8903_GPn_FN_SHIFT) |
 		WM8903_GPn_DIR;
 
-	ret = regmap_update_bits(wm8903->regmap,
-				 WM8903_GPIO_CONTROL_1 + offset, mask, val);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return regmap_update_bits(wm8903->regmap,
+				  WM8903_GPIO_CONTROL_1 + offset, mask, val);
 }
 
 static int wm8903_gpio_get(struct gpio_chip *chip, unsigned offset)
@@ -1812,27 +1807,26 @@ static int wm8903_gpio_direction_out(struct gpio_chip *chip,
 {
 	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
 	unsigned int mask, val;
-	int ret;
 
 	mask = WM8903_GPn_FN_MASK | WM8903_GPn_DIR_MASK | WM8903_GPn_LVL_MASK;
-	val = (WM8903_GPn_FN_GPIO_OUTPUT << WM8903_GPn_FN_SHIFT) |
-		(value << WM8903_GPn_LVL_SHIFT);
+	val = WM8903_GPn_FN_GPIO_OUTPUT << WM8903_GPn_FN_SHIFT;
+	if (value)
+		val |= 0x1 << WM8903_GPn_LVL_SHIFT;
 
-	ret = regmap_update_bits(wm8903->regmap,
-				 WM8903_GPIO_CONTROL_1 + offset, mask, val);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return regmap_update_bits(wm8903->regmap,
+				  WM8903_GPIO_CONTROL_1 + offset, mask, val);
 }
 
 static void wm8903_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
 	struct wm8903_priv *wm8903 = gpio_to_wm8903(chip);
+	unsigned int val = 0;
+
+	if (value)
+		val = 0x1 << WM8903_GPn_LVL_SHIFT;
 
 	regmap_update_bits(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset,
-			   WM8903_GPn_LVL_MASK,
-			   !!value << WM8903_GPn_LVL_SHIFT);
+			   WM8903_GPn_LVL_MASK, val);
 }
 
 static struct gpio_chip wm8903_template_chip = {
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux