From 8270698e589f14239b4942a42b27132af497410b Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Wed, 4 Aug 2021 11:19:55 -0600 Subject: system: fix system_get_scratchpad API The current API for system_get_scratchpad mixes the status and the value being read. Update the signature to allow both. BRANCH=none BUG=b:195481980 TEST=make testall && zmake testall Signed-off-by: Yuval Peress Change-Id: I3a5f5ad523d507c53a5d474806f58afafb82e70c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3074828 Commit-Queue: Denis Brockus Reviewed-by: Denis Brockus --- test/kb_scan.c | 4 +++- test/scratchpad.c | 4 ++-- test/system.c | 27 +++++++++++++++++---------- test/utils.c | 5 ++++- 4 files changed, 26 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/kb_scan.c b/test/kb_scan.c index b3b42813e4..a43808c0c1 100644 --- a/test/kb_scan.c +++ b/test/kb_scan.c @@ -557,7 +557,9 @@ static int test_check_boot_down(void) void test_init(void) { - uint32_t state = system_get_scratchpad(); + uint32_t state; + + system_get_scratchpad(&state); if (state & TEST_STATE_MASK(TEST_STATE_STEP_2)) { /* Power-F3-ESC */ diff --git a/test/scratchpad.c b/test/scratchpad.c index eeae7fcb93..1bea76f7a1 100644 --- a/test/scratchpad.c +++ b/test/scratchpad.c @@ -15,13 +15,13 @@ test_static int test_scratchpad(void) int rv; uint32_t scratch; - scratch = system_get_scratchpad(); + TEST_EQ(system_get_scratchpad(&scratch), EC_SUCCESS, "%d"); TEST_EQ(scratch, 0, "%d"); rv = system_set_scratchpad(1); TEST_EQ(rv, EC_SUCCESS, "%d"); - scratch = system_get_scratchpad(); + TEST_EQ(system_get_scratchpad(&scratch), EC_SUCCESS, "%d"); TEST_EQ(scratch, 1, "%d"); return EC_SUCCESS; diff --git a/test/system.c b/test/system.c index 6874708cc7..79383b82d9 100644 --- a/test/system.c +++ b/test/system.c @@ -29,9 +29,9 @@ static int test_reboot_on_shutdown(void) params.cmd = EC_REBOOT_COLD; params.flags = EC_REBOOT_FLAG_ON_AP_SHUTDOWN; - TEST_ASSERT(test_send_host_command( - EC_CMD_REBOOT_EC, 0, ¶ms, - sizeof(params), NULL, 0) == EC_SUCCESS); + TEST_EQ(test_send_host_command(EC_CMD_REBOOT_EC, 0, ¶ms, + sizeof(params), NULL, 0), + EC_SUCCESS, "%d"); system_set_scratchpad(TEST_STATE_STEP_2); test_chipset_off(); @@ -54,16 +54,16 @@ static int test_cancel_reboot(void) params.cmd = EC_REBOOT_COLD; params.flags = EC_REBOOT_FLAG_ON_AP_SHUTDOWN; - TEST_ASSERT(test_send_host_command( - EC_CMD_REBOOT_EC, 0, ¶ms, - sizeof(params), NULL, 0) == EC_SUCCESS); + TEST_EQ(test_send_host_command(EC_CMD_REBOOT_EC, 0, ¶ms, + sizeof(params), NULL, 0), + EC_SUCCESS, "%d"); params.cmd = EC_REBOOT_CANCEL; params.flags = 0; - TEST_ASSERT(test_send_host_command( - EC_CMD_REBOOT_EC, 0, ¶ms, - sizeof(params), NULL, 0) == EC_SUCCESS); + TEST_EQ(test_send_host_command(EC_CMD_REBOOT_EC, 0, ¶ms, + sizeof(params), NULL, 0), + EC_SUCCESS, "%d"); test_chipset_off(); msleep(30); @@ -94,7 +94,14 @@ static void fail_and_clean_up(void) void run_test(int argc, char **argv) { - uint32_t state = system_get_scratchpad(); + uint32_t state = 0; + + /* The return value isn't checked here on purpose. The scratchpad file + * may exist from a previous run or it may be in a clean state. A + * previous run of this test should reset the scratchpad value to 0 + * regardless of the final result. + */ + system_get_scratchpad(&state); test_reset(); diff --git a/test/utils.c b/test/utils.c index 9402e92740..ede0c807ed 100644 --- a/test/utils.c +++ b/test/utils.c @@ -270,8 +270,11 @@ static int test_shared_mem(void) static int test_scratchpad(void) { + uint32_t scratchpad_value; + system_set_scratchpad(0xfeed); - TEST_ASSERT(system_get_scratchpad() == 0xfeed); + TEST_EQ(system_get_scratchpad(&scratchpad_value), EC_SUCCESS, "%d"); + TEST_EQ(scratchpad_value, 0xfeed, "%d"); return EC_SUCCESS; } -- cgit v1.2.1