aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2022-03-14 14:39:33 +0000
committerPeter Maydell <peter.maydell@linaro.org>2022-03-14 14:39:33 +0000
commit352998df1c53b366413690d95b35f76d0721ebed (patch)
tree6158086c0e3a76b58993f03fb390f35e3d0236bc
parent15df33ceb73cb6bb3c6736cf4d2cff51129ed4b4 (diff)
parent1cbab82e9d1bdb2c7b9ef46a396fdc03ea3fa04c (diff)
Merge tag 'i2c-20220314' of https://github.com/philmd/qemu into staging
I2C patch queue - Fix AT24 EEPROM partial write (Patrick Venture) # gpg: Signature made Mon 14 Mar 2022 13:50:01 GMT # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: FAAB E75E 1291 7221 DCFD 6BB2 E3E3 2C2C DEAD C0DE * tag 'i2c-20220314' of https://github.com/philmd/qemu: hw/nvram: at24 return 0xff if 1 byte address Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/nvram/eeprom_at24c.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index da435500ba..01a3093600 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -58,9 +58,10 @@ int at24c_eeprom_event(I2CSlave *s, enum i2c_event event)
switch (event) {
case I2C_START_SEND:
- case I2C_START_RECV:
case I2C_FINISH:
ee->haveaddr = 0;
+ /* fallthrough */
+ case I2C_START_RECV:
DPRINTK("clear\n");
if (ee->blk && ee->changed) {
int len = blk_pwrite(ee->blk, 0, ee->mem, ee->rsize, 0);
@@ -84,6 +85,10 @@ uint8_t at24c_eeprom_recv(I2CSlave *s)
EEPROMState *ee = AT24C_EE(s);
uint8_t ret;
+ if (ee->haveaddr == 1) {
+ return 0xff;
+ }
+
ret = ee->mem[ee->cur];
ee->cur = (ee->cur + 1u) % ee->rsize;