From patchwork Sun Apr 4 08:04:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 415480 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D2C7C43462 for ; Sun, 4 Apr 2021 08:04:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B65761364 for ; Sun, 4 Apr 2021 08:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230089AbhDDIFC (ORCPT ); Sun, 4 Apr 2021 04:05:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47225 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbhDDIFC (ORCPT ); Sun, 4 Apr 2021 04:05:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617523498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LZjgIxstBnqsDrasc5dTocmBOdU7YscxMH6lQXTtRvk=; b=MEQibCUHCYAU7Z7pYu8sWkSF1+46QARB8sw1r5UG/3UvRJAXv9YpaYLsj31ZWIxqQ1MjHD 66eE0dt9MRx3jw9lLmOCGc8wmm4pzZeR+0b5JPZF7C9bA1g93dNcczAn0GnemiwcY/XiXn JhCXgfhy/6b08KvrXtQ8HICf5EvlwoQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-SuSzTLswMFOXt4RYYwuKeg-1; Sun, 04 Apr 2021 04:04:54 -0400 X-MC-Unique: SuSzTLswMFOXt4RYYwuKeg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4740550206; Sun, 4 Apr 2021 08:04:53 +0000 (UTC) Received: from x1.localdomain (ovpn-112-48.ams2.redhat.com [10.36.112.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9BE6100E113; Sun, 4 Apr 2021 08:04:51 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires , Alexander Kobel Cc: Hans de Goede , Pavel Machek , =?utf-8?q?Marek_Beh=C3=BAn?= , linux-input@vger.kernel.org, linux-leds@vger.kernel.org Subject: [PATCH v2 resend 8/9] HID: lenovo: Rework how the tp10ubkbd code decides which USB interface to use Date: Sun, 4 Apr 2021 10:04:31 +0200 Message-Id: <20210404080432.4322-9-hdegoede@redhat.com> In-Reply-To: <20210404080432.4322-1-hdegoede@redhat.com> References: <20210404080432.4322-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org 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 --- drivers/hid/hid-lenovo.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c index 2287142116b9..a33de5022ec3 100644 --- a/drivers/hid/hid-lenovo.c +++ b/drivers/hid/hid-lenovo.c @@ -959,11 +959,24 @@ static const struct attribute_group lenovo_attr_group_tp10ubkbd = { static int lenovo_probe_tp10ubkbd(struct hid_device *hdev) { + struct hid_report_enum *rep_enum; struct lenovo_drvdata *data; + struct hid_report *rep; + bool found; int ret; - /* All the custom action happens on the USBMOUSE device for USB */ - if (hdev->type != HID_TYPE_USBMOUSE) + /* + * The LEDs and the Fn-lock functionality use output report 9, + * with an application of 0xffa0001, add the LEDs on the interface + * with this output report. + */ + found = false; + rep_enum = &hdev->report_enum[HID_OUTPUT_REPORT]; + list_for_each_entry(rep, &rep_enum->report_list, list) { + if (rep->application == 0xffa00001) + found = true; + } + if (!found) return 0; data = devm_kzalloc(&hdev->dev, sizeof(*data), GFP_KERNEL);