Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: cros_ec_keyb - fix button/switch capability reports

The cros_ec_keyb_bs array lists buttons and switches together, expecting
that its users will match the appropriate type and bit fields. But
cros_ec_keyb_register_bs() only checks the 'bit' field, which causes
misreported input capabilities in some cases. For example, tablets
(e.g., Scarlet -- a.k.a. Acer Chromebook Tab 10) were reporting a SW_LID
capability, because EC_MKBP_POWER_BUTTON and EC_MKBP_LID_OPEN happen to
share the same bit.

(This has comedic effect on a tablet, in which a power-management daemon
then thinks this "lid" is closed, and so puts the system to sleep as
soon as it boots!)

To fix this, check both the 'ev_type' and 'bit' fields before reporting
the capability.

Tested with a lid (Kevin / Samsung Chromebook Plus) and without a lid
(Scarlet / Acer Chromebook Tab 10).

This error got introduced when porting the feature from the downstream
Chromium OS kernel to be upstreamed.

Fixes: cdd7950e7aa4 ("input: cros_ec_keyb: Add non-matrix buttons and switches")
Cc: <stable@vger.kernel.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Brian Norris and committed by
Dmitry Torokhov
ac5722c1 3ed64da3

+2 -1
+2 -1
drivers/input/keyboard/cros_ec_keyb.c
··· 493 493 for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) { 494 494 const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i]; 495 495 496 - if (buttons & BIT(map->bit)) 496 + if ((map->ev_type == EV_KEY && (buttons & BIT(map->bit))) || 497 + (map->ev_type == EV_SW && (switches & BIT(map->bit)))) 497 498 input_set_capability(idev, map->ev_type, map->code); 498 499 } 499 500