summaryrefslogtreecommitdiff
path: root/util/ectool.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/ectool.c')
-rw-r--r--util/ectool.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 13062afcbf..17a5ad011a 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -34,7 +34,7 @@ const char help_str[] =
" Enable/disable LCD backlight\n"
" battery\n"
" Prints battery info\n"
- " batterycutoff\n"
+ " batterycutoff [at-shutdown]\n"
" Cut off battery output power\n"
" batteryparam\n"
" Read or write board-specific battery parameter\n"
@@ -3653,9 +3653,21 @@ cmd_error:
int cmd_battery_cut_off(int argc, char *argv[])
{
+ struct ec_params_battery_cutoff p;
int rv;
- rv = ec_command(EC_CMD_BATTERY_CUT_OFF, 0, NULL, 0, NULL, 0);
+ memset(&p, 0, sizeof(p));
+ if (argc > 1) {
+ if (!strcasecmp(argv[1], "at-shutdown")) {
+ p.flags = EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN;
+ } else {
+ fprintf(stderr, "Bad parameter: %s\n", argv[1]);
+ return -1;
+ }
+ }
+
+ rv = ec_command(EC_CMD_BATTERY_CUT_OFF, EC_VER_BATTERY_CUT_OFF,
+ &p, sizeof(p), NULL, 0);
rv = (rv < 0 ? rv : 0);
if (rv < 0) {
@@ -3666,11 +3678,14 @@ int cmd_battery_cut_off(int argc, char *argv[])
EC_RES_INVALID_COMMAND);
} else {
printf("\n");
- printf("SUCCESS. The battery has arranged a cut-off and\n");
- printf("the system should be shutdown immediately.\n");
+ printf("SUCCESS. The battery has arranged a cut-off.\n");
+
+ if (p.flags & EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN)
+ printf("The battery will be cut off after shutdown.\n");
+ else
+ printf("The system should be shutdown immediately.\n");
+
printf("\n");
- printf("If the system is still alive, you could remove\n");
- printf("the AC power and try again.\n");
}
return rv;
}