gpio fixes for v5.19-rc8

- fix several regmap usage issues in gpio-pca953x
 - fix out-of-tree build for GPIO selftests
 - fix integer overflow in gpio-xilinx
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmLawUgACgkQEacuoBRx
 13JzrRAAnQSIVnIPqMiQ/I0+zQW72SVajxp43j8Buq6ls6V+TjpZ376JJWDw9h/Y
 M9rSY5J2H/ENkiid9473/ibAvE3m3OXuq8Jn6arKiuce/7ziTBW7KdrB3a30eZqo
 Y6c6mPxSOilVnSqtN+SyfOjBW9J1/LP+TU+lYib/rw+hWm9GxR6qCQRocV0VWXiM
 YK1TA6lRfGPMj8Y0shQ2Lz3B9k1QlZ3L2GxlKkRmPSiDiF+ihx7Y9W0mAhp7Q5ds
 W19+FnZYkoYYWf6sebAeqL9Ha350T/KbWv5iNng2CcpF/WXazvY1GYNXfGpdHVIa
 v+GObHv8bgc04keJ4rrJzjMDKcJTDWVk7aKrI4V3hHTktmm5h5xZzY4IOJnBEKYu
 X85YJ+CZ7oxvSLeG2eccJkCalrD4QCgJ3NLdRojPEWuq1bG3Dcf+KdP67wguObB/
 G5F0fyJFWAXOdf1uIHf9GOvAVhDBHsHvvmcPp6fMYaAWSgv3t+wmxotaMViifAVY
 +/cPrr9J03geQuRUVLOz6U/iVoX6fy8SRJg9Hmx+cBZtMMdi0TdRtJwnY2zymwY8
 6bNpC+ZRON7pP1ewhS6Dp/87AtukgpVxyRf2ihJv2/fzIA7Kc5AYpYXgYKYEJpVi
 B0kO226C4y033SRc0Rd2uq/0/iqkmAA+lp0Gcd/H8ng7zpGyiZM=
 =ZSY3
 -----END PGP SIGNATURE-----

Merge tag 'gpio-fixes-for-v5.19-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

 - fix several regmap usage issues in gpio-pca953x

 - fix out-of-tree build for GPIO selftests

 - fix integer overflow in gpio-xilinx

* tag 'gpio-fixes-for-v5.19-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpio: gpio-xilinx: Fix integer overflow
  selftests: gpio: fix include path to kernel headers for out of tree builds
  gpio: pca953x: use the correct register address when regcache sync during init
  gpio: pca953x: use the correct range when do regmap sync
  gpio: pca953x: only use single read/write for No AI mode
This commit is contained in:
Linus Torvalds 2022-07-22 12:28:47 -07:00
commit 6f8e4e1043
3 changed files with 16 additions and 10 deletions

View File

@ -351,6 +351,9 @@ static const struct regmap_config pca953x_i2c_regmap = {
.reg_bits = 8,
.val_bits = 8,
.use_single_read = true,
.use_single_write = true,
.readable_reg = pca953x_readable_register,
.writeable_reg = pca953x_writeable_register,
.volatile_reg = pca953x_volatile_register,
@ -906,15 +909,18 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
static int device_pca95xx_init(struct pca953x_chip *chip, u32 invert)
{
DECLARE_BITMAP(val, MAX_LINE);
u8 regaddr;
int ret;
ret = regcache_sync_region(chip->regmap, chip->regs->output,
chip->regs->output + NBANK(chip));
regaddr = pca953x_recalc_addr(chip, chip->regs->output, 0);
ret = regcache_sync_region(chip->regmap, regaddr,
regaddr + NBANK(chip) - 1);
if (ret)
goto out;
ret = regcache_sync_region(chip->regmap, chip->regs->direction,
chip->regs->direction + NBANK(chip));
regaddr = pca953x_recalc_addr(chip, chip->regs->direction, 0);
ret = regcache_sync_region(chip->regmap, regaddr,
regaddr + NBANK(chip) - 1);
if (ret)
goto out;
@ -1127,14 +1133,14 @@ static int pca953x_regcache_sync(struct device *dev)
* sync these registers first and only then sync the rest.
*/
regaddr = pca953x_recalc_addr(chip, chip->regs->direction, 0);
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip));
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip) - 1);
if (ret) {
dev_err(dev, "Failed to sync GPIO dir registers: %d\n", ret);
return ret;
}
regaddr = pca953x_recalc_addr(chip, chip->regs->output, 0);
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip));
ret = regcache_sync_region(chip->regmap, regaddr, regaddr + NBANK(chip) - 1);
if (ret) {
dev_err(dev, "Failed to sync GPIO out registers: %d\n", ret);
return ret;
@ -1144,7 +1150,7 @@ static int pca953x_regcache_sync(struct device *dev)
if (chip->driver_data & PCA_PCAL) {
regaddr = pca953x_recalc_addr(chip, PCAL953X_IN_LATCH, 0);
ret = regcache_sync_region(chip->regmap, regaddr,
regaddr + NBANK(chip));
regaddr + NBANK(chip) - 1);
if (ret) {
dev_err(dev, "Failed to sync INT latch registers: %d\n",
ret);
@ -1153,7 +1159,7 @@ static int pca953x_regcache_sync(struct device *dev)
regaddr = pca953x_recalc_addr(chip, PCAL953X_INT_MASK, 0);
ret = regcache_sync_region(chip->regmap, regaddr,
regaddr + NBANK(chip));
regaddr + NBANK(chip) - 1);
if (ret) {
dev_err(dev, "Failed to sync INT mask registers: %d\n",
ret);

View File

@ -99,7 +99,7 @@ static inline void xgpio_set_value32(unsigned long *map, int bit, u32 v)
const unsigned long offset = (bit % BITS_PER_LONG) & BIT(5);
map[index] &= ~(0xFFFFFFFFul << offset);
map[index] |= v << offset;
map[index] |= (unsigned long)v << offset;
}
static inline int xgpio_regoffset(struct xgpio_instance *chip, int ch)

View File

@ -3,6 +3,6 @@
TEST_PROGS := gpio-mockup.sh gpio-sim.sh
TEST_FILES := gpio-mockup-sysfs.sh
TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev gpio-chip-info gpio-line-name
CFLAGS += -O2 -g -Wall -I../../../../usr/include/
CFLAGS += -O2 -g -Wall -I../../../../usr/include/ $(KHDR_INCLUDES)
include ../lib.mk