Skip to content

Commit d7ae97e

Browse files
dnojiriTerrails
authored andcommitted
charge_state: Delete EC_CMD_CHARGE_CONTROL v1
V1 is superseded by v2. All hosts are using v2 today. This CL deletes v1. BUG=b:278898714 TEST=make run-sbs_charging LOW_COVERAGE_REASON=No new lines are added. Change-Id: I06e349b76e53a4d8ddc33e5bc4ac57b74ae778a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4828144 Commit-Queue: Daisuke Nojiri <[email protected]> Tested-by: Daisuke Nojiri <[email protected]> Reviewed-by: Keith Short <[email protected]> Auto-Submit: Daisuke Nojiri <[email protected]> Code-Coverage: Daisuke Nojiri <[email protected]>
1 parent f541f89 commit d7ae97e

File tree

2 files changed

+24
-34
lines changed

2 files changed

+24
-34
lines changed

common/charge_state.c

+18-21
Original file line numberDiff line numberDiff line change
@@ -2085,28 +2085,25 @@ charge_command_charge_control(struct host_cmd_handler_args *args)
20852085
struct ec_response_charge_control *r = args->response;
20862086
int rv;
20872087

2088-
if (args->version >= 2) {
2089-
if (p->cmd == EC_CHARGE_CONTROL_CMD_SET) {
2090-
if (p->mode == CHARGE_CONTROL_NORMAL) {
2091-
rv = battery_sustainer_set(
2092-
p->sustain_soc.lower,
2093-
p->sustain_soc.upper);
2094-
if (rv == EC_RES_UNAVAILABLE)
2095-
return EC_RES_UNAVAILABLE;
2096-
if (rv)
2097-
return EC_RES_INVALID_PARAM;
2098-
} else {
2099-
battery_sustainer_disable();
2100-
}
2101-
} else if (p->cmd == EC_CHARGE_CONTROL_CMD_GET) {
2102-
r->mode = get_chg_ctrl_mode();
2103-
r->sustain_soc.lower = sustain_soc.lower;
2104-
r->sustain_soc.upper = sustain_soc.upper;
2105-
args->response_size = sizeof(*r);
2106-
return EC_RES_SUCCESS;
2088+
if (p->cmd == EC_CHARGE_CONTROL_CMD_SET) {
2089+
if (p->mode == CHARGE_CONTROL_NORMAL) {
2090+
rv = battery_sustainer_set(p->sustain_soc.lower,
2091+
p->sustain_soc.upper);
2092+
if (rv == EC_RES_UNAVAILABLE)
2093+
return EC_RES_UNAVAILABLE;
2094+
if (rv)
2095+
return EC_RES_INVALID_PARAM;
21072096
} else {
2108-
return EC_RES_INVALID_PARAM;
2097+
battery_sustainer_disable();
21092098
}
2099+
} else if (p->cmd == EC_CHARGE_CONTROL_CMD_GET) {
2100+
r->mode = get_chg_ctrl_mode();
2101+
r->sustain_soc.lower = sustain_soc.lower;
2102+
r->sustain_soc.upper = sustain_soc.upper;
2103+
args->response_size = sizeof(*r);
2104+
return EC_RES_SUCCESS;
2105+
} else {
2106+
return EC_RES_INVALID_PARAM;
21102107
}
21112108

21122109
rv = set_chg_ctrl_mode(p->mode);
@@ -2116,7 +2113,7 @@ charge_command_charge_control(struct host_cmd_handler_args *args)
21162113
return EC_RES_SUCCESS;
21172114
}
21182115
DECLARE_HOST_COMMAND(EC_CMD_CHARGE_CONTROL, charge_command_charge_control,
2119-
EC_VER_MASK(1) | EC_VER_MASK(2));
2116+
EC_VER_MASK(2));
21202117

21212118
static enum ec_status
21222119
charge_command_current_limit(struct host_cmd_handler_args *args)

util/ectool.cc

+6-13
Original file line numberDiff line numberDiff line change
@@ -7666,15 +7666,14 @@ int cmd_charge_control(int argc, char *argv[])
76667666
char *e;
76677667
int rv;
76687668

7669-
if (!ec_cmd_version_supported(EC_CMD_CHARGE_CONTROL, 2))
7670-
version = 1;
7669+
if (!ec_cmd_version_supported(EC_CMD_CHARGE_CONTROL, 2)) {
7670+
fprintf(stderr,
7671+
"EC doesn't support V2+ of charge control command.\n"
7672+
"Consider firmware update.\n");
7673+
return -1;
7674+
}
76717675

76727676
if (argc == 1) {
7673-
if (version < 2) {
7674-
cmd_charge_control_help(argv[0],
7675-
"Old EC doesn't support GET.");
7676-
return -1;
7677-
}
76787677
p.cmd = EC_CHARGE_CONTROL_CMD_GET;
76797678
rv = ec_command(EC_CMD_CHARGE_CONTROL, version, &p, sizeof(p),
76807679
&r, sizeof(r));
@@ -7703,12 +7702,6 @@ int cmd_charge_control(int argc, char *argv[])
77037702
p.sustain_soc.lower = -1;
77047703
p.sustain_soc.upper = -1;
77057704
} else if (argc == 4) {
7706-
if (version < 2) {
7707-
cmd_charge_control_help(
7708-
argv[0],
7709-
"Old EC doesn't support sustainer.");
7710-
return -1;
7711-
}
77127705
p.sustain_soc.lower = strtol(argv[2], &e, 0);
77137706
if (e && *e) {
77147707
cmd_charge_control_help(

0 commit comments

Comments
 (0)