processing.  If yes, a bitmap is passed over get/set array functions directly
 between a caller and a respective .get/set_multiple() callback of a GPIO chip.
 
-In order to qualify for fast bitmap processing, the pin mapping must meet the
+In order to qualify for fast bitmap processing, the array must meet the
 following requirements:
-- it must belong to the same chip as other 'fast' pins of the function,
-- its index within the function must match its hardware number within the chip.
-
-Open drain and open source pins are excluded from fast bitmap output processing.
+- pin hardware number of array member 0 must also be 0,
+- pin hardware numbers of consecutive array members which belong to the same
+  chip as member 0 does must also match their array indexes.
+
+Otherwise fast bitmap processing path is not used in order to avoid consecutive
+pins which belong to the same chip but are not in hardware order being processed
+separately.
+
+If the array applies for fast bitmap processing path, pins which belong to
+different chips than member 0 does, as well as those with indexes different from
+their hardware pin numbers, are excluded from the fast path, both input and
+output.  Moreover, open drain and open source pins are excluded from fast bitmap
+output processing.
 
 
                chip = gpiod_to_chip(desc);
                /*
-                * Select a chip of first array member
-                * whose index matches its pin hardware number
-                * as a candidate for fast bitmap processing.
+                * If pin hardware number of array member 0 is also 0, select
+                * its chip as a candidate for fast bitmap processing path.
                 */
-               if (!array_info && gpio_chip_hwgpio(desc) == descs->ndescs) {
+               if (descs->ndescs == 0 && gpio_chip_hwgpio(desc) == 0) {
                        struct gpio_descs *array;
 
                        bitmap_size = BITS_TO_LONGS(chip->ngpio > count ?
                                   count - descs->ndescs);
                        descs->info = array_info;
                }
-               /*
-                * Unmark members which don't qualify for fast bitmap
-                * processing (different chip, not in hardware order)
-                */
-               if (array_info && (chip != array_info->chip ||
-                   gpio_chip_hwgpio(desc) != descs->ndescs)) {
+               /* Unmark array members which don't belong to the 'fast' chip */
+               if (array_info && array_info->chip != chip) {
                        __clear_bit(descs->ndescs, array_info->get_mask);
                        __clear_bit(descs->ndescs, array_info->set_mask);
+               }
+               /*
+                * Detect array members which belong to the 'fast' chip
+                * but their pins are not in hardware order.
+                */
+               else if (array_info &&
+                          gpio_chip_hwgpio(desc) != descs->ndescs) {
+                       /*
+                        * Don't use fast path if all array members processed so
+                        * far belong to the same chip as this one but its pin
+                        * hardware number is different from its array index.
+                        */
+                       if (bitmap_full(array_info->get_mask, descs->ndescs)) {
+                               array_info = NULL;
+                       } else {
+                               __clear_bit(descs->ndescs,
+                                           array_info->get_mask);
+                               __clear_bit(descs->ndescs,
+                                           array_info->set_mask);
+                       }
                } else if (array_info) {
                        /* Exclude open drain or open source from fast output */
                        if (gpiochip_line_is_open_drain(chip, descs->ndescs) ||