Skip to content

Commit 2d0f1c0

Browse files
jwrdegoedeJiri Kosina
authored andcommitted
HID: lenovo: Rework how the tp10ubkbd code decides which USB interface to use
Instead of looking for a hdev with a type of HID_TYPE_USBMOUSE find the interface for the mute/mic-mute/fn-lock LEDs by checking for the output-report which is used to set them. This is a preparation patch for adding support for the LEDs on the X1 tablet thin keyboard which uses the same output-report, but has a separate (third) USB interface for the touchpad/mouse functionality. Signed-off-by: Hans de Goede <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent e2da5ff commit 2d0f1c0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/hid/hid-lenovo.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,11 +959,24 @@ static const struct attribute_group lenovo_attr_group_tp10ubkbd = {
959959

960960
static int lenovo_probe_tp10ubkbd(struct hid_device *hdev)
961961
{
962+
struct hid_report_enum *rep_enum;
962963
struct lenovo_drvdata *data;
964+
struct hid_report *rep;
965+
bool found;
963966
int ret;
964967

965-
/* All the custom action happens on the USBMOUSE device for USB */
966-
if (hdev->type != HID_TYPE_USBMOUSE)
968+
/*
969+
* The LEDs and the Fn-lock functionality use output report 9,
970+
* with an application of 0xffa0001, add the LEDs on the interface
971+
* with this output report.
972+
*/
973+
found = false;
974+
rep_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
975+
list_for_each_entry(rep, &rep_enum->report_list, list) {
976+
if (rep->application == 0xffa00001)
977+
found = true;
978+
}
979+
if (!found)
967980
return 0;
968981

969982
data = devm_kzalloc(&hdev->dev, sizeof(*data), GFP_KERNEL);

0 commit comments

Comments
 (0)