summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-08-04 11:19:55 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-20 14:32:44 +0000
commit8270698e589f14239b4942a42b27132af497410b (patch)
treeea10c53f412c229980ea24a6faf8572295b92f75 /common
parentd63ba9739b77bece9e0be136dd256c89ce2fd688 (diff)
downloadchrome-ec-8270698e589f14239b4942a42b27132af497410b.tar.gz
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 <peress@chromium.org> Change-Id: I3a5f5ad523d507c53a5d474806f58afafb82e70c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3074828 Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/system.c13
-rw-r--r--common/test_util.c5
2 files changed, 16 insertions, 2 deletions
diff --git a/common/system.c b/common/system.c
index 236b886f1d..6c1d0277e2 100644
--- a/common/system.c
+++ b/common/system.c
@@ -1174,6 +1174,7 @@ DECLARE_HOST_COMMAND(EC_CMD_SYSINFO, host_command_sysinfo,
static int command_scratchpad(int argc, char **argv)
{
int rv = EC_SUCCESS;
+ uint32_t scratchpad_value;
if (argc == 2) {
char *e;
@@ -1181,9 +1182,19 @@ static int command_scratchpad(int argc, char **argv)
if (*e)
return EC_ERROR_PARAM1;
rv = system_set_scratchpad(s);
+
+ if (rv) {
+ ccprintf("Error setting scratchpad register (%d)\b",
+ rv);
+ return rv;
+ }
}
- ccprintf("Scratchpad: 0x%08x\n", system_get_scratchpad());
+ rv = system_get_scratchpad(&scratchpad_value);
+ if (rv)
+ ccprintf("Error reading scratchpad register (%d)\n", rv);
+ else
+ ccprintf("Scratchpad: 0x%08x\n", scratchpad_value);
return rv;
}
DECLARE_CONSOLE_COMMAND(scratchpad, command_scratchpad,
diff --git a/common/test_util.c b/common/test_util.c
index 8b3cbaad03..b23f85509b 100644
--- a/common/test_util.c
+++ b/common/test_util.c
@@ -102,7 +102,10 @@ int test_get_error_count(void)
uint32_t test_get_state(void)
{
- return system_get_scratchpad();
+ uint32_t state;
+
+ system_get_scratchpad(&state);
+ return state;
}
test_mockable void test_clean_up(void)