public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] gpio: mmio: restroe get multiple gpio mask
@ 2023-04-23  9:06 Yan Wang
  2023-04-24  6:56 ` Linus Walleij
  2023-04-24 13:31 ` Andy Shevchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Yan Wang @ 2023-04-23  9:06 UTC (permalink / raw)
  To: linus.walleij, brgl
  Cc: Yan Wang, Andy Shevchenko, open list:GPIO SUBSYSTEM, open list

Simplify the code,should not modify its logic.

Fixes: 761b5c30c206 ("gpio: mmio: replace open-coded for_each_set_bit()")
Signed-off-by: Yan Wang <rk.code@outlook.com>
---
 drivers/gpio/gpio-mmio.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
index d9dff3dc92ae..c2347ef3a4df 100644
--- a/drivers/gpio/gpio-mmio.c
+++ b/drivers/gpio/gpio-mmio.c
@@ -271,10 +271,14 @@ static void bgpio_multiple_get_masks(struct gpio_chip *gc,
 	*clear_mask = 0;
 
 	for_each_set_bit(i, mask, gc->bgpio_bits) {
-		if (test_bit(i, bits))
-			*set_mask |= bgpio_line2mask(gc, i);
-		else
-			*clear_mask |= bgpio_line2mask(gc, i);
+		if (*mask == 0)
+			break;
+		if (__test_and_clear_bit(i, mask)) {
+			if (test_bit(i, bits))
+				*set_mask |= bgpio_line2mask(gc, i);
+			else
+				*clear_mask |= bgpio_line2mask(gc, i);
+		}
 	}
 }
 
-- 
2.17.1


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

end of thread, other threads:[~2023-04-24 14:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-23  9:06 [PATCH v1] gpio: mmio: restroe get multiple gpio mask Yan Wang
2023-04-24  6:56 ` Linus Walleij
2023-04-24  9:03   ` Yan Wang
2023-04-24 13:31 ` Andy Shevchenko
2023-04-24 14:21   ` Yan Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox