summaryrefslogtreecommitdiff
path: root/common/i2c_trace.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2022-06-27 14:36:38 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-06-28 09:10:26 +0000
commit6a9bb2a6ca1c125dd177dfcf2b4c4cbd5830df96 (patch)
tree22bc238b3ab70f332e6b9a261016c9ae5e798d3f /common/i2c_trace.c
parent98ba4365a28607a1e5eb55497bcfe67d7f6c1729 (diff)
downloadchrome-ec-6a9bb2a6ca1c125dd177dfcf2b4c4cbd5830df96.tar.gz
common/i2c_trace.c: Format with clang-format
BUG=b:236386294 BRANCH=none TEST=none Change-Id: Ie311c38df6e602bd2a3003f1edc5869e8c9084ff Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729638 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'common/i2c_trace.c')
-rw-r--r--common/i2c_trace.c64
1 files changed, 25 insertions, 39 deletions
diff --git a/common/i2c_trace.c b/common/i2c_trace.c
index af65d85210..b39f0f5266 100644
--- a/common/i2c_trace.c
+++ b/common/i2c_trace.c
@@ -11,8 +11,8 @@
#include "util.h"
#define CPUTS(outstr) cputs(CC_I2C, outstr)
-#define CPRINTS(format, args...) cprints(CC_I2C, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_I2C, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args)
struct i2c_trace_range {
bool enabled;
@@ -23,18 +23,17 @@ struct i2c_trace_range {
static struct i2c_trace_range trace_entries[8];
-void i2c_trace_notify(int port, uint16_t addr_flags,
- const uint8_t *out_data, size_t out_size,
- const uint8_t *in_data, size_t in_size, int ret)
+void i2c_trace_notify(int port, uint16_t addr_flags, const uint8_t *out_data,
+ size_t out_size, const uint8_t *in_data, size_t in_size,
+ int ret)
{
size_t i;
uint16_t addr = I2C_STRIP_FLAGS(addr_flags);
for (i = 0; i < ARRAY_SIZE(trace_entries); i++)
- if (trace_entries[i].enabled
- && trace_entries[i].port == port
- && trace_entries[i].addr_lo <= addr
- && trace_entries[i].addr_hi >= addr)
+ if (trace_entries[i].enabled && trace_entries[i].port == port &&
+ trace_entries[i].addr_lo <= addr &&
+ trace_entries[i].addr_hi >= addr)
goto trace_enabled;
return;
@@ -66,19 +65,16 @@ static int command_i2ctrace_list(void)
for (i = 0; i < ARRAY_SIZE(trace_entries); i++) {
if (trace_entries[i].enabled) {
i2c_port = get_i2c_port(trace_entries[i].port);
- ccprintf("%-2zd %d %-8s 0x%X",
- i,
- trace_entries[i].port,
+ ccprintf("%-2zd %d %-8s 0x%X", i, trace_entries[i].port,
#ifndef CONFIG_ZEPHYR
i2c_port->name,
#else
"",
#endif /* CONFIG_ZEPHYR */
trace_entries[i].addr_lo);
- if (trace_entries[i].addr_hi
- != trace_entries[i].addr_lo)
- ccprintf(" to 0x%X",
- trace_entries[i].addr_hi);
+ if (trace_entries[i].addr_hi !=
+ trace_entries[i].addr_lo)
+ ccprintf(" to 0x%X", trace_entries[i].addr_hi);
ccprintf("\n");
}
}
@@ -95,8 +91,7 @@ static int command_i2ctrace_disable(size_t id)
return EC_SUCCESS;
}
-static int command_i2ctrace_enable(int port, int addr_lo,
- int addr_hi)
+static int command_i2ctrace_enable(int port, int addr_lo, int addr_hi)
{
struct i2c_trace_range *t;
struct i2c_trace_range *new_entry = NULL;
@@ -111,41 +106,34 @@ static int command_i2ctrace_enable(int port, int addr_lo,
* Scan thru existing entries to see if there is one we can
* extend instead of making a new entry
*/
- for (t = trace_entries;
- t < trace_entries + ARRAY_SIZE(trace_entries);
+ for (t = trace_entries; t < trace_entries + ARRAY_SIZE(trace_entries);
t++) {
if (t->enabled && t->port == port) {
/* Subset of existing range, do nothing */
- if (t->addr_lo <= addr_lo &&
- t->addr_hi >= addr_hi)
+ if (t->addr_lo <= addr_lo && t->addr_hi >= addr_hi)
return EC_SUCCESS;
/* Extends exising range on both directions, replace */
- if (t->addr_lo >= addr_lo &&
- t->addr_hi <= addr_hi) {
+ if (t->addr_lo >= addr_lo && t->addr_hi <= addr_hi) {
t->enabled = 0;
- return command_i2ctrace_enable(
- port, addr_lo, addr_hi);
+ return command_i2ctrace_enable(port, addr_lo,
+ addr_hi);
}
/* Extends existing range below */
if (t->addr_lo - 1 <= addr_hi &&
t->addr_hi >= addr_hi) {
t->enabled = 0;
- return command_i2ctrace_enable(
- port,
- addr_lo,
- t->addr_hi);
+ return command_i2ctrace_enable(port, addr_lo,
+ t->addr_hi);
}
/* Extends existing range above */
if (t->addr_lo <= addr_lo &&
t->addr_hi + 1 >= addr_lo) {
t->enabled = 0;
- return command_i2ctrace_enable(
- port,
- t->addr_lo,
- addr_hi);
+ return command_i2ctrace_enable(port, t->addr_lo,
+ addr_hi);
}
} else if (!t->enabled && !new_entry) {
new_entry = t;
@@ -165,7 +153,6 @@ static int command_i2ctrace_enable(int port, int addr_lo,
return EC_ERROR_MEMORY_ALLOCATION;
}
-
static int command_i2ctrace(int argc, char **argv)
{
int id_or_port;
@@ -204,14 +191,13 @@ static int command_i2ctrace(int argc, char **argv)
return EC_ERROR_PARAM_COUNT;
}
- return command_i2ctrace_enable(
- id_or_port, address_low, address_high);
+ return command_i2ctrace_enable(id_or_port, address_low,
+ address_high);
}
return EC_ERROR_PARAM1;
}
-DECLARE_CONSOLE_COMMAND(i2ctrace,
- command_i2ctrace,
+DECLARE_CONSOLE_COMMAND(i2ctrace, command_i2ctrace,
"[list | disable <id> | enable <port> <address> | "
"enable <port> <address-low> <address-high>]",
"Trace I2C transactions");