summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-11-09 14:41:07 -0700
committerCommit Bot <commit-bot@chromium.org>2020-11-13 00:27:37 +0000
commitc382208fe8052890704b83b60219c7d55164127b (patch)
tree47bbaac91afbd9fc34d40d9dcb2f70f37075b76a
parent9263a4f135deb87f7926ed2e91deef496bbfe818 (diff)
downloadchrome-ec-c382208fe8052890704b83b60219c7d55164127b.tar.gz
crc8: rename crc8 to cros_crc8 to to avoid zephyr conflict
Zephyr already provides a robust implementation for crc8, but it conflicts with platform/ec's name of crc8. Rename platform/ec to use cros_crc8 instead since it is a special case of zephyr crc8 implementation. BRANCH=none BUG=b:168032589 TEST=builds. Just a rename Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: I2dc509fe1c1d8c2a4cdec3943b63f29429919137 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2532691 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--common/cbi.c4
-rw-r--r--common/console.c2
-rw-r--r--common/crc8.c6
-rw-r--r--common/ec_ec_comm_master.c15
-rw-r--r--common/ec_ec_comm_slave.c10
-rw-r--r--common/i2c_master.c20
-rw-r--r--common/vboot/efs2.c2
-rw-r--r--driver/bc12/mt6360.c2
-rw-r--r--include/crc8.h7
9 files changed, 35 insertions, 33 deletions
diff --git a/common/cbi.c b/common/cbi.c
index c6fa213807..02f154e8ee 100644
--- a/common/cbi.c
+++ b/common/cbi.c
@@ -26,8 +26,8 @@
*/
uint8_t cbi_crc8(const struct cbi_header *h)
{
- return crc8((uint8_t *)&h->crc + 1,
- h->total_size - sizeof(h->magic) - sizeof(h->crc));
+ return cros_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 8f42dffbf5..1a2a41c9c1 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 != crc8(&input[i], command_len)) {
+ if (packed_crc8 != cros_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 83ba31c5a4..8098fa74eb 100644
--- a/common/crc8.c
+++ b/common/crc8.c
@@ -5,12 +5,12 @@
#include "common.h"
#include "crc8.h"
-inline uint8_t crc8(const uint8_t *data, int len)
+inline uint8_t cros_crc8(const uint8_t *data, int len)
{
- return crc8_arg(data, len, 0);
+ return cros_crc8_arg(data, len, 0);
}
-uint8_t crc8_arg(const uint8_t *data, int len, uint8_t previous_crc)
+uint8_t cros_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 966e4c0f53..5cf8eba31a 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 =
- crc8((uint8_t *)request_header, sizeof(*request_header)-1);
+ cros_crc8((uint8_t *)request_header, sizeof(*request_header)-1);
if (req_len > 0)
data[sizeof(*request_header) + req_len] =
- crc8(&data[sizeof(*request_header)], req_len);
+ cros_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 !=
- crc8((uint8_t *)response_header,
- sizeof(*response_header)-1)) {
+ cros_crc8((uint8_t *)response_header,
+ sizeof(*response_header) - 1)) {
INCR_COMM_STATS(errcrc);
return EC_ERROR_CRC;
}
@@ -206,9 +206,10 @@ static int write_command(uint16_t command,
}
/* Check data CRC. */
- if (hascrc && data[rx_length - 1] !=
- crc8(&data[tx_length + sizeof(*request_header)],
- resp_len)) {
+ if (hascrc &&
+ data[rx_length - 1] !=
+ cros_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 ae845d58bc..001400da60 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 =
- crc8((uint8_t *)&header, sizeof(header)-1);
+ cros_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 = crc8(data, len);
+ crc = cros_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 !=
- crc8((uint8_t *)&header, sizeof(header)-1)) {
+ header.header_crc !=
+ cros_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] != crc8(params, len-1)) {
+ if (hascrc && params[len-1] != cros_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 09d446bf94..7702beebb3 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 = crc8(out, ARRAY_SIZE(out));
- pec_local = crc8_arg(in, in_size, pec_local);
+ pec_local = cros_crc8(out, ARRAY_SIZE(out));
+ pec_local = cros_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 = crc8(&addr_8bit, 1);
- pec = crc8_arg(out, out_size, pec);
+ pec = cros_crc8(&addr_8bit, 1);
+ pec = cros_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 = crc8(out, sizeof(out));
- pec = crc8_arg(&block_length, 1, pec);
- pec = crc8_arg(data, data_length, pec);
+ pec = cros_crc8(out, sizeof(out));
+ pec = cros_crc8_arg(&block_length, 1, pec);
+ pec = cros_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 = crc8_arg(&byte, 1, pec);
+ pec = cros_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 = crc8(&addr_8bit, sizeof(uint8_t));
- pec = crc8_arg(data, len, pec);
+ pec = cros_crc8(&addr_8bit, sizeof(uint8_t));
+ pec = cros_crc8_arg(data, len, pec);
}
/*
diff --git a/common/vboot/efs2.c b/common/vboot/efs2.c
index e608fd5841..f0b60e49e0 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 = crc8((uint8_t *)&p->type,
+ p->crc = cros_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 c634be8e33..26925ece03 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 = crc8(out, ARRAY_SIZE(out));
+ crc = cros_crc8(out, ARRAY_SIZE(out));
if (crc != real_crc)
return EC_ERROR_CRC;
diff --git a/include/crc8.h b/include/crc8.h
index e6e70e2bf3..45b2322b44 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 crc8(const uint8_t *data, int len);
+uint8_t cros_crc8(const uint8_t *data, int len);
/**
* crc8_arg
@@ -25,9 +25,10 @@ uint8_t 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 crc8()).
+ * Seed with zero for a new calculation (or use the result of
+ * cros_crc8()).
* @return the crc-8 of the input data.
*/
-uint8_t crc8_arg(const uint8_t *data, int len, uint8_t previous_crc);
+uint8_t cros_crc8_arg(const uint8_t *data, int len, uint8_t previous_crc);
#endif /* __CROS_EC_CRC8_H */