Merge tag 'gpio-v4.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio

Pull GPIO fixes from Linus Walleij:
"These are hopefully the last GPIO fixes for v4.9. The most important
is that it fixes the UML randconfig builds that have been nagging me
for some time and me being confused about where the problem was really
sitting, now this fix give this nice feeling that everything is solid
and builds fine.

Summary:

- Finally, after being puzzled by a bunch of recurrent UML build
failures on randconfigs from the build robot, Keno Fischer nailed
it: GPIO_DEVRES is optional and depends on HAS_IOMEM even though
many users just unconditionally rely on it to be available. And it
*should* be available: garbage collection is nice for this and it
*certainly* has nothing to do with having IOMEM. So we got rid of
it, and now the UML builds should JustWork(TM).

- Do not call .get_direction() on sleeping GPIO chips on the fastpath
when locking GPIOs for interrupts: it is done from atomic context,
no way.

- Some driver fixes"

* tag 'gpio-v4.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: Remove GPIO_DEVRES option
gpio: tc3589x: fix up .get_direction()
gpio: do not double-check direction on sleeping chips
gpio: pca953x: Move memcpy into mutex lock for set multiple
gpio: pca953x: Fix corruption of other gpios in set_multiple.

+9 -10
-4
drivers/gpio/Kconfig
··· 22 23 if GPIOLIB 24 25 - config GPIO_DEVRES 26 - def_bool y 27 - depends on HAS_IOMEM 28 - 29 config OF_GPIO 30 def_bool y 31 depends on OF
··· 22 23 if GPIOLIB 24 25 config OF_GPIO 26 def_bool y 27 depends on OF
+1 -1
drivers/gpio/Makefile
··· 2 3 ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG 4 5 - obj-$(CONFIG_GPIO_DEVRES) += devres.o 6 obj-$(CONFIG_GPIOLIB) += gpiolib.o 7 obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o 8 obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
··· 2 3 ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG 4 5 + obj-$(CONFIG_GPIOLIB) += devres.o 6 obj-$(CONFIG_GPIOLIB) += gpiolib.o 7 obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o 8 obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
+2 -2
drivers/gpio/gpio-pca953x.c
··· 372 373 bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); 374 375 - memcpy(reg_val, chip->reg_output, NBANK(chip)); 376 mutex_lock(&chip->i2c_lock); 377 for (bank = 0; bank < NBANK(chip); bank++) { 378 bank_mask = mask[bank / sizeof(*mask)] >> 379 ((bank % sizeof(*mask)) * 8); 380 if (bank_mask) { 381 bank_val = bits[bank / sizeof(*bits)] >> 382 ((bank % sizeof(*bits)) * 8); 383 reg_val[bank] = (reg_val[bank] & ~bank_mask) | bank_val; 384 } 385 } ··· 608 609 if (client->irq && irq_base != -1 610 && (chip->driver_data & PCA_INT)) { 611 - 612 ret = pca953x_read_regs(chip, 613 chip->regs->input, chip->irq_stat); 614 if (ret)
··· 372 373 bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); 374 375 mutex_lock(&chip->i2c_lock); 376 + memcpy(reg_val, chip->reg_output, NBANK(chip)); 377 for (bank = 0; bank < NBANK(chip); bank++) { 378 bank_mask = mask[bank / sizeof(*mask)] >> 379 ((bank % sizeof(*mask)) * 8); 380 if (bank_mask) { 381 bank_val = bits[bank / sizeof(*bits)] >> 382 ((bank % sizeof(*bits)) * 8); 383 + bank_val &= bank_mask; 384 reg_val[bank] = (reg_val[bank] & ~bank_mask) | bank_val; 385 } 386 } ··· 607 608 if (client->irq && irq_base != -1 609 && (chip->driver_data & PCA_INT)) { 610 ret = pca953x_read_regs(chip, 611 chip->regs->input, chip->irq_stat); 612 if (ret)
+1 -1
drivers/gpio/gpio-tc3589x.c
··· 97 if (ret < 0) 98 return ret; 99 100 - return !!(ret & BIT(pos)); 101 } 102 103 static int tc3589x_gpio_set_single_ended(struct gpio_chip *chip,
··· 97 if (ret < 0) 98 return ret; 99 100 + return !(ret & BIT(pos)); 101 } 102 103 static int tc3589x_gpio_set_single_ended(struct gpio_chip *chip,
+5 -2
drivers/gpio/gpiolib.c
··· 2737 if (IS_ERR(desc)) 2738 return PTR_ERR(desc); 2739 2740 - /* Flush direction if something changed behind our back */ 2741 - if (chip->get_direction) { 2742 int dir = chip->get_direction(chip, offset); 2743 2744 if (dir)
··· 2737 if (IS_ERR(desc)) 2738 return PTR_ERR(desc); 2739 2740 + /* 2741 + * If it's fast: flush the direction setting if something changed 2742 + * behind our back 2743 + */ 2744 + if (!chip->can_sleep && chip->get_direction) { 2745 int dir = chip->get_direction(chip, offset); 2746 2747 if (dir)