Am 05.02.2013 17:58, schrieb Anthony Liguori: > Andreas Färber <afaer...@suse.de> writes: > >> memread(s->addr + OMAP_I2C_DATA, &data, 2); >> >> - memread(s->addr + OMAP_I2C_STAT, &stat, 2); >> + omap_i2c_read16(s->addr + OMAP_I2C_STAT, &stat); >> if (unlikely(len == 1)) { >> - *buf = data & 0xf; >> + *buf = le16_to_cpu(data) & 0xf; > > I don't really get this part. You're effectively unswapping the bytes, > right?
No. I am reading into "data" unswapped above. This line swaps "data" when only half of the register is used for the 0xF mask, which assumes host endianness - I can re-test tonight to verify whether it breaks without. Probably I should insert a white line to make the "data" vs. "stat" distinction more clear. I was using a broken STAT register bit before, if you check the libi2c-omap patch history, where we couldn't agree on how to fix properly without spec. Thus I changed the condition to not rely on stat; reading the register seemed necessary though. Alternatively the I2C device has a Big Endian bit that we could enable - but I would rather not have the tests run different device code paths based on host. Regards, Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg