summaryrefslogtreecommitdiff
path: root/common/spi_commands.c
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-07-12 10:01:23 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-19 16:29:14 +0000
commit8d30a05ed74730fece3ebf0fd617426c565541ce (patch)
tree697a064455230b2358246d52feb5eb4e94ec2fd0 /common/spi_commands.c
parente97b3e407b786e95cabef7977d42998f0ed13be8 (diff)
downloadchrome-ec-8d30a05ed74730fece3ebf0fd617426c565541ce.tar.gz
tree: Remove non-standard "%ph" printf format
The non-standard "%ph" format is replaced with snprintf_hex_buffer and then using "%s" to print the resulting buffer. Using standard format specifiers makes it easier to switch between the "builtin" EC standard library and the C standard library provided by the toolchain (or Zephyr). BRANCH=none BUG=b:238433667, b:234181908 TEST=Enable CONFIG_CMD_RAND in nocturne_fp/board.h On icetower v0.1 with servo_micro and J-Trace: Before change: > rand rand 8ab8b15090ca5ae83bdad671c906d51a5f2b98a359a4106054ee6b54a4087190 After change: > rand rand 2a8645235a31936a28b8d1b9c4948f46d39662e7fcb10a185ddb14c6a998e2eb Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I3bff928d32579440d7cdb27a75899e45159accfb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3759123 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'common/spi_commands.c')
-rw-r--r--common/spi_commands.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/common/spi_commands.c b/common/spi_commands.c
index 45c2f3ce70..b51609d257 100644
--- a/common/spi_commands.c
+++ b/common/spi_commands.c
@@ -8,6 +8,7 @@
#include "common.h"
#include "console.h"
+#include "printf.h"
#include "spi.h"
#include "timer.h"
#include "util.h"
@@ -45,8 +46,13 @@ static int command_spixfer(int argc, char **argv)
rv = spi_transaction(&spi_devices[dev_id], &cmd, 1, data, v);
- if (!rv)
- ccprintf("Data: %ph\n", HEX_BUF(data, v));
+ if (!rv) {
+ char str_buf[hex_str_buf_size(v)];
+
+ snprintf_hex_buffer(str_buf, sizeof(str_buf),
+ HEX_BUF(data, v));
+ ccprintf("Data: %s\n", str_buf);
+ }
} else if (strcasecmp(argv[1], "w") == 0) {
/* 8-bit write */