From: Hugo Villeneuve Date: Wed, 5 Nov 2025 05:14:05 +0000 (-0500) Subject: tlv-eeprom: adapt for integration with hvtlv X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=f10cb09a7b170592a596a82e7961ec729fe7b71a;p=mtlv.git tlv-eeprom: adapt for integration with hvtlv Replace calls to i2c_eeprom_read/write and call eeprom_block_read/write from main.c. Use zlib crc32 function. Signed-off-by: Hugo Villeneuve --- diff --git a/src/tlv_eeprom.c b/src/tlv_eeprom.c index 904c6bb..4b2dfb4 100644 --- a/src/tlv_eeprom.c +++ b/src/tlv_eeprom.c @@ -9,17 +9,16 @@ * Copyright (C) 2014,2016 david_yang */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - +#include +#include +#include +#include +#include +#include +#include +#include /* For crc32 routine */ + +#include "linux-compat.h" #include "tlv_eeprom.h" /* File scope function prototypes */ @@ -744,16 +743,8 @@ static int set_bytes(char *buf, const char *string, int *converted_accum) */ int read_tlv_eeprom(void *eeprom, int offset, int len, int dev_num) { - struct udevice *dev; - - if (dev_num >= MAX_TLV_DEVICES) - return -EINVAL; - - dev = find_tlv_device_by_index(dev_num); - if (!dev) - return -ENODEV; - - return i2c_eeprom_read(dev, offset, eeprom, len); + (void) dev_num; + return eeprom_block_read(offset, eeprom, len); } /** @@ -761,12 +752,8 @@ int read_tlv_eeprom(void *eeprom, int offset, int len, int dev_num) */ int write_tlv_eeprom(void *eeprom, int len, int dev) { - if (!(gd->flags & GD_FLG_RELOC)) - return -ENODEV; - if (!tlv_devices[dev]) - return -ENODEV; - - return i2c_eeprom_write(tlv_devices[dev], 0, eeprom, len); + (void) dev; + return eeprom_block_write(0, eeprom, len); } int read_tlvinfo_tlv_eeprom(void *eeprom, struct tlvinfo_header **hdr, diff --git a/src/tlv_eeprom.h b/src/tlv_eeprom.h index 8e0516a..10c479a 100644 --- a/src/tlv_eeprom.h +++ b/src/tlv_eeprom.h @@ -9,6 +9,8 @@ #include +#include "linux-compat.h" + /* * The Definition of the TlvInfo EEPROM format can be found at onie.org or * github.com/onie @@ -137,4 +139,8 @@ int prog_eeprom(int devnum, u8 *eeprom); int read_eeprom(int devnum, u8 *eeprom); void show_tlv_code_list(void); +/* Callbacks in main.c */ +int eeprom_block_read(int offset, uint8_t *buf, int size); +int eeprom_block_write(int offset, const uint8_t *buf, int size); + #endif /* __TLV_EEPROM_H_ */