((p >= 'a') && (p <= 'f')));
}
+/**
+ * is_valid_tlvinfo_header
+ *
+ * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM
+ * data pointed to by the parameter:
+ * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo"
+ * 2. Version byte is 1
+ * 3. Total length bytes contain value which is less than or equal
+ * to the allowed maximum (2048-11)
+ *
+ */
+static inline bool is_valid_tlvinfo_header(struct tlvinfo_header *hdr)
+{
+ return ((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) &&
+ (hdr->version == TLV_INFO_VERSION) &&
+ (be16_to_cpu(hdr->totallen) <= TLV_TOTAL_LEN_MAX));
+}
+
+bool is_valid_tlvinfo(u8 *eeprom)
+{
+ struct tlvinfo_header *eeprom_hdr = to_header(eeprom);
+
+ if (!is_valid_tlvinfo_header(eeprom_hdr) ||
+ !is_checksum_valid(eeprom))
+ return false;
+
+ return true;
+}
+
/**
* is_checksum_valid
*
return calc_crc == stored_crc;
}
+void tlvinfo_default_tlv(u8 *eeprom)
+{
+ struct tlvinfo_header *eeprom_hdr = to_header(eeprom);
+
+ strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING);
+ eeprom_hdr->version = TLV_INFO_VERSION;
+ eeprom_hdr->totallen = cpu_to_be16(0);
+ update_crc(eeprom);
+}
+
/**
* read_eeprom
*
int read_tlvinfo_tlv_eeprom(void *eeprom, struct tlvinfo_header **hdr,
struct tlvinfo_tlv **first_entry, int dev);
-/**
- * is_valid_tlvinfo_header
- *
- * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM
- * data pointed to by the parameter:
- * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo"
- * 2. Version byte is 1
- * 3. Total length bytes contain value which is less than or equal
- * to the allowed maximum (2048-11)
- *
- */
-static inline bool is_valid_tlvinfo_header(struct tlvinfo_header *hdr)
-{
- return ((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) &&
- (hdr->version == TLV_INFO_VERSION) &&
- (be16_to_cpu(hdr->totallen) <= TLV_TOTAL_LEN_MAX));
-}
-
+void tlvinfo_default_tlv(u8 *eeprom);
+bool is_valid_tlvinfo(u8 *eeprom);
void show_eeprom(int devnum, u8 *eeprom);
bool tlvinfo_find_tlv(u8 *eeprom, u8 tcode, int *eeprom_index);
bool tlvinfo_delete_tlv(u8 *eeprom, u8 code);