Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1] gpiolib: Deduplicate find_first_zero_bit() call
@ 2020-06-30  9:21 Andy Shevchenko
  2020-06-30 10:39 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2020-06-30  9:21 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio; +Cc: Andy Shevchenko

bitmap_full() is a shortcut to find_first_zero_bit().
Thus, no need to call it twice.

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

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index d4c4e4fb05b6..57e116c7bf9b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2594,10 +2594,9 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,
 			bitmap_xor(value_bitmap, value_bitmap,
 				   array_info->invert_mask, array_size);
 
-		if (bitmap_full(array_info->get_mask, array_size))
-			return 0;
-
 		i = find_first_zero_bit(array_info->get_mask, array_size);
+		if (i == array_size)
+			return 0;
 	} else {
 		array_info = NULL;
 	}
@@ -2878,10 +2877,9 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,
 		gpio_chip_set_multiple(array_info->chip, array_info->set_mask,
 				       value_bitmap);
 
-		if (bitmap_full(array_info->set_mask, array_size))
-			return 0;
-
 		i = find_first_zero_bit(array_info->set_mask, array_size);
+		if (i == array_size)
+			return 0;
 	} else {
 		array_info = NULL;
 	}
-- 
2.27.0


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

* Re: [PATCH v1] gpiolib: Deduplicate find_first_zero_bit() call
  2020-06-30  9:21 [PATCH v1] gpiolib: Deduplicate find_first_zero_bit() call Andy Shevchenko
@ 2020-06-30 10:39 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2020-06-30 10:39 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Linus Walleij, linux-gpio

On Tue, Jun 30, 2020 at 11:22 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> bitmap_full() is a shortcut to find_first_zero_bit().
> Thus, no need to call it twice.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied, thanks!

Bartosz

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30  9:21 [PATCH v1] gpiolib: Deduplicate find_first_zero_bit() call Andy Shevchenko
2020-06-30 10:39 ` Bartosz Golaszewski

Linux-GPIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-gpio/0 linux-gpio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-gpio linux-gpio/ https://lore.kernel.org/linux-gpio \
		linux-gpio@vger.kernel.org
	public-inbox-index linux-gpio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-gpio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git