Skip to contentSkip to conversation

gpio: wcd934x: Don't change gpio direction in wcd_gpio_set

PATCH In review Axel Lin 3 participants 6 messages Jan 31, 2020 – Feb 4, 2020 GPIO

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 gpio: wcd934x: Don't change gpio direction in wcd_gpio_set

The .set callback should just set output value.

---
Hi Srinivas,
I don't have this h/w to test, so please help to review and test the patchs. Thanks,
Axel

 drivers/gpio/gpio-wcd934x.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-wcd934x.c +4 -1
index 74913f2e5697..9d4ec8941b9b 100644
@@ -66,7 +66,10 @@ static int wcd_gpio_get(struct gpio_chip *chip, unsigned int pin)
 
 static void wcd_gpio_set(struct gpio_chip *chip, unsigned int pin, int val)
 {
-	wcd_gpio_direction_output(chip, pin, val);
+	struct wcd_gpio_data *data = gpiochip_get_data(chip);
+
+	regmap_update_bits(data->map, WCD_REG_VAL_CTL_OFFSET,
+			   WCD_PIN_MASK(pin), val ? WCD_PIN_MASK(pin) : 0);
 }
 
 static int wcd_gpio_probe(struct platform_device *pdev)
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 2/2 gpio: wcd934x: Fix logic of wcd_gpio_get

The check with register value and mask should be & rather than &&. While at it, also use "unsigned int" for value variable because regmap_read() takes unsigned int *val argument.

---
 drivers/gpio/gpio-wcd934x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-wcd934x.c +2 -2
index 9d4ec8941b9b..1cbce5990855 100644
@@ -57,11 +57,11 @@ static int wcd_gpio_direction_output(struct gpio_chip *chip, unsigned int pin,
 static int wcd_gpio_get(struct gpio_chip *chip, unsigned int pin)
 {
 	struct wcd_gpio_data *data = gpiochip_get_data(chip);
-	int value;
+	unsigned int value;
 
 	regmap_read(data->map, WCD_REG_VAL_CTL_OFFSET, &value);
 
-	return !!(value && WCD_PIN_MASK(pin));
+	return !!(value & WCD_PIN_MASK(pin));
 }
 
 static void wcd_gpio_set(struct gpio_chip *chip, unsigned int pin, int val)
Signature · 1 line
2.20.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] gpio: wcd934x: Fix logic of wcd_gpio_get

Thanks for the patch!

Quoted 5 lines · Axel Lin

The check with register value and mask should be & rather than &&. While at it, also use "unsigned int" for value variable because regmap_read() takes unsigned int *val argument.

Quoted 23 lines
---
  drivers/gpio/gpio-wcd934x.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-wcd934x.c +2 -2
index 9d4ec8941b9b..1cbce5990855 100644
@@ -57,11 +57,11 @@ static int wcd_gpio_direction_output(struct gpio_chip *chip, unsigned int pin,
  static int wcd_gpio_get(struct gpio_chip *chip, unsigned int pin)
  {
  	struct wcd_gpio_data *data = gpiochip_get_data(chip);
-	int value;
+	unsigned int value;
 
  	regmap_read(data->map, WCD_REG_VAL_CTL_OFFSET, &value);
 
-	return !!(value && WCD_PIN_MASK(pin));
+	return !!(value & WCD_PIN_MASK(pin));
  }
 
  static void wcd_gpio_set(struct gpio_chip *chip, unsigned int pin, int val)
#3 lore raw

Re: [PATCH 2/2] gpio: wcd934x: Fix logic of wcd_gpio_get

wt., 4 lut 2020 o 11:33 Srinivas Kandagatla
<[email protected]> napisał(a):

Quoted 12 lines

Thanks for the patch!

Quoted 5 lines · Axel Lin

The check with register value and mask should be & rather than &&. While at it, also use "unsigned int" for value variable because regmap_read() takes unsigned int *val argument.

Applied with Srinivas' tag.

Bartosz

Reviewed-by on v1 1/2
#4 lore raw
In reply to Axel Lin

Thanks for the patch!

Quoted 3 lines · Axel Lin

The .set callback should just set output value.

Quoted 25 lines

---
Hi Srinivas,
I don't have this h/w to test, so please help to review and test the patchs. Thanks,
Axel

  drivers/gpio/gpio-wcd934x.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-wcd934x.c +4 -1
index 74913f2e5697..9d4ec8941b9b 100644
@@ -66,7 +66,10 @@ static int wcd_gpio_get(struct gpio_chip *chip, unsigned int pin)
 
  static void wcd_gpio_set(struct gpio_chip *chip, unsigned int pin, int val)
  {
-	wcd_gpio_direction_output(chip, pin, val);
+	struct wcd_gpio_data *data = gpiochip_get_data(chip);
+
+	regmap_update_bits(data->map, WCD_REG_VAL_CTL_OFFSET,
+			   WCD_PIN_MASK(pin), val ? WCD_PIN_MASK(pin) : 0);
  }
 
  static int wcd_gpio_probe(struct platform_device *pdev)