summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2022-08-24 15:53:20 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-26 23:03:37 +0000
commitecfd1db9c9c9d560ba5c2d4e71cea8bb179e9c74 (patch)
tree51c2c08eb084ec6c8194ec5c9b4ffe64ec8b7005
parentb0e6adc7f14ec16e777d30f06a638556c6e23360 (diff)
downloadchrome-ec-ecfd1db9c9c9d560ba5c2d4e71cea8bb179e9c74.tar.gz
Zephyr emul: Clarify TCPCI message type
Both the TCPCI emulator and the partner emulator have message structures with a member named "type". Re-name the TCPCI "type" to reduce confusion when the code references msg->type in both files. BRANCH=None BUG=b:243151272 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I600e8b046a701f53f21157a15d5073a127209076 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3859559 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/emul/tcpc/emul_tcpci.c12
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_partner_common.c6
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci.h2
-rw-r--r--zephyr/test/drivers/default/src/ps8xxx.c2
-rw-r--r--zephyr/test/drivers/default/src/tcpci_test_common.c16
5 files changed, 19 insertions, 19 deletions
diff --git a/zephyr/emul/tcpc/emul_tcpci.c b/zephyr/emul/tcpc/emul_tcpci.c
index 14f920c97e..432005bf3a 100644
--- a/zephyr/emul/tcpc/emul_tcpci.c
+++ b/zephyr/emul/tcpc/emul_tcpci.c
@@ -330,7 +330,7 @@ int tcpci_emul_add_rx_msg(const struct emul *emul,
return rc;
}
- switch (rx_msg->type) {
+ switch (rx_msg->sop_type) {
case TCPCI_MSG_SOP:
rx_detect_mask = TCPC_REG_RX_DETECT_SOP;
break;
@@ -370,7 +370,7 @@ int tcpci_emul_add_rx_msg(const struct emul *emul,
get_reg(ctx, TCPC_REG_ALERT, &alert_reg);
/* Handle HardReset */
- if (rx_msg->type == TCPCI_MSG_TX_HARD_RESET) {
+ if (rx_msg->sop_type == TCPCI_MSG_TX_HARD_RESET) {
tcpci_emul_disable_pd_msg_delivery(emul);
tcpci_emul_reset_mask_regs(ctx);
@@ -383,7 +383,7 @@ int tcpci_emul_add_rx_msg(const struct emul *emul,
}
/* Handle CableReset */
- if (rx_msg->type == TCPCI_MSG_CABLE_RESET) {
+ if (rx_msg->sop_type == TCPCI_MSG_CABLE_RESET) {
tcpci_emul_disable_pd_msg_delivery(emul);
/* Rest of CableReset handling is the same as SOP* message */
}
@@ -886,7 +886,7 @@ static int tcpci_emul_handle_rx_buf(const struct emul *emul, int reg,
tcpci_emul_set_i2c_interface_err(emul);
return -EIO;
} else if (bytes == 1) {
- *val = ctx->rx_msg->type;
+ *val = ctx->rx_msg->sop_type;
} else if (ctx->rx_msg->idx < ctx->rx_msg->cnt) {
*val = ctx->rx_msg->buf[ctx->rx_msg->idx];
ctx->rx_msg->idx++;
@@ -907,7 +907,7 @@ static int tcpci_emul_handle_rx_buf(const struct emul *emul, int reg,
if (ctx->rx_msg == NULL) {
*val = 0;
} else {
- *val = ctx->rx_msg->type;
+ *val = ctx->rx_msg->sop_type;
}
break;
@@ -1189,7 +1189,7 @@ static int tcpci_emul_handle_transmit(const struct emul *emul)
enum tcpci_msg_type type;
ctx->tx_msg->cnt = ctx->tx_msg->idx;
- ctx->tx_msg->type = TCPC_REG_TRANSMIT_TYPE(ctx->write_data);
+ ctx->tx_msg->sop_type = TCPC_REG_TRANSMIT_TYPE(ctx->write_data);
ctx->tx_msg->idx = 0;
type = TCPC_REG_TRANSMIT_TYPE(ctx->write_data);
diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c
index 5ad4d9dcb8..67072d4a74 100644
--- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c
+++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c
@@ -60,7 +60,7 @@ static struct tcpci_partner_msg *tcpci_partner_alloc_msg_helper(size_t size)
}
/* Set default message type to SOP */
- new_msg->msg.type = TCPCI_MSG_SOP;
+ new_msg->msg.sop_type = TCPCI_MSG_SOP;
new_msg->msg.cnt = size;
return new_msg;
@@ -162,7 +162,7 @@ static enum tcpci_emul_tx_status *tcpci_partner_log_msg(
}
log_msg->cnt = cnt;
- log_msg->sop = msg->type;
+ log_msg->sop = msg->sop_type;
log_msg->time = k_uptime_get();
log_msg->sender = sender;
log_msg->status = status;
@@ -487,7 +487,7 @@ void tcpci_partner_common_send_hard_reset(struct tcpci_partner_data *data)
tcpci_partner_common_hard_reset(data);
msg = tcpci_partner_alloc_standard_msg(0);
- msg->msg.type = TCPCI_MSG_TX_HARD_RESET;
+ msg->msg.sop_type = TCPCI_MSG_TX_HARD_RESET;
tcpci_partner_send_msg(data, msg, 0);
}
diff --git a/zephyr/include/emul/tcpc/emul_tcpci.h b/zephyr/include/emul/tcpc/emul_tcpci.h
index 25bde7bd06..378967355e 100644
--- a/zephyr/include/emul/tcpc/emul_tcpci.h
+++ b/zephyr/include/emul/tcpc/emul_tcpci.h
@@ -32,7 +32,7 @@ struct tcpci_emul_msg {
/** Number of bytes in buf */
int cnt;
/** Type of message (SOP, SOP', etc) */
- uint8_t type;
+ uint8_t sop_type;
/** Index used to mark accessed byte */
int idx;
/** Pointer to optional second message */
diff --git a/zephyr/test/drivers/default/src/ps8xxx.c b/zephyr/test/drivers/default/src/ps8xxx.c
index 83724a89c7..9d2ffc9fe5 100644
--- a/zephyr/test/drivers/default/src/ps8xxx.c
+++ b/zephyr/test/drivers/default/src/ps8xxx.c
@@ -349,7 +349,7 @@ static void test_ps8xxx_transmit(void)
USBC_PORT_C1, TCPCI_MSG_TX_BIST_MODE_2, 0, NULL),
NULL);
check_tcpci_reg(ps8xxx_emul, PS8XXX_REG_BIST_CONT_MODE_CTR, 0);
- zassert_equal(TCPCI_MSG_TX_BIST_MODE_2, msg->type, NULL);
+ zassert_equal(TCPCI_MSG_TX_BIST_MODE_2, msg->sop_type, NULL);
/* Check BIST counter value */
zassert_ok(tcpci_emul_get_reg(ps8xxx_emul,
diff --git a/zephyr/test/drivers/default/src/tcpci_test_common.c b/zephyr/test/drivers/default/src/tcpci_test_common.c
index 3fb1cd40e9..4b9c7903f7 100644
--- a/zephyr/test/drivers/default/src/tcpci_test_common.c
+++ b/zephyr/test/drivers/default/src/tcpci_test_common.c
@@ -493,7 +493,7 @@ void test_tcpci_get_rx_message_raw(const struct emul *emul,
}
msg.buf = buf;
msg.cnt = 31;
- msg.type = TCPCI_MSG_SOP;
+ msg.sop_type = TCPCI_MSG_SOP;
zassert_equal(TCPCI_EMUL_TX_SUCCESS,
tcpci_emul_add_rx_msg(emul, &msg, true),
"Failed to setup emulator message");
@@ -529,7 +529,7 @@ void test_tcpci_get_rx_message_raw(const struct emul *emul,
/* Test alert register and message payload on success */
size = 28;
msg.cnt = size + 2;
- msg.type = TCPCI_MSG_SOP_PRIME;
+ msg.sop_type = TCPCI_MSG_SOP_PRIME;
zassert_equal(TCPCI_EMUL_TX_SUCCESS,
tcpci_emul_add_rx_msg(emul, &msg, true),
"Failed to setup emulator message");
@@ -577,13 +577,13 @@ void test_tcpci_transmit(const struct emul *emul,
zassert_equal(EC_SUCCESS,
drv->transmit(port, TCPCI_MSG_CABLE_RESET, 0, NULL),
NULL);
- zassert_equal(TCPCI_MSG_CABLE_RESET, msg->type, NULL);
+ zassert_equal(TCPCI_MSG_CABLE_RESET, msg->sop_type, NULL);
/* Test transmit hard reset */
zassert_equal(EC_SUCCESS,
drv->transmit(port, TCPCI_MSG_TX_HARD_RESET, 0, NULL),
NULL);
- zassert_equal(TCPCI_MSG_TX_HARD_RESET, msg->type, NULL);
+ zassert_equal(TCPCI_MSG_TX_HARD_RESET, msg->sop_type, NULL);
/* Test transmit fail on rx buffer */
i2c_common_emul_set_write_fail_reg(common_data, TCPC_REG_TX_BUFFER);
@@ -599,7 +599,7 @@ void test_tcpci_transmit(const struct emul *emul,
zassert_equal(EC_SUCCESS,
drv->transmit(port, TCPCI_MSG_SOP_PRIME, header, data),
NULL);
- zassert_equal(TCPCI_MSG_SOP_PRIME, msg->type, NULL);
+ zassert_equal(TCPCI_MSG_SOP_PRIME, msg->sop_type, NULL);
zassert_mem_equal(msg->buf, &header, 2, NULL);
zassert_equal(2, msg->cnt, NULL);
@@ -610,7 +610,7 @@ void test_tcpci_transmit(const struct emul *emul,
zassert_equal(EC_SUCCESS,
drv->transmit(port, TCPCI_MSG_SOP_PRIME, header, data),
NULL);
- zassert_equal(TCPCI_MSG_SOP_PRIME, msg->type, NULL);
+ zassert_equal(TCPCI_MSG_SOP_PRIME, msg->sop_type, NULL);
zassert_mem_equal(msg->buf, &header, 2, NULL);
zassert_mem_equal(msg->buf + 2, data, 6 * sizeof(uint32_t), NULL);
zassert_equal(2 + 6 * sizeof(uint32_t), msg->cnt, NULL);
@@ -686,11 +686,11 @@ void test_tcpci_alert_rx_message(const struct emul *emul,
size = 23;
msg1.buf = buf1;
msg1.cnt = size + 3;
- msg1.type = TCPCI_MSG_SOP;
+ msg1.sop_type = TCPCI_MSG_SOP;
msg2.buf = buf2;
msg2.cnt = size + 3;
- msg2.type = TCPCI_MSG_SOP_PRIME;
+ msg2.sop_type = TCPCI_MSG_SOP_PRIME;
/* Test receiving one message */
zassert_equal(TCPCI_EMUL_TX_SUCCESS,