* [PATCH v2] gpio: lp87565: Set proper output level and direction for direction_output
@ 2017-07-03 8:28 Axel Lin
2017-07-03 8:32 ` Keerthy
2017-07-31 13:27 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2017-07-03 8:28 UTC (permalink / raw)
To: Linus Walleij; +Cc: Keerthy, linux-gpio, Axel Lin
The value argument of lp87565_gpio_direction_output() means output level
rather than gpio direction.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
---
v2: Call lp87565_gpio_set() instead of open-coded.
I move lp87565_gpio_get/lp87565_gpio_set functions up to avoid forward
declaration. It's fine to only move lp87565_gpio_set() but it looks better
for me to move lp87565_gpio_get/lp87565_gpio_set together.
Hope this change is fine.
drivers/gpio/gpio-lp87565.c | 46 +++++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
index 6313c50..a121c8f 100644
--- a/drivers/gpio/gpio-lp87565.c
+++ b/drivers/gpio/gpio-lp87565.c
@@ -26,6 +26,27 @@ struct lp87565_gpio {
struct regmap *map;
};
+static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+ struct lp87565_gpio *gpio = gpiochip_get_data(chip);
+ int ret, val;
+
+ ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val);
+ if (ret < 0)
+ return ret;
+
+ return !!(val & BIT(offset));
+}
+
+static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
+ int value)
+{
+ struct lp87565_gpio *gpio = gpiochip_get_data(chip);
+
+ regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
+ BIT(offset), value ? BIT(offset) : 0);
+}
+
static int lp87565_gpio_get_direction(struct gpio_chip *chip,
unsigned int offset)
{
@@ -54,30 +75,11 @@ static int lp87565_gpio_direction_output(struct gpio_chip *chip,
{
struct lp87565_gpio *gpio = gpiochip_get_data(chip);
+ lp87565_gpio_set(chip, offset, value);
+
return regmap_update_bits(gpio->map,
LP87565_REG_GPIO_CONFIG,
- BIT(offset), !value ? BIT(offset) : 0);
-}
-
-static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
-{
- struct lp87565_gpio *gpio = gpiochip_get_data(chip);
- int ret, val;
-
- ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val);
- if (ret < 0)
- return ret;
-
- return !!(val & BIT(offset));
-}
-
-static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
- int value)
-{
- struct lp87565_gpio *gpio = gpiochip_get_data(chip);
-
- regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
- BIT(offset), value ? BIT(offset) : 0);
+ BIT(offset), BIT(offset));
}
static int lp87565_gpio_request(struct gpio_chip *gc, unsigned int offset)
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] gpio: lp87565: Set proper output level and direction for direction_output
2017-07-03 8:28 [PATCH v2] gpio: lp87565: Set proper output level and direction for direction_output Axel Lin
@ 2017-07-03 8:32 ` Keerthy
2017-07-31 13:27 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Keerthy @ 2017-07-03 8:32 UTC (permalink / raw)
To: Axel Lin, Linus Walleij; +Cc: linux-gpio
On Monday 03 July 2017 01:58 PM, Axel Lin wrote:
> The value argument of lp87565_gpio_direction_output() means output level
> rather than gpio direction.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> Reviewed-by: Keerthy <j-keerthy@ti.com>
> Tested-by: Keerthy <j-keerthy@ti.com>
> ---
> v2: Call lp87565_gpio_set() instead of open-coded.
> I move lp87565_gpio_get/lp87565_gpio_set functions up to avoid forward
> declaration. It's fine to only move lp87565_gpio_set() but it looks better
> for me to move lp87565_gpio_get/lp87565_gpio_set together.
> Hope this change is fine.
Looks good to me.
>
> drivers/gpio/gpio-lp87565.c | 46 +++++++++++++++++++++++----------------------
> 1 file changed, 24 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpio/gpio-lp87565.c b/drivers/gpio/gpio-lp87565.c
> index 6313c50..a121c8f 100644
> --- a/drivers/gpio/gpio-lp87565.c
> +++ b/drivers/gpio/gpio-lp87565.c
> @@ -26,6 +26,27 @@ struct lp87565_gpio {
> struct regmap *map;
> };
>
> +static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
> +{
> + struct lp87565_gpio *gpio = gpiochip_get_data(chip);
> + int ret, val;
> +
> + ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val);
> + if (ret < 0)
> + return ret;
> +
> + return !!(val & BIT(offset));
> +}
> +
> +static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
> + int value)
> +{
> + struct lp87565_gpio *gpio = gpiochip_get_data(chip);
> +
> + regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
> + BIT(offset), value ? BIT(offset) : 0);
> +}
> +
> static int lp87565_gpio_get_direction(struct gpio_chip *chip,
> unsigned int offset)
> {
> @@ -54,30 +75,11 @@ static int lp87565_gpio_direction_output(struct gpio_chip *chip,
> {
> struct lp87565_gpio *gpio = gpiochip_get_data(chip);
>
> + lp87565_gpio_set(chip, offset, value);
> +
> return regmap_update_bits(gpio->map,
> LP87565_REG_GPIO_CONFIG,
> - BIT(offset), !value ? BIT(offset) : 0);
> -}
> -
> -static int lp87565_gpio_get(struct gpio_chip *chip, unsigned int offset)
> -{
> - struct lp87565_gpio *gpio = gpiochip_get_data(chip);
> - int ret, val;
> -
> - ret = regmap_read(gpio->map, LP87565_REG_GPIO_IN, &val);
> - if (ret < 0)
> - return ret;
> -
> - return !!(val & BIT(offset));
> -}
> -
> -static void lp87565_gpio_set(struct gpio_chip *chip, unsigned int offset,
> - int value)
> -{
> - struct lp87565_gpio *gpio = gpiochip_get_data(chip);
> -
> - regmap_update_bits(gpio->map, LP87565_REG_GPIO_OUT,
> - BIT(offset), value ? BIT(offset) : 0);
> + BIT(offset), BIT(offset));
> }
>
> static int lp87565_gpio_request(struct gpio_chip *gc, unsigned int offset)
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] gpio: lp87565: Set proper output level and direction for direction_output
2017-07-03 8:28 [PATCH v2] gpio: lp87565: Set proper output level and direction for direction_output Axel Lin
2017-07-03 8:32 ` Keerthy
@ 2017-07-31 13:27 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2017-07-31 13:27 UTC (permalink / raw)
To: Axel Lin; +Cc: Keerthy, linux-gpio@vger.kernel.org
On Mon, Jul 3, 2017 at 10:28 AM, Axel Lin <axel.lin@ingics.com> wrote:
> The value argument of lp87565_gpio_direction_output() means output level
> rather than gpio direction.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> Reviewed-by: Keerthy <j-keerthy@ti.com>
> Tested-by: Keerthy <j-keerthy@ti.com>
> ---
> v2: Call lp87565_gpio_set() instead of open-coded.
> I move lp87565_gpio_get/lp87565_gpio_set functions up to avoid forward
> declaration. It's fine to only move lp87565_gpio_set() but it looks better
> for me to move lp87565_gpio_get/lp87565_gpio_set together.
> Hope this change is fine.
Patch applied for fixes.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-31 13:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-03 8:28 [PATCH v2] gpio: lp87565: Set proper output level and direction for direction_output Axel Lin
2017-07-03 8:32 ` Keerthy
2017-07-31 13:27 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).