diff options
author | Andrew McRae <amcrae@google.com> | 2022-12-30 13:47:50 +1100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-01-04 05:11:52 +0000 |
commit | fd6fea7c20991b875875239ea0a86200ac7b267a (patch) | |
tree | fc9c932ff4012a395cf18f948c2feb2aa6fcc76b | |
parent | 436af95674cd6722a84799beaa6434d69bb68c84 (diff) | |
download | chrome-ec-fd6fea7c20991b875875239ea0a86200ac7b267a.tar.gz |
usb_mux: Only send virtual mux state if changed
Only send the virtual mux status to the host if the mux status
has changed, and is not zero.
This avoids any false events waking up the host if
there are changes on the port.
BUG=b:262338992
TEST=Verify on nirwen that AP suspends after hub is unplugged.
BRANCH=none
Change-Id: I15ba40fe978c2f8773b179962de95904bee6b620
Signed-off-by: Andrew McRae <amcrae@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4128262
Reviewed-by: Sam McNally <sammc@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r-- | driver/usb_mux/virtual.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/driver/usb_mux/virtual.c b/driver/usb_mux/virtual.c index dc6f4c3334..43e4b0042f 100644 --- a/driver/usb_mux/virtual.c +++ b/driver/usb_mux/virtual.c @@ -31,14 +31,21 @@ static inline void virtual_mux_update_state(int port, mux_state_t mux_state, { mux_state_t previous_mux_state = virtual_mux_state[port]; - virtual_mux_state[port] = mux_state; - /* * Initialize ack_required to false to start, and set on necessary * conditions */ *ack_required = false; + /* + * If there is no state change, and the mux status is + * clear, do not send a host event. + */ + if (mux_state == 0 && previous_mux_state == 0) + return; + + virtual_mux_state[port] = mux_state; + if (!IS_ENABLED(CONFIG_HOSTCMD_EVENTS)) return; |