diff options
| author | Wolfram Sang <wsa+renesas@sang-engineering.com> | 2015-03-23 04:26:39 -0400 |
|---|---|---|
| committer | Wolfram Sang <wsa@the-dreams.de> | 2015-03-27 11:53:40 -0400 |
| commit | 98e982b3a29829b676b723e42c1184c87e5242d0 (patch) | |
| tree | b65bd89a53eed65aecf4d95229cba99825e5ab5c | |
| parent | d0c892f59c918535f902caea63637af87d931d91 (diff) | |
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>
| -rw-r--r-- | drivers/i2c/i2c-slave-eeprom.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c index 3fb45d894d80..822374654609 100644 --- a/drivers/i2c/i2c-slave-eeprom.c +++ b/drivers/i2c/i2c-slave-eeprom.c | |||
| @@ -48,12 +48,18 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, | |||
| 48 | break; | 48 | break; |
| 49 | 49 | ||
| 50 | case I2C_SLAVE_READ_PROCESSED: | 50 | case I2C_SLAVE_READ_PROCESSED: |
| 51 | /* The previous byte made it to the bus, get next one */ | ||
| 51 | eeprom->buffer_idx++; | 52 | eeprom->buffer_idx++; |
| 52 | /* fallthrough */ | 53 | /* fallthrough */ |
| 53 | case I2C_SLAVE_READ_REQUESTED: | 54 | case I2C_SLAVE_READ_REQUESTED: |
| 54 | spin_lock(&eeprom->buffer_lock); | 55 | spin_lock(&eeprom->buffer_lock); |
| 55 | *val = eeprom->buffer[eeprom->buffer_idx]; | 56 | *val = eeprom->buffer[eeprom->buffer_idx]; |
| 56 | spin_unlock(&eeprom->buffer_lock); | 57 | spin_unlock(&eeprom->buffer_lock); |
| 58 | /* | ||
| 59 | * Do not increment buffer_idx here, because we don't know if | ||
| 60 | * this byte will be actually used. Read Linux I2C slave docs | ||
| 61 | * for details. | ||
| 62 | */ | ||
| 57 | break; | 63 | break; |
| 58 | 64 | ||
| 59 | case I2C_SLAVE_STOP: | 65 | case I2C_SLAVE_STOP: |
