diff options
author | Ricardo Quesada <ricardoq@google.com> | 2022-02-15 13:40:15 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-17 20:07:21 +0000 |
commit | 940026601876cc7a959ed47c04bb53c879cf4448 (patch) | |
tree | 61a9a10339f3920004c0cb3713cbd405a0bbbdb1 | |
parent | 8bd671e0c4b481b0086824cfb643210bcee8dd25 (diff) | |
download | chrome-ec-940026601876cc7a959ed47c04bb53c879cf4448.tar.gz |
i2c: move PASSTRHU_RESTRICTED check to check_i2c_params
This CL moves the check about allowing PASSTHRU_RESTRICED checks from
i2c_command_passthru() to check_i2c_params().
The rationale, is that we already have a function to check whether the
params are valid and/or allowed.
This is similar to what this CL did: https://crrev.com/c/1588492
BRANCH=none
BUG=b:135642493
TEST=make buildall passes
Change-Id: I5902feae8f5b626e10053f279cb2fe2cdbba2585
Signed-off-by: Ricardo Quesada <ricardoq@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3466415
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Ricardo Quesada <ricardoq@chromium.org>
Auto-Submit: Ricardo Quesada <ricardoq@chromium.org>
Commit-Queue: Ricardo Quesada <ricardoq@chromium.org>
-rw-r--r-- | common/i2c_controller.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/common/i2c_controller.c b/common/i2c_controller.c index 65b904c0dc..a7368d85ed 100644 --- a/common/i2c_controller.c +++ b/common/i2c_controller.c @@ -1232,6 +1232,12 @@ static int check_i2c_params(const struct host_cmd_handler_args *args) read_len += msg->len; else write_len += msg->len; +#ifdef CONFIG_I2C_PASSTHRU_RESTRICTED + if (system_is_locked() && + !board_allow_i2c_passthru(params->port)) { + return EC_RES_ACCESS_DENIED; + } +#endif } /* Check there is room for the data */ @@ -1358,14 +1364,6 @@ static enum ec_status i2c_command_passthru(struct host_cmd_handler_args *args) PTHRUPRINTF("\n"); } if (rv) { -#ifdef CONFIG_I2C_PASSTHRU_RESTRICTED - if (system_is_locked() && - !board_allow_i2c_passthru(params->port)) { - if (port_is_locked) - i2c_lock(params->port, 0); - return EC_RES_ACCESS_DENIED; - } -#endif if (!port_is_locked) i2c_lock(params->port, (port_is_locked = 1)); rv = i2c_xfer_unlocked(params->port, |