Re: [PATCH] i2c: slave-eeprom: add latch mode

From: Wolfram Sang
Date: Mon May 19 2025 - 13:03:36 EST


On Mon, Dec 09, 2024 at 02:04:21PM +0800, Jian Zhang wrote:
> The read operation is locked by byte, while the write operation is
> locked by block (or based on the amount of data written). If we need to
> ensure the integrity of a "block" of data that the other end can read,
> then we need a latch mode, lock the buffer when a read operation is
> requested.

I don't really understand what you want to fix here. Does this patch
really fix your issue because...

> switch (event) {
> case I2C_SLAVE_WRITE_RECEIVED:
> + if (eeprom->latch) {
> + spin_lock(&eeprom->buffer_lock);
> + memcpy(eeprom->buffer_latch, eeprom->buffer, eeprom->bin.size);
> + spin_unlock(&eeprom->buffer_lock);
> + }

... what advantage brings you this memcpy of the buffer to a latch after
every single byte is received?

> + if (of_property_read_bool(client->adapter->dev.of_node, "use-latch")) {

If there really is a problem, we don't need a binding for it but should
use the fix in all cases.

Attachment: signature.asc
Description: PGP signature