diff options
-rw-r--r-- | common/cbi.c | 18 | ||||
-rw-r--r-- | include/cros_board_info.h | 5 | ||||
-rw-r--r-- | include/ec_commands.h | 1 | ||||
-rw-r--r-- | test/cbi.c | 6 | ||||
-rw-r--r-- | util/cbi-util.c | 71 | ||||
-rw-r--r-- | util/ectool.c | 40 |
6 files changed, 20 insertions, 121 deletions
diff --git a/common/cbi.c b/common/cbi.c index 97bdbf5a2f..6c98e610ec 100644 --- a/common/cbi.c +++ b/common/cbi.c @@ -343,12 +343,6 @@ int cbi_get_pcb_supplier(uint32_t *pcb_supplier) &size); } -int cbi_get_rework_id(uint64_t *id) -{ - uint8_t size = sizeof(*id); - return cbi_get_board_info(CBI_TAG_REWORK_ID, (uint8_t *)id, &size); -} - static enum ec_status hc_cbi_get(struct host_cmd_handler_args *args) { const struct __ec_align4 ec_params_get_cbi *p = args->params; @@ -447,20 +441,9 @@ static void print_tag(const char * const tag, int rv, const uint32_t *val) ccprintf(": (Error %d)\n", rv); } -static void print_uint64_tag(const char * const tag, int rv, const uint64_t *lval) -{ - ccprintf("%s", tag); - if(rv == EC_SUCCESS && lval) - ccprintf(": %llu (0x%llx)\n", *(unsigned long long*)lval, - *(unsigned long long*)lval); - else - ccprintf(": (Error %d)\n", rv); -} - static void dump_cbi(void) { uint32_t val; - uint64_t lval; /* Ensure we read the latest data from flash. */ cached_read_result = EC_ERROR_CBI_CACHE_INVALID; @@ -481,7 +464,6 @@ static void dump_cbi(void) print_tag("FW_CONFIG", cbi_get_fw_config(&val), &val); print_tag("PCB_SUPPLIER", cbi_get_pcb_supplier(&val), &val); print_tag("SSFC", cbi_get_ssfc(&val), &val); - print_uint64_tag("REWORK_ID", cbi_get_rework_id(&lval), &lval); } static int cc_cbi(int argc, char **argv) diff --git a/include/cros_board_info.h b/include/cros_board_info.h index 266e66c5af..ed5967b0d6 100644 --- a/include/cros_board_info.h +++ b/include/cros_board_info.h @@ -44,8 +44,8 @@ struct cbi_data { /** * Board info accessors * - * @param version/sku_id/oem_id/id/fw_config/pcb_supplier/ssfc/rework_id [OUT] - * Data_read from EEPROM. + * @param version/sku_id/oem_id/id/fw_config/pcb_supplier/ssfc [OUT] Data read + * from EEPROM * @return EC_SUCCESS on success or EC_ERROR_* otherwise. * EC_ERROR_BUSY to indicate data is not ready. */ @@ -56,7 +56,6 @@ int cbi_get_model_id(uint32_t *id); int cbi_get_fw_config(uint32_t *fw_config); int cbi_get_pcb_supplier(uint32_t *pcb_supplier); int cbi_get_ssfc(uint32_t *ssfc); -int cbi_get_rework_id(uint64_t *id); /** * Get data from CBI store diff --git a/include/ec_commands.h b/include/ec_commands.h index 5fd8713b7d..8f4e313ee4 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -5892,7 +5892,6 @@ enum cbi_data_tag { CBI_TAG_PCB_SUPPLIER = 7, /* uint32_t or smaller */ /* Second Source Factory Cache */ CBI_TAG_SSFC = 8, /* uint32_t bit field */ - CBI_TAG_REWORK_ID = 9, /* uint64_t or smaller */ CBI_TAG_COUNT, }; diff --git a/test/cbi.c b/test/cbi.c index eb2321a649..f0fe68f162 100644 --- a/test/cbi.c +++ b/test/cbi.c @@ -126,7 +126,6 @@ static int test_all_tags(void) { uint8_t d8; uint32_t d32; - uint64_t d64; const char string[] = "abc"; uint8_t buf[32]; uint8_t size; @@ -163,9 +162,6 @@ static int test_all_tags(void) TEST_ASSERT(cbi_set_board_info(CBI_TAG_SSFC, &d8, sizeof(d8)) == EC_SUCCESS); count++; - TEST_ASSERT(cbi_set_board_info(CBI_TAG_REWORK_ID, &d8, sizeof(d8)) - == EC_SUCCESS); - count++; /* Read out all */ TEST_ASSERT(cbi_get_board_version(&d32) == EC_SUCCESS); @@ -192,8 +188,6 @@ static int test_all_tags(void) TEST_EQ(d32, d8, "0x%x"); TEST_ASSERT(cbi_get_ssfc(&d32) == EC_SUCCESS); TEST_EQ(d32, d8, "0x%x"); - TEST_ASSERT(cbi_get_rework_id(&d64) == EC_SUCCESS); - TEST_EQ((unsigned long long)d64, (unsigned long long)d8, "0x%llx"); /* Fail if a (new) tag is missing from the unit test. */ TEST_EQ(count, CBI_TAG_COUNT, "%d"); diff --git a/util/cbi-util.c b/util/cbi-util.c index 51d229d901..54782f8bad 100644 --- a/util/cbi-util.c +++ b/util/cbi-util.c @@ -40,7 +40,6 @@ enum { OPT_FW_CONFIG, OPT_PCB_SUPPLIER, OPT_SSFC, - OPT_REWORK_ID, OPT_SIZE, OPT_ERASE_BYTE, OPT_SHOW_ALL, @@ -58,7 +57,6 @@ static const struct option opts_create[] = { {"fw_config", 1, 0, OPT_FW_CONFIG}, {"pcb_supplier", 1, 0, OPT_PCB_SUPPLIER}, {"ssfc", 1, 0, OPT_SSFC}, - {"rework_id", 1, 0, OPT_REWORK_ID}, {"size", 1, 0, OPT_SIZE}, {"erase_byte", 1, 0, OPT_ERASE_BYTE}, {NULL, 0, 0, 0} @@ -81,7 +79,6 @@ static const char *field_name[] = { "FW_CONFIG", "PCB_SUPPLIER", "SSFC", - "REWORK_ID", }; BUILD_ASSERT(ARRAY_SIZE(field_name) == CBI_TAG_COUNT); @@ -104,11 +101,9 @@ const char help_create[] = " --fw_config <value> Firmware configuration bit-field\n" " --pcb_supplier <value> PCB supplier\n" " --ssfc <value> Second Source Factory Cache bit-field\n" - " --rework_id <lvalue> REWORK_ID\n" "\n" - "<value> must be a positive integer <= 0XFFFFFFFF, <lvalue> must be a\n" - " positive integer <= 0xFFFFFFFFFFFFFFFF and field size can be\n" - " optionally specified by <value:size> notation: e.g. 0xabcd:4.\n" + "<value> must be a positive integer <= 0XFFFFFFFF and field size can\n" + " be optionally specified by <value:size> notation: e.g. 0xabcd:4.\n" "<size> must be a positive integer <= 0XFFFF.\n" "<string> is a string\n" "\n"; @@ -129,11 +124,6 @@ struct integer_field { int size; }; -struct long_integer_field { - uint64_t val; - int size; -}; - static void print_help_create(void) { printf(help_create, cmd_name); @@ -260,48 +250,6 @@ static int parse_integer_field(const char *arg, struct integer_field *f) return 0; } -static int parse_uint64_field(const char *arg, struct long_integer_field *f) -{ - uint64_t val; - char *e; - char *ch; - - val = strtoul(arg, &e, 0); - /* strtoul sets an errno for invalid input. If the value read is out of - * range of representable values by an unsigned long int, the function - * returns ULONG_MAX or ULONG_MIN and the errno is set to ERANGE. - */ - if (errno == ERANGE || !*arg || (e && *e && *e != ':')) { - fprintf(stderr, "Invalid integer value\n"); - return -1; - } - f->val = val; - - ch = strchr(arg, ':'); - if (ch) { - ch++; - val = strtoul(ch, &e, 0); - if (val < 1 || 8 < val || !*ch || (e && *e)) { - fprintf(stderr, "Invalid size suffix\n"); - return -1; - } - f->size = val; - } else { - if (f->val < UINT32_MAX) - f->size = estimate_field_size(f->val); - else - f->size = 8; /* assign default long int size */ - } - - if (f->size < 8 && (f->val > (1ull << f->size * 8))) { - fprintf(stderr, "Value (0x%lx) exceeds field size (%d)\n", - f->val, f->size); - return -1; - } - - return 0; -} - static int cmd_create(int argc, char **argv) { uint8_t *cbi; @@ -313,7 +261,6 @@ static int cmd_create(int argc, char **argv) struct integer_field fw_config; struct integer_field pcb_supplier; struct integer_field ssfc; - struct long_integer_field rework; const char *dram_part_num; const char *oem_name; } bi; @@ -394,10 +341,6 @@ static int cmd_create(int argc, char **argv) if (parse_integer_field(optarg, &bi.ssfc)) return -1; break; - case OPT_REWORK_ID: - if (parse_uint64_field(optarg, &bi.rework)) - return -1; - break; } } @@ -429,7 +372,6 @@ static int cmd_create(int argc, char **argv) p = cbi_set_data(p, CBI_TAG_PCB_SUPPLIER, &bi.pcb_supplier.val, bi.pcb_supplier.size); p = cbi_set_data(p, CBI_TAG_SSFC, &bi.ssfc.val, bi.ssfc.size); - p = cbi_set_data(p, CBI_TAG_REWORK_ID, &bi.rework.val, bi.rework.size); p = cbi_set_string(p, CBI_TAG_DRAM_PART_NUM, bi.dram_part_num); p = cbi_set_string(p, CBI_TAG_OEM_NAME, bi.oem_name); @@ -465,8 +407,7 @@ static void print_string(const uint8_t *buf, enum cbi_data_tag tag) static void print_integer(const uint8_t *buf, enum cbi_data_tag tag) { - uint64_t v; - + uint32_t v; struct cbi_data *d = cbi_find_tag(buf, tag); const char *name; @@ -485,15 +426,12 @@ static void print_integer(const uint8_t *buf, enum cbi_data_tag tag) case 4: v = *(uint32_t *)d->value; break; - case 8: - v = *(uint64_t *)d->value; - break; default: printf(" %s: Integer of size %d not supported\n", name, d->size); return; } - printf(" %s: %lu (0x%lx, %u, %u)\n", name, v, v, d->tag, d->size); + printf(" %s: %u (0x%x, %u, %u)\n", name, v, v, d->tag, d->size); } static int cmd_show(int argc, char **argv) @@ -562,7 +500,6 @@ static int cmd_show(int argc, char **argv) print_integer(buf, CBI_TAG_FW_CONFIG); print_integer(buf, CBI_TAG_PCB_SUPPLIER); print_integer(buf, CBI_TAG_SSFC); - print_integer(buf, CBI_TAG_REWORK_ID); print_string(buf, CBI_TAG_DRAM_PART_NUM); print_string(buf, CBI_TAG_OEM_NAME); diff --git a/util/ectool.c b/util/ectool.c index cabe13adb5..a5d156129d 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -8106,7 +8106,6 @@ static void cmd_cbi_help(char *cmd) " 6: FW_CONFIG\n" " 7: PCB_VENDOR\n" " 8: SSFC\n" - " 9: REWORK_ID\n" " <size> is the size of the data in byte. It should be zero for\n" " string types.\n" " <value/string> is an integer or a string to be set\n" @@ -8172,12 +8171,16 @@ static int cmd_cbi(int argc, char *argv[]) printf("%.*s", rv, (const char *)ec_inbuf); } else { const uint8_t * const buffer = ec_inbuf; - uint64_t int_value = 0; - for(i = 0; i < rv; i++) - int_value |= (uint64_t)buffer[i] << (i * 8); - printf("As uint: %lu (0x%lx)\n", int_value, - int_value); + if (rv <= sizeof(uint32_t)) { + uint32_t int_value = 0; + + for (i = 0; i < rv; i++) + int_value |= buffer[i] << (i * 8); + + printf("As uint: %u (0x%x)\n", int_value, + int_value); + } printf("As binary:"); for (i = 0; i < rv; i++) { if (i % 32 == 31) @@ -8191,9 +8194,8 @@ static int cmd_cbi(int argc, char *argv[]) struct ec_params_set_cbi *p = (struct ec_params_set_cbi *)ec_outbuf; void *val_ptr; - uint64_t val = 0; + uint32_t val; uint8_t size; - uint8_t bad_size = 0; if (argc < 5) { fprintf(stderr, "Invalid number of params\n"); cmd_cbi_help(argv[0]); @@ -8206,31 +8208,17 @@ static int cmd_cbi(int argc, char *argv[]) val_ptr = argv[3]; size = strlen(val_ptr) + 1; } else { - val = strtoul(argv[3], &e, 0); - /* strtoul sets an errno for invalid input. If the value - * read is out of range of representable values by an - * unsigned long int, the function returns ULONG_MAX - * or ULONG_MIN and the errno is set to ERANGE. - */ - if ((e && *e) || errno == ERANGE) { + val = strtol(argv[3], &e, 0); + if (e && *e) { fprintf(stderr, "Bad value\n"); return -1; } size = strtol(argv[4], &e, 0); - if (tag == CBI_TAG_REWORK_ID) { - if ((e && *e) || size < 1 || size > 8 || - (size < 8 && val >= (1ull << size*8))) - bad_size = 1; - } else { - if ((e && *e) || size < 1 || 4 < size || - val >= (1ull << size*8)) - bad_size = 1; - } - if (bad_size == 1) { + if ((e && *e) || size < 1 || 4 < size || + val >= (1ull << size*8)) { fprintf(stderr, "Bad size: %d\n", size); return -1; } - val_ptr = &val; } |