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@xxxxxxxxxxx> --- 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