From 936df714ebd00e54cd1e9b23d57a8f93f0ae0871 Mon Sep 17 00:00:00 2001 From: Jett Rink Date: Wed, 11 Nov 2020 12:22:04 -0700 Subject: Revert "crc8: rename crc8 to cros_crc8 to to avoid zephyr conflict" Something slipped through CQ coverage. Need to figure out, but in the mean time, revert the 3 CLs that seemed to have caused the issue. BRANCH=none BUG=chromium:1147953 TEST=none This reverts commit befe5a9c78ff4e75db7c5cda801688c8976e95f3. Change-Id: I14e82f33646b6574b1b3da13783143e3a29d417b Signed-off-by: Jett Rink Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2533357 --- common/cbi.c | 4 ++-- common/console.c | 2 +- common/crc8.c | 6 +++--- common/ec_ec_comm_master.c | 15 +++++++-------- common/ec_ec_comm_slave.c | 10 +++++----- common/i2c_master.c | 20 ++++++++++---------- common/vboot/efs2.c | 2 +- driver/bc12/mt6360.c | 2 +- include/crc8.h | 7 +++---- 9 files changed, 33 insertions(+), 35 deletions(-) diff --git a/common/cbi.c b/common/cbi.c index 02f154e8ee..c6fa213807 100644 --- a/common/cbi.c +++ b/common/cbi.c @@ -26,8 +26,8 @@ */ uint8_t cbi_crc8(const struct cbi_header *h) { - return cros_crc8((uint8_t *)&h->crc + 1, - h->total_size - sizeof(h->magic) - sizeof(h->crc)); + return crc8((uint8_t *)&h->crc + 1, + h->total_size - sizeof(h->magic) - sizeof(h->crc)); } uint8_t *cbi_set_data(uint8_t *p, enum cbi_data_tag tag, diff --git a/common/console.c b/common/console.c index 1a2a41c9c1..8f42dffbf5 100644 --- a/common/console.c +++ b/common/console.c @@ -217,7 +217,7 @@ static int handle_command(char *input) /* Lastly, verify the CRC8 of the command. */ if (i+command_len > input_len) goto command_has_error; - if (packed_crc8 != cros_crc8(&input[i], command_len)) { + if (packed_crc8 != crc8(&input[i], command_len)) { command_has_error: /* Send back the error string. */ ccprintf("&&EE\n"); diff --git a/common/crc8.c b/common/crc8.c index 8098fa74eb..83ba31c5a4 100644 --- a/common/crc8.c +++ b/common/crc8.c @@ -5,12 +5,12 @@ #include "common.h" #include "crc8.h" -inline uint8_t cros_crc8(const uint8_t *data, int len) +inline uint8_t crc8(const uint8_t *data, int len) { - return cros_crc8_arg(data, len, 0); + return crc8_arg(data, len, 0); } -uint8_t cros_crc8_arg(const uint8_t *data, int len, uint8_t previous_crc) +uint8_t crc8_arg(const uint8_t *data, int len, uint8_t previous_crc) { unsigned crc = previous_crc << 8; int i, j; diff --git a/common/ec_ec_comm_master.c b/common/ec_ec_comm_master.c index 5cf8eba31a..966e4c0f53 100644 --- a/common/ec_ec_comm_master.c +++ b/common/ec_ec_comm_master.c @@ -149,10 +149,10 @@ static int write_command(uint16_t command, request_header->command = command; request_header->data_len = req_len; request_header->header_crc = - cros_crc8((uint8_t *)request_header, sizeof(*request_header)-1); + crc8((uint8_t *)request_header, sizeof(*request_header)-1); if (req_len > 0) data[sizeof(*request_header) + req_len] = - cros_crc8(&data[sizeof(*request_header)], req_len); + crc8(&data[sizeof(*request_header)], req_len); ret = uart_alt_pad_write_read((void *)data, tx_length, (void *)data, rx_length, timeout_us); @@ -179,8 +179,8 @@ static int write_command(uint16_t command, } if (response_header->header_crc != - cros_crc8((uint8_t *)response_header, - sizeof(*response_header) - 1)) { + crc8((uint8_t *)response_header, + sizeof(*response_header)-1)) { INCR_COMM_STATS(errcrc); return EC_ERROR_CRC; } @@ -206,10 +206,9 @@ static int write_command(uint16_t command, } /* Check data CRC. */ - if (hascrc && - data[rx_length - 1] != - cros_crc8(&data[tx_length + sizeof(*request_header)], - resp_len)) { + if (hascrc && data[rx_length - 1] != + crc8(&data[tx_length + sizeof(*request_header)], + resp_len)) { INCR_COMM_STATS(errdatacrc); return EC_ERROR_CRC; } diff --git a/common/ec_ec_comm_slave.c b/common/ec_ec_comm_slave.c index 001400da60..ae845d58bc 100644 --- a/common/ec_ec_comm_slave.c +++ b/common/ec_ec_comm_slave.c @@ -88,13 +88,13 @@ static void write_response(uint16_t res, int seq, const void *data, int len) header.data_len = len; header.reserved = 0; header.header_crc = - cros_crc8((uint8_t *)&header, sizeof(header)-1); + crc8((uint8_t *)&header, sizeof(header)-1); QUEUE_ADD_UNITS(&ec_ec_comm_slave_output, (uint8_t *)&header, sizeof(header)); if (len > 0) { QUEUE_ADD_UNITS(&ec_ec_comm_slave_output, data, len); - crc = cros_crc8(data, len); + crc = crc8(data, len); QUEUE_ADD_UNITS(&ec_ec_comm_slave_output, &crc, sizeof(crc)); } } @@ -243,8 +243,8 @@ void ec_ec_comm_slave_task(void *u) /* Validate version and crc. */ if ((header.fields0 & EC_PACKET4_0_STRUCT_VERSION_MASK) != 4 || - header.header_crc != - cros_crc8((uint8_t *)&header, sizeof(header) - 1)) { + header.header_crc != + crc8((uint8_t *)&header, sizeof(header)-1)) { CPRINTS("%s header/crc error", __func__); goto discard; } @@ -277,7 +277,7 @@ void ec_ec_comm_slave_task(void *u) } /* Check data CRC */ - if (hascrc && params[len-1] != cros_crc8(params, len-1)) { + if (hascrc && params[len-1] != crc8(params, len-1)) { CPRINTS("%s data crc error", __func__); write_response(EC_RES_INVALID_CHECKSUM, seq, NULL, 0); goto discard; diff --git a/common/i2c_master.c b/common/i2c_master.c index 83b7d47856..23164720b5 100644 --- a/common/i2c_master.c +++ b/common/i2c_master.c @@ -294,8 +294,8 @@ static int platform_ec_i2c_read(const int port, const uint16_t slave_addr_flags, if (rv) continue; - pec_local = cros_crc8(out, ARRAY_SIZE(out)); - pec_local = cros_crc8_arg(in, in_size, pec_local); + pec_local = crc8(out, ARRAY_SIZE(out)); + pec_local = crc8_arg(in, in_size, pec_local); if (pec_local == pec_remote) break; @@ -322,8 +322,8 @@ static int platform_ec_i2c_write(const int port, uint8_t addr_8bit = I2C_STRIP_FLAGS(slave_addr_flags) << 1; uint8_t pec; - pec = cros_crc8(&addr_8bit, 1); - pec = cros_crc8_arg(out, out_size, pec); + pec = crc8(&addr_8bit, 1); + pec = crc8_arg(out, out_size, pec); i2c_lock(port, 1); for (i = 0; i <= CONFIG_I2C_NACK_RETRY_COUNT; i++) { @@ -698,9 +698,9 @@ int i2c_read_string(const int port, if (rv) continue; - pec = cros_crc8(out, sizeof(out)); - pec = cros_crc8_arg(&block_length, 1, pec); - pec = cros_crc8_arg(data, data_length, pec); + pec = crc8(out, sizeof(out)); + pec = crc8_arg(&block_length, 1, pec); + pec = crc8_arg(data, data_length, pec); /* read all remaining bytes */ block_length -= data_length; @@ -711,7 +711,7 @@ int i2c_read_string(const int port, NULL, 0, &byte, 1, 0); if (rv) break; - pec = cros_crc8_arg(&byte, 1, pec); + pec = crc8_arg(&byte, 1, pec); --block_length; } if (rv) @@ -764,8 +764,8 @@ int i2c_write_block(const int port, if (IS_ENABLED(CONFIG_SMBUS_PEC) && I2C_USE_PEC(slave_addr_flags)) { uint8_t addr_8bit = I2C_STRIP_FLAGS(slave_addr_flags) << 1; - pec = cros_crc8(&addr_8bit, sizeof(uint8_t)); - pec = cros_crc8_arg(data, len, pec); + pec = crc8(&addr_8bit, sizeof(uint8_t)); + pec = crc8_arg(data, len, pec); } /* diff --git a/common/vboot/efs2.c b/common/vboot/efs2.c index f0b60e49e0..e608fd5841 100644 --- a/common/vboot/efs2.c +++ b/common/vboot/efs2.c @@ -141,7 +141,7 @@ static enum cr50_comm_err cmd_to_cr50(enum cr50_comm_cmd cmd, p->type = cmd; p->size = size; memcpy(p->data, data, size); - p->crc = cros_crc8((uint8_t *)&p->type, + p->crc = crc8((uint8_t *)&p->type, sizeof(p->type) + sizeof(p->size) + size); do { diff --git a/driver/bc12/mt6360.c b/driver/bc12/mt6360.c index 26925ece03..c634be8e33 100644 --- a/driver/bc12/mt6360.c +++ b/driver/bc12/mt6360.c @@ -203,7 +203,7 @@ static int mt6360_regulator_read8(int addr, int reg, int *val) real_crc = (*val >> 8) & 0xFF; *val &= 0xFF; out[2] = *val; - crc = cros_crc8(out, ARRAY_SIZE(out)); + crc = crc8(out, ARRAY_SIZE(out)); if (crc != real_crc) return EC_ERROR_CRC; diff --git a/include/crc8.h b/include/crc8.h index 45b2322b44..e6e70e2bf3 100644 --- a/include/crc8.h +++ b/include/crc8.h @@ -16,7 +16,7 @@ * @param len int, input, size of input data in bytes * @return the crc-8 of the input data. */ -uint8_t cros_crc8(const uint8_t *data, int len); +uint8_t crc8(const uint8_t *data, int len); /** * crc8_arg @@ -25,10 +25,9 @@ uint8_t cros_crc8(const uint8_t *data, int len); * @param data uint8_t *, input, a pointer to input data * @param len int, input, size of input data in bytes * @param previous_crc uint8_t, input, pre-calculated CRC of previous data. - * Seed with zero for a new calculation (or use the result of - * cros_crc8()). + * Seed with zero for a new calculation (or use the result of crc8()). * @return the crc-8 of the input data. */ -uint8_t cros_crc8_arg(const uint8_t *data, int len, uint8_t previous_crc); +uint8_t crc8_arg(const uint8_t *data, int len, uint8_t previous_crc); #endif /* __CROS_EC_CRC8_H */ -- cgit v1.2.1