summaryrefslogtreecommitdiff
path: root/common/i2c_trace.c
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2020-04-03 23:38:09 -0600
committerCommit Bot <commit-bot@chromium.org>2020-04-07 02:20:38 +0000
commited4ffafa80319a0084b684eb0b9f95c120922862 (patch)
treec364070288a12fdb8199b8c39a3cac9d657213e3 /common/i2c_trace.c
parent2dd71e66565bc09852567958b1f48748b7d20a49 (diff)
downloadchrome-ec-ed4ffafa80319a0084b684eb0b9f95c120922862.tar.gz
i2c: Fix port bug with i2ctrace and i2cscan commands
'port' is not the index into i2c_ports[]. Fix i2ctrace and i2cscan to use get_i2c_port() to find the matching port in i2c_ports[] table. Add the port name to the 'i2ctrace list' output to make it clear which port it is. > i2ctrace list id port address -- ---- ------- 0 8 ap_audio 0x4A 1 9 ap_hdmi 0x5A to 0x5F 2 3 ap_mux 0x30 3 4 thermal 0x40 4 5 sensor 0x50 BUG=none BRANCH=none TEST=i2ctrace for I2C_PORT_AP_HDMI on Zork: i2ctrace enable 9 0x4a Signed-off-by: Edward Hill <ecgh@chromium.org> Change-Id: I7b897ac9154751a46ef5961aded569aaec49bfd4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2136526 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'common/i2c_trace.c')
-rw-r--r--common/i2c_trace.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/common/i2c_trace.c b/common/i2c_trace.c
index 6645b9a303..340de901f9 100644
--- a/common/i2c_trace.c
+++ b/common/i2c_trace.c
@@ -56,15 +56,18 @@ trace_enabled:
static int command_i2ctrace_list(void)
{
size_t i;
+ const struct i2c_port_t *i2c_port;
- ccprintf("id port address\n");
- ccprintf("-- ---- -------\n");
+ ccprintf("id port address\n");
+ ccprintf("-- ---- -------\n");
for (i = 0; i < ARRAY_SIZE(trace_entries); i++) {
if (trace_entries[i].enabled) {
- ccprintf("%2d %4d 0x%X",
+ i2c_port = get_i2c_port(trace_entries[i].port);
+ ccprintf("%-2zd %d %-8s 0x%X",
i,
trace_entries[i].port,
+ i2c_port->name,
trace_entries[i].slave_addr_lo);
if (trace_entries[i].slave_addr_hi
!= trace_entries[i].slave_addr_lo)
@@ -92,7 +95,7 @@ static int command_i2ctrace_enable(int port, int slave_addr_lo,
struct i2c_trace_range *t;
struct i2c_trace_range *new_entry = NULL;
- if (port >= i2c_ports_used)
+ if (!get_i2c_port(port))
return EC_ERROR_PARAM2;
if (slave_addr_lo > slave_addr_hi)