Skip to content

Commit c3afa80

Browse files
pthomaslinusw
authored andcommitted
gpio: xilinx: Fix bug where the wrong GPIO register is written to
Care is taken with "index", however with the current version the actual xgpio_writereg is using index for data but xgpio_regoffset(chip, i) for the offset. And since i is already incremented it is incorrect. This patch fixes it so that index is used for the offset too. Cc: [email protected] Signed-off-by: Paul Thomas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent dee7c11 commit c3afa80

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpio/gpio-xilinx.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,10 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
147147
for (i = 0; i < gc->ngpio; i++) {
148148
if (*mask == 0)
149149
break;
150+
/* Once finished with an index write it out to the register */
150151
if (index != xgpio_index(chip, i)) {
151152
xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET +
152-
xgpio_regoffset(chip, i),
153+
index * XGPIO_CHANNEL_OFFSET,
153154
chip->gpio_state[index]);
154155
spin_unlock_irqrestore(&chip->gpio_lock[index], flags);
155156
index = xgpio_index(chip, i);
@@ -165,7 +166,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
165166
}
166167

167168
xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET +
168-
xgpio_regoffset(chip, i), chip->gpio_state[index]);
169+
index * XGPIO_CHANNEL_OFFSET, chip->gpio_state[index]);
169170

170171
spin_unlock_irqrestore(&chip->gpio_lock[index], flags);
171172
}

0 commit comments

Comments
 (0)