diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-07-12 10:01:23 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-19 16:29:14 +0000 |
commit | 8d30a05ed74730fece3ebf0fd617426c565541ce (patch) | |
tree | 697a064455230b2358246d52feb5eb4e94ec2fd0 /driver/nfc | |
parent | e97b3e407b786e95cabef7977d42998f0ed13be8 (diff) | |
download | chrome-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 'driver/nfc')
-rw-r--r-- | driver/nfc/ctn730.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c index 16ab40d025..ea7eeb29df 100644 --- a/driver/nfc/ctn730.c +++ b/driver/nfc/ctn730.c @@ -10,6 +10,7 @@ #include "gpio.h" #include "i2c.h" #include "peripheral_charger.h" +#include "printf.h" #include "timer.h" #include "util.h" #include "watchdog.h" @@ -256,8 +257,13 @@ static int _process_payload_response(struct pchg *ctx, struct ctn730_msg *res) int rv = _i2c_read(ctx->cfg->i2c_port, buf, len); if (rv) return rv; - if (IS_ENABLED(CTN730_DEBUG)) - CPRINTS("Payload: %ph", HEX_BUF(buf, len)); + if (IS_ENABLED(CTN730_DEBUG)) { + char str_buf[hex_str_buf_size(len)]; + + snprintf_hex_buffer(str_buf, sizeof(str_buf), + HEX_BUF(buf, len)); + CPRINTS("Payload: %s", str_buf); + } } ctx->event = PCHG_EVENT_NONE; @@ -357,8 +363,13 @@ static int _process_payload_event(struct pchg *ctx, struct ctn730_msg *res) int rv = _i2c_read(ctx->cfg->i2c_port, buf, len); if (rv) return rv; - if (IS_ENABLED(CTN730_DEBUG)) - CPRINTS("Payload: %ph", HEX_BUF(buf, len)); + if (IS_ENABLED(CTN730_DEBUG)) { + char str_buf[hex_str_buf_size(len)]; + + snprintf_hex_buffer(str_buf, sizeof(str_buf), + HEX_BUF(buf, len)); + CPRINTS("Payload: %s", str_buf); + } } ctx->event = PCHG_EVENT_NONE; |