From c31a5d73bd2159845930c0f1bd0b9edbe2529624 Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Tue, 17 Aug 2021 17:12:08 +0800 Subject: usb_hid_keyboard: fix incorrect sleep/lock key position The position of SLEEP_KEY_MASK bit is not in its intended position because TK_* enum is 1-indexed. Fix this bug by shift the mask by 1. BUG=b:196934919 TEST=evtest BRANCH=trogdor Signed-off-by: Ting Shen Change-Id: I900636f032786510f7870948d1856d0bc4374800 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3097478 Reviewed-by: Rong Chang Commit-Queue: Ting Shen Tested-by: Ting Shen --- chip/stm32/usb_hid_keyboard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c index defe39e845..e2a8d675e9 100644 --- a/chip/stm32/usb_hid_keyboard.c +++ b/chip/stm32/usb_hid_keyboard.c @@ -515,7 +515,8 @@ static const struct action_key_config action_key[] = { [TK_MICMUTE] = { .mask = BIT(18), .usage = 0x000B002F }, }; -static const int SLEEP_KEY_MASK = BIT(ARRAY_SIZE(action_key)); +/* TK_* is 1-indexed, so the next bit is at ARRAY_SIZE(action_key) - 1 */ +static const int SLEEP_KEY_MASK = BIT(ARRAY_SIZE(action_key) - 1); #ifdef CONFIG_USB_HID_KEYBOARD_VIVALDI static uint32_t feature_report[CONFIG_USB_HID_KB_NUM_TOP_ROW_KEYS]; -- cgit v1.2.1