gpiolib: Fix missing updates of bitmap index
authorJanusz Krzysztofik <jmkrzyszt@gmail.com>
Sun, 23 Sep 2018 23:53:35 +0000 (01:53 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 24 Sep 2018 11:46:53 +0000 (13:46 +0200)
In new code introduced by commit b17566a6b08b ("gpiolib: Implement fast
processing path in get/set array"), bitmap index is not updated with
next found zero bit position as it should while skipping over pins
already processed via fast bitmap path, possibly resulting in an
infinite loop.  Fix it.

Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c

index ce7fa2db26a731155951a8ea41959f53682f8150..aa0b4b46fccc1203037e121fe26e63233c334b5e 100644 (file)
@@ -2880,8 +2880,8 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,
                        __set_bit(hwgpio, mask);
 
                        if (array_info)
-                               find_next_zero_bit(array_info->get_mask,
-                                                  array_size, i);
+                               i = find_next_zero_bit(array_info->get_mask,
+                                                      array_size, i);
                        else
                                i++;
                } while ((i < array_size) &&
@@ -2905,7 +2905,8 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,
                        trace_gpio_value(desc_to_gpio(desc), 1, value);
 
                        if (array_info)
-                               find_next_zero_bit(array_info->get_mask, i, j);
+                               j = find_next_zero_bit(array_info->get_mask, i,
+                                                      j);
                        else
                                j++;
                }
@@ -3192,8 +3193,8 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,
                        }
 
                        if (array_info)
-                               find_next_zero_bit(array_info->set_mask,
-                                                  array_size, i);
+                               i = find_next_zero_bit(array_info->set_mask,
+                                                      array_size, i);
                        else
                                i++;
                } while ((i < array_size) &&