]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: eeprom: Don't read/write whole EEPROM if not necessary
authorMarek Behún <kabel@kernel.org>
Tue, 21 May 2024 07:13:34 +0000 (09:13 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 7 Jun 2024 16:48:00 +0000 (10:48 -0600)
Don't read/write whole EEPROM if not necessary when printing / updating
EEPROM layout fields. Only read/write layout.data_size bytes.

Signed-off-by: Marek Behún <kabel@kernel.org>
cmd/eeprom.c

index c76cf43157852f35970d35f2165b75df48fb7f10..9c4af88738e3200a76ba4705e3a7f8b89e5f1ceb 100644 (file)
@@ -311,16 +311,10 @@ static int do_eeprom_rw(struct eeprom_dev_spec *dev, bool read,
 static int do_eeprom_layout(struct eeprom_dev_spec *dev, int layout_ver,
                            struct eeprom_layout *layout)
 {
-       int ret;
-
-       ret = eeprom_read(dev->i2c_addr, 0, eeprom_buf, CONFIG_SYS_EEPROM_SIZE);
-       if (ret)
-               return ret;
-
        eeprom_layout_setup(layout, eeprom_buf, CONFIG_SYS_EEPROM_SIZE,
                            layout_ver);
 
-       return 0;
+       return eeprom_read(dev->i2c_addr, 0, eeprom_buf, layout->data_size);
 }
 
 static int do_eeprom_print(struct eeprom_dev_spec *dev, int layout_ver)
@@ -351,8 +345,7 @@ static int do_eeprom_update(struct eeprom_dev_spec *dev, int layout_ver,
        if (ret)
                return CMD_RET_FAILURE;
 
-       return eeprom_write(dev->i2c_addr, 0, layout.data,
-                           CONFIG_SYS_EEPROM_SIZE);
+       return eeprom_write(dev->i2c_addr, 0, layout.data, layout.data_size);
 }
 
 #endif