Skip to content

Commit

Permalink
gpio: pca953x: remove incorrect le16_to_cpu calls
Browse files Browse the repository at this point in the history
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 <sebastian.reichel@collabora.co.uk>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Andy Shevchenko authored and Linus Walleij committed Aug 14, 2017
1 parent ef95484 commit b2dc411
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/gpio/gpio-pca953x.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ static int pca953x_write_regs_8(struct pca953x_chip *chip, int reg, u8 *val)

static int pca953x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
{
__le16 word = cpu_to_le16(get_unaligned((u16 *)val));
u16 word = get_unaligned((u16 *)val);

return i2c_smbus_write_word_data(chip->client,
reg << 1, (__force u16)word);
return i2c_smbus_write_word_data(chip->client, reg << 1, word);
}

static int pca957x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
Expand Down Expand Up @@ -241,8 +240,7 @@ static int pca953x_read_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
int ret;

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

return ret;
}
Expand Down

0 comments on commit b2dc411

Please sign in to comment.