summaryrefslogtreecommitdiff
path: root/chip/g/idle.c
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2017-02-02 20:08:50 -0800
committerVadim Bendebury <vbendeb@chromium.org>2017-02-07 02:43:49 +0000
commitabef8dd8f43989cdf73bfc20d9cb3f8f839c9a82 (patch)
treef83a60431c2e2823ff11366713b2bc5c7559d914 /chip/g/idle.c
parent43298813e963f12173be63886607c3690a4931d9 (diff)
downloadchrome-ec-abef8dd8f43989cdf73bfc20d9cb3f8f839c9a82.tar.gz
g: allow idle console command in read-only mode in prod images
Being able to determine what sleep state the system is in is very handy, and reading the state is pretty safe. Let's declare the idle console command safe and disallow its parameters when console is locked. BRANCH=none BUG=none TEST=verified that it is possible to read the idle state when console is locked, but not possible to set it. Change-Id: I97f680bf033290220a4fa7fd5a7af170736443d8 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/436905 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'chip/g/idle.c')
-rw-r--r--chip/g/idle.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/chip/g/idle.c b/chip/g/idle.c
index 0d4656a8c6..1d365dd06c 100644
--- a/chip/g/idle.c
+++ b/chip/g/idle.c
@@ -44,6 +44,10 @@ static int command_idle(int argc, char **argv)
int c, i;
if (argc > 1) {
+ if (console_is_restricted()) {
+ ccprintf("Console is locked, no parameters allowed\n");
+ return EC_ERROR_INVAL;
+ }
c = tolower(argv[1][0]);
for (i = 1; i < ARRAY_SIZE(idle_name); i++)
if (idle_name[i][0] == c) {
@@ -56,9 +60,9 @@ static int command_idle(int argc, char **argv)
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(idle, command_idle,
- "[w|s|d]",
- "Set or show the idle action: wfi, sleep, deep sleep");
+DECLARE_SAFE_CONSOLE_COMMAND(idle, command_idle,
+ "[w|s|d]",
+ "Set or show the idle action: wfi, sleep, deep sleep");
static int utmi_wakeup_is_enabled(void)
{