summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2019-08-01 14:59:45 -0600
committerCommit Bot <commit-bot@chromium.org>2019-08-20 20:00:40 +0000
commit7470bbfae198c0efd07ece8dceac714d8ad0a6ff (patch)
tree3fe1c4d3cc84339dfb2e839b17f1eb424e93b57f
parent4cd06cf22b89b7d400c76897d011327b70cee842 (diff)
downloadchrome-ec-7470bbfae198c0efd07ece8dceac714d8ad0a6ff.tar.gz
cleanup: use STATIC_IF for hibernate variables
This is an example usage of STATIC_IF, as a child CL of the STATIC_IF implementation. BUG=chromium:989786 BRANCH=none TEST=buildall Change-Id: I1e69bf85a3daf8aa5f5c0e0b1da9808a8a5f8649 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1731972 Reviewed-by: Raul E Rangel <rrangel@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Raul E Rangel <rrangel@chromium.org>
-rw-r--r--common/system.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/common/system.c b/common/system.c
index fec9b63380..db12aa5535 100644
--- a/common/system.c
+++ b/common/system.c
@@ -92,10 +92,8 @@ static int disable_jump; /* Disable ALL jumps if system is locked */
static int force_locked; /* Force system locked even if WP isn't enabled */
static enum ec_reboot_cmd reboot_at_shutdown;
-#ifdef CONFIG_HIBERNATE
-static uint32_t hibernate_seconds;
-static uint32_t hibernate_microseconds;
-#endif
+STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_seconds;
+STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_microseconds;
/* On-going actions preventing going into deep-sleep mode */
uint32_t sleep_mask;
@@ -900,20 +898,24 @@ static int handle_pending_reboot(enum ec_reboot_cmd cmd)
case EC_REBOOT_DISABLE_JUMP:
system_disable_jump();
return EC_SUCCESS;
-#ifdef CONFIG_HIBERNATE
case EC_REBOOT_HIBERNATE_CLEAR_AP_OFF:
-#ifdef CONFIG_POWER_BUTTON_INIT_IDLE
- CPRINTS("Clearing AP_OFF");
- chip_save_reset_flags(
+ if (!IS_ENABLED(CONFIG_HIBERNATE))
+ return EC_ERROR_INVAL;
+
+ if (IS_ENABLED(CONFIG_POWER_BUTTON_INIT_IDLE)) {
+ CPRINTS("Clearing AP_OFF");
+ chip_save_reset_flags(
chip_read_reset_flags() & ~RESET_FLAG_AP_OFF);
-#endif
+ }
/* Intentional fall-through */
case EC_REBOOT_HIBERNATE:
+ if (!IS_ENABLED(CONFIG_HIBERNATE))
+ return EC_ERROR_INVAL;
+
CPRINTS("system hibernating");
system_hibernate(hibernate_seconds, hibernate_microseconds);
/* That shouldn't return... */
return EC_ERROR_UNKNOWN;
-#endif
default:
return EC_ERROR_INVAL;
}
@@ -984,8 +986,7 @@ DECLARE_CONSOLE_COMMAND(scratchpad, command_scratchpad,
"Get or set scratchpad value");
#endif /* CONFIG_CMD_SCRATCHPAD */
-#ifdef CONFIG_HIBERNATE
-static int command_hibernate(int argc, char **argv)
+__maybe_unused static int command_hibernate(int argc, char **argv)
{
int seconds = 0;
int microseconds = 0;
@@ -1017,6 +1018,7 @@ static int command_hibernate(int argc, char **argv)
return EC_SUCCESS;
}
+#ifdef CONFIG_HIBERNATE
DECLARE_CONSOLE_COMMAND(hibernate, command_hibernate,
"[sec] [usec]",
"Hibernate the EC");