---
hw/nvram/eeprom_at24c.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
index 2d4d8b952f..693212b661 100644
--- a/hw/nvram/eeprom_at24c.c
+++ b/hw/nvram/eeprom_at24c.c
@@ -87,7 +87,7 @@ uint8_t at24c_eeprom_recv(I2CSlave *s)
EEPROMState *ee = AT24C_EE(s);
uint8_t ret;
- if (ee->haveaddr == 1) {
+ if (ee->rsize > 256 && ee->haveaddr == 1) {
return 0xff;
}
@@ -104,11 +104,13 @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)
{
EEPROMState *ee = AT24C_EE(s);
- if (ee->haveaddr < 2) {
+ if ((ee->rsize > 256 && ee->haveaddr < 2) ||
+ (ee->rsize <= 256 && ee->haveaddr < 1)) {
ee->cur <<= 8;
ee->cur |= data;
ee->haveaddr++;
- if (ee->haveaddr == 2) {
+ if ((ee->rsize > 256 && ee->haveaddr == 2) ||
+ (ee->rsize <= 256 && ee->haveaddr == 1)) {
ee->cur %= ee->rsize;
DPRINTK("Set pointer %04x\n", ee->cur);
}