i2c: slave-eeprom: add more info when to increase the pointer

It is a bit subtle when to correctly increase the buffer index when
reading. Make this clearer by adding some more comments and pointers to
the docs.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
Wolfram Sang 2015-03-23 09:26:39 +01:00 committed by Wolfram Sang
parent d0c892f59c
commit 98e982b3a2

View File

@ -48,12 +48,18 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
break; break;
case I2C_SLAVE_READ_PROCESSED: case I2C_SLAVE_READ_PROCESSED:
/* The previous byte made it to the bus, get next one */
eeprom->buffer_idx++; eeprom->buffer_idx++;
/* fallthrough */ /* fallthrough */
case I2C_SLAVE_READ_REQUESTED: case I2C_SLAVE_READ_REQUESTED:
spin_lock(&eeprom->buffer_lock); spin_lock(&eeprom->buffer_lock);
*val = eeprom->buffer[eeprom->buffer_idx]; *val = eeprom->buffer[eeprom->buffer_idx];
spin_unlock(&eeprom->buffer_lock); spin_unlock(&eeprom->buffer_lock);
/*
* Do not increment buffer_idx here, because we don't know if
* this byte will be actually used. Read Linux I2C slave docs
* for details.
*/
break; break;
case I2C_SLAVE_STOP: case I2C_SLAVE_STOP: