diff mbox series

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

Message ID 20200131122918.7127-2-axel.lin@ingics.com
State New
Headers show
Series None | expand

Commit Message

Axel Lin Jan. 31, 2020, 12:29 p.m. UTC
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.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/gpio/gpio-wcd934x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Srinivas Kandagatla Feb. 4, 2020, 10:33 a.m. UTC | #1
Thanks for the patch!

On 31/01/2020 12:29, Axel Lin wrote:
> 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.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>


> ---
>   drivers/gpio/gpio-wcd934x.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-wcd934x.c b/drivers/gpio/gpio-wcd934x.c
> index 9d4ec8941b9b..1cbce5990855 100644
> --- a/drivers/gpio/gpio-wcd934x.c
> +++ b/drivers/gpio/gpio-wcd934x.c
> @@ -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)
>
Bartosz Golaszewski Feb. 4, 2020, 2:19 p.m. UTC | #2
wt., 4 lut 2020 o 11:33 Srinivas Kandagatla
<srinivas.kandagatla@linaro.org> napisaƂ(a):
>
> Thanks for the patch!
>
> On 31/01/2020 12:29, Axel Lin wrote:
> > 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.
> >
> > Signed-off-by: Axel Lin <axel.lin@ingics.com>
>
> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>

Applied with Srinivas' tag.

Bartosz
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-wcd934x.c b/drivers/gpio/gpio-wcd934x.c
index 9d4ec8941b9b..1cbce5990855 100644
--- a/drivers/gpio/gpio-wcd934x.c
+++ b/drivers/gpio/gpio-wcd934x.c
@@ -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)