diff options
author | Dirk Eibach <dirk.eibach@gdsys.cc> | 2015-10-29 13:51:27 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2015-11-12 18:04:12 -0500 |
commit | daa75b34828d45b7c1d63009188d45f4a32d06ba (patch) | |
tree | f193191fbaee4702c134d1c8a7a0567e14e0bf5e /drivers | |
parent | 37b33254c2cf6e47f2aaf40946ed6c98ba1057ed (diff) | |
download | u-boot-imx-daa75b34828d45b7c1d63009188d45f4a32d06ba.zip u-boot-imx-daa75b34828d45b7c1d63009188d45f4a32d06ba.tar.gz u-boot-imx-daa75b34828d45b7c1d63009188d45f4a32d06ba.tar.bz2 |
i2c: Fix pca953x endianess issue
By reading 2 consecutive bytes from i2c to an u16 value
we have an endianess issue.
Signed-off-by: Dirk Eibach <dirk.eibach@gdsys.cc>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpio/pca953x.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c index 7371cd4..c8c8637 100644 --- a/drivers/gpio/pca953x.c +++ b/drivers/gpio/pca953x.c @@ -88,8 +88,10 @@ static int pca953x_reg_write(uint8_t chip, uint addr, uint mask, uint data) if (i2c_read(chip, addr << 1, 1, (u8*)&valw, 2)) return -1; + valw = le16_to_cpu(valw); valw &= ~mask; valw |= data; + valw = cpu_to_le16(valw); return i2c_write(chip, addr << 1, 1, (u8*)&valw, 2); } @@ -107,7 +109,7 @@ static int pca953x_reg_read(uint8_t chip, uint addr, uint *data) } else { if (i2c_read(chip, addr << 1, 1, (u8*)&valw, 2)) return -1; - *data = (int)valw; + *data = (uint)le16_to_cpu(valw); } return 0; } |