From: Michal Simek Date: Mon, 15 Apr 2019 12:42:55 +0000 (+0200) Subject: cmd: fru: Fix structure format for board info X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=70c975fe77c4bde3fdb4101a174d26bb99ed29e4;p=thirdparty%2Fu-boot.git cmd: fru: Fix structure format for board info Origin code was targeting product area which is not what will be used at first place. Signed-off-by: Michal Simek --- diff --git a/common/fru_ops.c b/common/fru_ops.c index 4bab1a725c9..778dce23251 100644 --- a/common/fru_ops.c +++ b/common/fru_ops.c @@ -67,10 +67,9 @@ static int fru_parse_board(unsigned long addr) memcpy(&fru_data.brd.ver, (void *)addr, 6); addr += 6; - data = (u8 *)&fru_data.brd.manuf_type_len; + data = (u8 *)&fru_data.brd.manufacturer_type_len; - for (i = 0; i < FRU_BOARD_AREA_TOTAL_FIELDS; i++, - data += FRU_BOARD_MAX_LEN) { + for (i = 0; ; i++, data += FRU_BOARD_MAX_LEN) { *data++ = *(u8 *)addr; len = fru_check_type_len(*(u8 *)addr, fru_data.brd.lang_code, &type); @@ -78,7 +77,7 @@ static int fru_parse_board(unsigned long addr) * Stop cature if it end of fields */ if (len == -EINVAL) - return 0; + break; /* * Dont capture data if type is not ASCII8 @@ -93,6 +92,12 @@ static int fru_parse_board(unsigned long addr) addr += len; } + if (i < FRU_BOARD_AREA_TOTAL_FIELDS) { + printf("Board area require minimum %d fields\n", + FRU_BOARD_AREA_TOTAL_FIELDS); + return -EINVAL; + } + return 0; } @@ -140,10 +145,9 @@ static int fru_display_board(void) const char *boardinfo[] = { "Manufacturer Name", "Product Name", - "Product Model/Part No", - "Product Version", - "Product Serial No", - "Asset Tag" + "Serial No", + "Part Number", + "File ID" }; printf("*****BOARD INFO*****\n"); @@ -157,11 +161,15 @@ static int fru_display_board(void) fru_data.brd.time[0]; printf("Time in Minutes from 0:00hrs 1/1/96 %d\n", time); - data = (u8 *)&fru_data.brd.manuf_type_len; + data = (u8 *)&fru_data.brd.manufacturer_type_len; - for (u8 i = 0; i < FRU_BOARD_AREA_TOTAL_FIELDS; i++) { + for (u8 i = 0; ; i++) { len = fru_check_type_len(*data++, fru_data.brd.lang_code, &type); + if (len == -EINVAL) { + printf("**** EOF for Board Area ****\n"); + break; + } if (type <= FRU_TYPELEN_TYPE_ASCII8 && (fru_data.brd.lang_code == FRU_LANG_CODE_ENGLISH || @@ -169,10 +177,7 @@ static int fru_display_board(void) printf("Type code: %s\n", typecode[type]); else printf("Type code: %s\n", typecode[type + 1]); - if (len == -EINVAL) { - printf("**** EOF for Board Area ****\n"); - return 0; - } + if (type != FRU_TYPELEN_TYPE_ASCII8) { printf("FRU_ERROR: Only ASCII8 type is supported\n"); return 0; diff --git a/include/fru.h b/include/fru.h index c416a88b204..4c0bb836b2c 100644 --- a/include/fru.h +++ b/include/fru.h @@ -26,18 +26,16 @@ struct fru_board_data { u8 len; u8 lang_code; u8 time[3]; - u8 manuf_type_len; - u8 manuf_name[FRU_BOARD_MAX_LEN]; - u8 prd_name_type_len; + u8 manufacturer_type_len; + u8 manufacturer_name[FRU_BOARD_MAX_LEN]; + u8 product_name_type_len; u8 product_name[FRU_BOARD_MAX_LEN]; - u8 prd_part_type_len; - u8 product_part[FRU_BOARD_MAX_LEN]; - u8 prd_ver_type_len; - u8 product_ver[FRU_BOARD_MAX_LEN]; - u8 prd_serial_type_len; - u8 product_serial[FRU_BOARD_MAX_LEN]; - u8 asset_tag_type_len; - u8 asset_tag[FRU_BOARD_MAX_LEN]; + u8 serial_number_type_len; + u8 serial_number[FRU_BOARD_MAX_LEN]; + u8 part_number_type_len; + u8 part_number[FRU_BOARD_MAX_LEN]; + u8 file_id_type_len; + u8 file_id[FRU_BOARD_MAX_LEN]; }; struct fru_table { @@ -54,7 +52,8 @@ struct fru_table { #define FRU_LANG_CODE_ENGLISH_1 25 #define FRU_TYPELEN_EOF 0xC1 -#define FRU_BOARD_AREA_TOTAL_FIELDS 6 +/* This should be minimum of fields */ +#define FRU_BOARD_AREA_TOTAL_FIELDS 5 #define FRU_TYPELEN_TYPE_SHIFT 6 #define FRU_TYPELEN_TYPE_ASCII8 3