diff options
author | Tom Hughes <tomhughes@chromium.org> | 2019-06-10 15:39:25 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-24 21:12:41 +0000 |
commit | 4f7f1b7fc6eec40094000e77e87f22f512f8321b (patch) | |
tree | 39163a5268377d0d414ab112aa2c406401669b54 /common/fpsensor/fpsensor_state.c | |
parent | b1fa948170aa5b5441914797256db6fb04b4464c (diff) | |
download | chrome-ec-4f7f1b7fc6eec40094000e77e87f22f512f8321b.tar.gz |
fpsensor: Refactor fp_command_mode
This refactoring allows us to call fp_command_mode from the debug
console commands and ensure that we're testing the same underlying code
path that the host commands use.
BRANCH=nocturne
BUG=b:124773209
TEST="fpenroll" in hatch FP console
"fpmatch" in hatch FP console
"fpclear" in hatch FP console
TEST=On nocturne:
flash_fp_mcu ec.bin
Enroll fingerprint via UI, lock/unlock, Remove fingerprint via UI
Change-Id: I5e1e314c7f1d67dc663795cafe751545516e9f89
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1652285
Reviewed-by: Nicolas Norvez <norvez@chromium.org>
Diffstat (limited to 'common/fpsensor/fpsensor_state.c')
-rw-r--r-- | common/fpsensor/fpsensor_state.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/common/fpsensor/fpsensor_state.c b/common/fpsensor/fpsensor_state.c index 2b546191a3..9767ed71dc 100644 --- a/common/fpsensor/fpsensor_state.c +++ b/common/fpsensor/fpsensor_state.c @@ -139,27 +139,40 @@ static int validate_fp_mode(const uint32_t mode) return EC_SUCCESS; } -static int fp_command_mode(struct host_cmd_handler_args *args) +int fp_set_sensor_mode(uint32_t mode, uint32_t *mode_output) { - const struct ec_params_fp_mode *p = args->params; - struct ec_response_fp_mode *r = args->response; int ret; - ret = validate_fp_mode(p->mode); + if (mode_output == NULL) + return EC_RES_INVALID_PARAM; + + ret = validate_fp_mode(mode); if (ret != EC_SUCCESS) { - CPRINTS("Invalid FP mode 0x%x", p->mode); + CPRINTS("Invalid FP mode 0x%x", mode); return EC_RES_INVALID_PARAM; } - if (!(p->mode & FP_MODE_DONT_CHANGE)) { - sensor_mode = p->mode; + if (!(mode & FP_MODE_DONT_CHANGE)) { + sensor_mode = mode; task_set_event(TASK_ID_FPSENSOR, TASK_EVENT_UPDATE_CONFIG, 0); } - r->mode = sensor_mode; - args->response_size = sizeof(*r); + *mode_output = sensor_mode; return EC_RES_SUCCESS; } + +static int fp_command_mode(struct host_cmd_handler_args *args) +{ + const struct ec_params_fp_mode *p = args->params; + struct ec_response_fp_mode *r = args->response; + + int ret = fp_set_sensor_mode(p->mode, &r->mode); + + if (ret == EC_RES_SUCCESS) + args->response_size = sizeof(*r); + + return ret; +} DECLARE_HOST_COMMAND(EC_CMD_FP_MODE, fp_command_mode, EC_VER_MASK(0)); static int fp_command_context(struct host_cmd_handler_args *args) |