Skip to content

Commit b2dc411

Browse files
andy-shevlinusw
authored andcommitted
gpio: pca953x: remove incorrect le16_to_cpu calls
i2c_smbus commands handle the correct byte order for smbus transactions internally. This will currently result in incorrect operation on big endian systems. Suggested-by: Sebastian Reichel <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Sebastian Reichel <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent ef95484 commit b2dc411

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,9 @@ static int pca953x_write_regs_8(struct pca953x_chip *chip, int reg, u8 *val)
187187

188188
static int pca953x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
189189
{
190-
__le16 word = cpu_to_le16(get_unaligned((u16 *)val));
190+
u16 word = get_unaligned((u16 *)val);
191191

192-
return i2c_smbus_write_word_data(chip->client,
193-
reg << 1, (__force u16)word);
192+
return i2c_smbus_write_word_data(chip->client, reg << 1, word);
194193
}
195194

196195
static int pca957x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
@@ -241,8 +240,7 @@ static int pca953x_read_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
241240
int ret;
242241

243242
ret = i2c_smbus_read_word_data(chip->client, reg << 1);
244-
val[0] = (u16)ret & 0xFF;
245-
val[1] = (u16)ret >> 8;
243+
put_unaligned(ret, (u16 *)val);
246244

247245
return ret;
248246
}

0 commit comments

Comments
 (0)