All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] gpiolib: Make use of assign_bit() API (part 2)
@ 2021-05-18  8:46 Andy Shevchenko
  2021-05-18 23:39 ` Linus Walleij
  2021-05-21 12:55 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2021-05-18  8:46 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

We have for some time the assign_bit() API to replace open coded

	if (foo)
		set_bit(n, bar);
	else
		clear_bit(n, bar);

Use this API in GPIO library code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib-sysfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 41b3b782bf3f..7c5afd999210 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -312,10 +312,7 @@ static int gpio_sysfs_set_active_low(struct device *dev, int value)
 	if (!!test_bit(FLAG_ACTIVE_LOW, &desc->flags) == !!value)
 		return 0;
 
-	if (value)
-		set_bit(FLAG_ACTIVE_LOW, &desc->flags);
-	else
-		clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
+	assign_bit(FLAG_ACTIVE_LOW, &desc->flags, value);
 
 	/* reconfigure poll(2) support if enabled on one edge only */
 	if (flags == GPIO_IRQF_TRIGGER_FALLING ||
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] gpiolib: Make use of assign_bit() API (part 2)
  2021-05-18  8:46 [PATCH v1 1/1] gpiolib: Make use of assign_bit() API (part 2) Andy Shevchenko
@ 2021-05-18 23:39 ` Linus Walleij
  2021-05-21 12:55 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2021-05-18 23:39 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: open list:GPIO SUBSYSTEM, linux-kernel, Bartosz Golaszewski

On Tue, May 18, 2021 at 10:46 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> We have for some time the assign_bit() API to replace open coded
>
>         if (foo)
>                 set_bit(n, bar);
>         else
>                 clear_bit(n, bar);
>
> Use this API in GPIO library code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Now I understand what assign_bit() is for...
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1 1/1] gpiolib: Make use of assign_bit() API (part 2)
  2021-05-18  8:46 [PATCH v1 1/1] gpiolib: Make use of assign_bit() API (part 2) Andy Shevchenko
  2021-05-18 23:39 ` Linus Walleij
@ 2021-05-21 12:55 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2021-05-21 12:55 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-gpio, LKML, Linus Walleij

On Tue, May 18, 2021 at 10:46 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> We have for some time the assign_bit() API to replace open coded
>
>         if (foo)
>                 set_bit(n, bar);
>         else
>                 clear_bit(n, bar);
>
> Use this API in GPIO library code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpiolib-sysfs.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
> index 41b3b782bf3f..7c5afd999210 100644
> --- a/drivers/gpio/gpiolib-sysfs.c
> +++ b/drivers/gpio/gpiolib-sysfs.c
> @@ -312,10 +312,7 @@ static int gpio_sysfs_set_active_low(struct device *dev, int value)
>         if (!!test_bit(FLAG_ACTIVE_LOW, &desc->flags) == !!value)
>                 return 0;
>
> -       if (value)
> -               set_bit(FLAG_ACTIVE_LOW, &desc->flags);
> -       else
> -               clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
> +       assign_bit(FLAG_ACTIVE_LOW, &desc->flags, value);
>
>         /* reconfigure poll(2) support if enabled on one edge only */
>         if (flags == GPIO_IRQF_TRIGGER_FALLING ||
> --
> 2.30.2
>

Patch applied, thanks!

Bartosz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-21 12:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18  8:46 [PATCH v1 1/1] gpiolib: Make use of assign_bit() API (part 2) Andy Shevchenko
2021-05-18 23:39 ` Linus Walleij
2021-05-21 12:55 ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.