i2c: slave: rework the slave API
After more discussion, brave users, and additional datasheet evaluation, some API updates for the new I2C slave framework became imminent. The slave events now get some easier to understand naming. Also, the event handling has been simplified to only need a single call to the slave callback when an action by the backend is required. Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be> 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:

committed by
Wolfram Sang

parent
4a7a08226d
commit
5b77d162a3
@@ -36,7 +36,7 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
|
||||
struct eeprom_data *eeprom = i2c_get_clientdata(client);
|
||||
|
||||
switch (event) {
|
||||
case I2C_SLAVE_REQ_WRITE_END:
|
||||
case I2C_SLAVE_WRITE_RECEIVED:
|
||||
if (eeprom->first_write) {
|
||||
eeprom->buffer_idx = *val;
|
||||
eeprom->first_write = false;
|
||||
@@ -47,17 +47,17 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
|
||||
}
|
||||
break;
|
||||
|
||||
case I2C_SLAVE_REQ_READ_START:
|
||||
case I2C_SLAVE_READ_PROCESSED:
|
||||
eeprom->buffer_idx++;
|
||||
/* fallthrough */
|
||||
case I2C_SLAVE_READ_REQUESTED:
|
||||
spin_lock(&eeprom->buffer_lock);
|
||||
*val = eeprom->buffer[eeprom->buffer_idx];
|
||||
spin_unlock(&eeprom->buffer_lock);
|
||||
break;
|
||||
|
||||
case I2C_SLAVE_REQ_READ_END:
|
||||
eeprom->buffer_idx++;
|
||||
break;
|
||||
|
||||
case I2C_SLAVE_STOP:
|
||||
case I2C_SLAVE_WRITE_REQUESTED:
|
||||
eeprom->first_write = true;
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user