Ver Fonte

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>
Peter Maydell há 3 anos atrás
pai
commit
352998df1c
1 ficheiros alterados com 6 adições e 1 exclusões
  1. 6 1
      hw/nvram/eeprom_at24c.c

+ 6 - 1
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;