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>
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);
}
} else {
if (i2c_read(chip, addr << 1, 1, (u8*)&valw, 2))
return -1;
- *data = (int)valw;
+ *data = (uint)le16_to_cpu(valw);
}
return 0;
}