From patchwork Wed May 5 21:39:30 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: 12241169 X-Patchwork-Delegate: jikos@jikos.cz 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=-16.4 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=ham 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 E4242C43462 for ; Wed, 5 May 2021 21:40:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF0F0613F0 for ; Wed, 5 May 2021 21:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234919AbhEEVlB (ORCPT ); Wed, 5 May 2021 17:41:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23402 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234780AbhEEVkm (ORCPT ); Wed, 5 May 2021 17:40:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620250785; 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=Fot0NGl2ai1R4LucSAk0T+YoOHYuoLoy5rq36GvX/iQ=; b=MqU5wSXSu/C4y1jMb0jb7eGcwoJXNUFx6znLh/GK39rXi2ETMO+q3KZuj8D1lcOhBQitIO yz73fle2LsERK/gNcddYi9XbF5WGR3dRhlM1EN7+UUTd3NPaVDGVC9LyUrS7RkEsnsY0xf bHqNY3ZYxfgCPnRoGOHBBRzzGLl3fLA= 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-592-O8SGOd2GN4-hrlxiwcFHOg-1; Wed, 05 May 2021 17:39:43 -0400 X-MC-Unique: O8SGOd2GN4-hrlxiwcFHOg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36C34100A67A; Wed, 5 May 2021 21:39:42 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-71.ams2.redhat.com [10.36.112.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B15E5D6A8; Wed, 5 May 2021 21:39:41 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH v2 1/6] HID: core: Remove extraneous empty line before EXPORT_SYMBOL_GPL(hid_check_keys_pressed) Date: Wed, 5 May 2021 23:39:30 +0200 Message-Id: <20210505213935.631351-2-hdegoede@redhat.com> In-Reply-To: <20210505213935.631351-1-hdegoede@redhat.com> References: <20210505213935.631351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Normally the EXPORT_SYMBOL of a function immediately follows the declaration of the function and all the other functions in hid-core.c follow this pattern, drop the extraneous empty line before the EXPORT_SYMBOL_GPL(hid_check_keys_pressed); line. Signed-off-by: Hans de Goede --- drivers/hid/hid-core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 097cb1ee3126..b593dff411a6 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2588,7 +2588,6 @@ int hid_check_keys_pressed(struct hid_device *hid) return 0; } - EXPORT_SYMBOL_GPL(hid_check_keys_pressed); static int __init hid_init(void) From patchwork Wed May 5 21:39: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: 12241167 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=-16.4 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=ham 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 B27D8C43600 for ; Wed, 5 May 2021 21:40:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9533A613EC for ; Wed, 5 May 2021 21:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234382AbhEEVlE (ORCPT ); Wed, 5 May 2021 17:41:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49033 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234489AbhEEVkn (ORCPT ); Wed, 5 May 2021 17:40:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620250785; 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=Wh3ljzsbAAW6ZUqua+jJWjltR3pDhfVhRRc0B+jIdmk=; b=eNcCLswlFCsH20taEZ1SPnFCVJpaI7vglj4tPysqOoIqRs4zfinwe3ll/EvjG+S431cDli isazkgzfDMEnWxALY6DVZaZLlJW7n8DTtU1aJfLT3i5sbfir1418AK1oLVTyQa6r8UUQle xaRgU2gftkG41suUpd7zNWYUNinY8eU= 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-105-wBrXaZ5_Mdyap4b_Jvltsg-1; Wed, 05 May 2021 17:39:44 -0400 X-MC-Unique: wBrXaZ5_Mdyap4b_Jvltsg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 667D1835DE1; Wed, 5 May 2021 21:39:43 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-71.ams2.redhat.com [10.36.112.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B2575D6A8; Wed, 5 May 2021 21:39:42 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH v2 2/6] HID: core: Add a hid_is_usb_device() helper function Date: Wed, 5 May 2021 23:39:31 +0200 Message-Id: <20210505213935.631351-3-hdegoede@redhat.com> In-Reply-To: <20210505213935.631351-1-hdegoede@redhat.com> References: <20210505213935.631351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Sometimes HID drivers want to know if the hid_device with which they are dealing is using the usb_hid_driver. For example this is often done to check if it is safe to cast hid_device->dev.parent to an usb_interface like this: struct usb_interface *intf = to_usb_interface(hdev->dev.parent); If drivers directly call hid_is_using_ll_driver(hdev, &usb_hid_driver)) for this, then this leads to a "missing symbol usb_hid_driver" compilation error when CONFIG_USB_HID is not enabled. Requiring the driver to have a depends on USB_HID in their Kconfig entry to work around this. Add a hid_is_usb_device() helper function which drivers can use to safely check if they are dealing with a usb_hid device without needing to worry about the CONFIG_USB_HID setting. Signed-off-by: Hans de Goede --- drivers/hid/hid-core.c | 10 ++++++++++ include/linux/hid.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index b593dff411a6..294c3cf05d85 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -2590,6 +2590,16 @@ int hid_check_keys_pressed(struct hid_device *hid) } EXPORT_SYMBOL_GPL(hid_check_keys_pressed); +bool hid_is_usb_device(struct hid_device *hid) +{ +#if IS_ENABLED(CONFIG_USB_HID) + return hid_is_using_ll_driver(hid, &usb_hid_driver); +#else + return false; +#endif +} +EXPORT_SYMBOL_GPL(hid_is_usb_device); + static int __init hid_init(void) { int ret; diff --git a/include/linux/hid.h b/include/linux/hid.h index ef702b3f56e3..6ceadc234132 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -901,6 +901,7 @@ struct hid_report *hid_validate_values(struct hid_device *hid, void hid_setup_resolution_multiplier(struct hid_device *hid); int hid_open_report(struct hid_device *device); int hid_check_keys_pressed(struct hid_device *hid); +bool hid_is_usb_device(struct hid_device *hid); int hid_connect(struct hid_device *hid, unsigned int connect_mask); void hid_disconnect(struct hid_device *hid); bool hid_match_one_id(const struct hid_device *hdev, From patchwork Wed May 5 21:39:32 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: 12241171 X-Patchwork-Delegate: jikos@jikos.cz 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=-16.4 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=ham 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 7C6D8C43461 for ; Wed, 5 May 2021 21:40:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6588C613EA for ; Wed, 5 May 2021 21:40:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234511AbhEEVlF (ORCPT ); Wed, 5 May 2021 17:41:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41607 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234828AbhEEVko (ORCPT ); Wed, 5 May 2021 17:40:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620250786; 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=PPX0O4STRSFoNhKftLhat1v0JRKfbgj4o8mwnxUmJ1g=; b=IxiChxf7CiMLoqfw/kmVxsaXhSRsaJullaGEXiuLhpmWkbc5sb+JWE1pqs5eeGitg1gFmn pY/gAnCIQ8yna6XSi8YK7cjxn+NHI9r7aL39DS5GWUIhUkvIo+a4q12mvQbFP7R6YtCvSw rPVSUBZpqkM9xJpMacOD0EAgV6IohRs= 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-422-b_H48ho-PzuwPBKOnHc4TA-1; Wed, 05 May 2021 17:39:45 -0400 X-MC-Unique: b_H48ho-PzuwPBKOnHc4TA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9699A1800D41; Wed, 5 May 2021 21:39:44 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-71.ams2.redhat.com [10.36.112.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC1195D6A8; Wed, 5 May 2021 21:39:43 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH v2 3/6] HID: multitouch: Disable event reporting on suspend on the Asus T101HA touchpad Date: Wed, 5 May 2021 23:39:32 +0200 Message-Id: <20210505213935.631351-4-hdegoede@redhat.com> In-Reply-To: <20210505213935.631351-1-hdegoede@redhat.com> References: <20210505213935.631351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The Asus T101HA has a problem with spurious wakeups when the lid is closed, this is caused by the screen sitting so close to the touchpad that the touchpad ends up reporting touch events, causing these wakeups. Add a quirk which disables event reporting on suspend when set, and enable this quirk for the Asus T101HA touchpad fixing the spurious wakeups, while still allowing the device to be woken by pressing a key on the keyboard (which is part of the same USB device). Signed-off-by: Hans de Goede --- drivers/hid/hid-multitouch.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 9d9f3e1bd5f4..cfb68e443ddd 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -70,6 +70,7 @@ MODULE_LICENSE("GPL"); #define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18) #define MT_QUIRK_SEPARATE_APP_REPORT BIT(19) #define MT_QUIRK_FORCE_MULTI_INPUT BIT(20) +#define MT_QUIRK_DISABLE_WAKEUP BIT(21) #define MT_INPUTMODE_TOUCHSCREEN 0x02 #define MT_INPUTMODE_TOUCHPAD 0x03 @@ -191,6 +192,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app); #define MT_CLS_EXPORT_ALL_INPUTS 0x0013 /* reserved 0x0014 */ #define MT_CLS_WIN_8_FORCE_MULTI_INPUT 0x0015 +#define MT_CLS_WIN_8_DISABLE_WAKEUP 0x0016 /* vendor specific classes */ #define MT_CLS_3M 0x0101 @@ -283,6 +285,15 @@ static const struct mt_class mt_classes[] = { MT_QUIRK_WIN8_PTP_BUTTONS | MT_QUIRK_FORCE_MULTI_INPUT, .export_all_inputs = true }, + { .name = MT_CLS_WIN_8_DISABLE_WAKEUP, + .quirks = MT_QUIRK_ALWAYS_VALID | + MT_QUIRK_IGNORE_DUPLICATES | + MT_QUIRK_HOVERING | + MT_QUIRK_CONTACT_CNT_ACCURATE | + MT_QUIRK_STICKY_FINGERS | + MT_QUIRK_WIN8_PTP_BUTTONS | + MT_QUIRK_DISABLE_WAKEUP, + .export_all_inputs = true }, /* * vendor specific classes @@ -759,7 +770,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, return 1; case HID_DG_CONFIDENCE: if ((cls->name == MT_CLS_WIN_8 || - cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT) && + cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT || + cls->name == MT_CLS_WIN_8_DISABLE_WAKEUP) && (field->application == HID_DG_TOUCHPAD || field->application == HID_DG_TOUCHSCREEN)) app->quirks |= MT_QUIRK_CONFIDENCE; @@ -1749,8 +1761,14 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) #ifdef CONFIG_PM static int mt_suspend(struct hid_device *hdev, pm_message_t state) { + struct mt_device *td = hid_get_drvdata(hdev); + /* High latency is desirable for power savings during S3/S0ix */ - mt_set_modes(hdev, HID_LATENCY_HIGH, true, true); + if (td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) + mt_set_modes(hdev, HID_LATENCY_HIGH, false, false); + else + mt_set_modes(hdev, HID_LATENCY_HIGH, true, true); + return 0; } @@ -1809,6 +1827,12 @@ static const struct hid_device_id mt_devices[] = { MT_USB_DEVICE(USB_VENDOR_ID_ANTON, USB_DEVICE_ID_ANTON_TOUCH_PAD) }, + /* Asus T101HA */ + { .driver_data = MT_CLS_WIN_8_DISABLE_WAKEUP, + HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, + USB_VENDOR_ID_ASUSTEK, + USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD) }, + /* Asus T304UA */ { .driver_data = MT_CLS_ASUS, HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, From patchwork Wed May 5 21:39:33 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: 12241173 X-Patchwork-Delegate: jikos@jikos.cz 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=-16.4 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=ham 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 91CA5C43460 for ; Wed, 5 May 2021 21:40:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 786B7613D6 for ; Wed, 5 May 2021 21:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234961AbhEEVlI (ORCPT ); Wed, 5 May 2021 17:41:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25728 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233492AbhEEVkp (ORCPT ); Wed, 5 May 2021 17:40:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620250788; 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=NEdvRvx4IJ+xRqGwkaz89HqKIJ2w+9EsUd+uP2+Gk28=; b=Jas35SyRQZCRbrybNrtZZrEBVW2+M6dQFsujF9TjpzUybA+Xb1yOc8NOWnpF6hdQhiDxLx KyNm5arWS07Dj15C3dWvYLk3xMrAY2W6Zt1D1dXYy5lZEfGjNmhWSwVt+363R83if1iOpE zYImYNKCyIMiVkPQV412psGMEKnKw+s= 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-591-_8u4x6W3PTaJPDZarOF5rw-1; Wed, 05 May 2021 17:39:46 -0400 X-MC-Unique: _8u4x6W3PTaJPDZarOF5rw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6FBC801B14; Wed, 5 May 2021 21:39:45 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-71.ams2.redhat.com [10.36.112.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC5565D6A8; Wed, 5 May 2021 21:39:44 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH v2 4/6] HID: multitouch: Disable event reporting on suspend when our parent is not a wakeup-source Date: Wed, 5 May 2021 23:39:33 +0200 Message-Id: <20210505213935.631351-5-hdegoede@redhat.com> In-Reply-To: <20210505213935.631351-1-hdegoede@redhat.com> References: <20210505213935.631351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Disable event reporting on suspend when our parent is not a wakeup-source. This should help save some extra power in this case. Signed-off-by: Hans de Goede --- Changes in v2: - Use new hid_is_usb_device() helper --- drivers/hid/hid-multitouch.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index cfb68e443ddd..24b4a54f7224 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -1759,12 +1759,33 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) } #ifdef CONFIG_PM + +/* Check if the parent which has the power/wakeup* sysfs attributes may wake the hdev */ +static bool mt_parent_may_wake(struct hid_device *hdev) +{ + struct device *parent = hdev->dev.parent; + + /* + * USB-HID is attached to the usb_interface (our parent), the + * power/wakeup* attr are part of the usb-device which is its parent. + */ + if (hid_is_usb_device(hdev) && parent) + parent = parent->parent; + + if (parent) + return device_may_wakeup(parent); + + /* Huh? Play it safe and keep reporting events. */ + return true; +} + static int mt_suspend(struct hid_device *hdev, pm_message_t state) { struct mt_device *td = hid_get_drvdata(hdev); /* High latency is desirable for power savings during S3/S0ix */ - if (td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) + if ((td->mtclass.quirks & MT_QUIRK_DISABLE_WAKEUP) || + !mt_parent_may_wake(hdev)) mt_set_modes(hdev, HID_LATENCY_HIGH, false, false); else mt_set_modes(hdev, HID_LATENCY_HIGH, true, true); From patchwork Wed May 5 21:39:34 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: 12241175 X-Patchwork-Delegate: jikos@jikos.cz 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=-16.4 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=ham 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 3310FC43461 for ; Wed, 5 May 2021 21:40:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12B67613EB for ; Wed, 5 May 2021 21:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbhEEVlI (ORCPT ); Wed, 5 May 2021 17:41:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52360 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233772AbhEEVks (ORCPT ); Wed, 5 May 2021 17:40:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620250790; 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=gUT60/I2futOhxJeimb6HwtYWVrW8DM8lY+djOvKMuU=; b=OibfSAJZQqf7083Mk07kSi/CCboDgquj4pJ3QUeFxabCGz5x+mVboloV3/sNkBNy2LxvrF MqTQNmVhr7Z25X7xaUpTDnYOhIKaPjgDaZTZ37zA6UHBkWMXxoO2xdkKznP0PWIzGJYkRY J7607Cmod++oEWs/LX2tEqoxoPtBF4E= 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-377-YiyaoQEJP9qPLb7GuH-_EA-1; Wed, 05 May 2021 17:39:48 -0400 X-MC-Unique: YiyaoQEJP9qPLb7GuH-_EA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DCDB107ACCA; Wed, 5 May 2021 21:39:47 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-71.ams2.redhat.com [10.36.112.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 415F85D6A8; Wed, 5 May 2021 21:39:45 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH v2 5/6] HID: asus: Cleanup Asus T101HA keyboard-dock handling Date: Wed, 5 May 2021 23:39:34 +0200 Message-Id: <20210505213935.631351-6-hdegoede@redhat.com> In-Reply-To: <20210505213935.631351-1-hdegoede@redhat.com> References: <20210505213935.631351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org There is no need to use a quirk and then return -ENODEV from the asus_probe() function to avoid that hid-asus binds to the hiddev for the USB-interface for the hid-multitouch touchpad. The hid-multitouch hiddev has a group of HID_GROUP_MULTITOUCH_WIN_8, so the same result can be achieved by making the hid_device_id entry for the dock in the asus_devices[] table only match on HID_GROUP_GENERIC instead of having it match HID_GROUP_ANY. Signed-off-by: Hans de Goede --- drivers/hid/hid-asus.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 2ab22b925941..6e24f48f211c 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -79,10 +79,9 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); #define QUIRK_T100_KEYBOARD BIT(6) #define QUIRK_T100CHI BIT(7) #define QUIRK_G752_KEYBOARD BIT(8) -#define QUIRK_T101HA_DOCK BIT(9) -#define QUIRK_T90CHI BIT(10) -#define QUIRK_MEDION_E1239T BIT(11) -#define QUIRK_ROG_NKEY_KEYBOARD BIT(12) +#define QUIRK_T90CHI BIT(9) +#define QUIRK_MEDION_E1239T BIT(10) +#define QUIRK_ROG_NKEY_KEYBOARD BIT(11) #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ QUIRK_NO_INIT_REPORTS | \ @@ -1072,11 +1071,6 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) return ret; } - /* use hid-multitouch for T101HA touchpad */ - if (id->driver_data & QUIRK_T101HA_DOCK && - hdev->collection->usage == HID_GD_MOUSE) - return -ENODEV; - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); if (ret) { hid_err(hdev, "Asus hw start failed: %d\n", ret); @@ -1230,8 +1224,6 @@ static const struct hid_device_id asus_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100TAF_KEYBOARD), QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES }, - { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, - USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD), QUIRK_T101HA_DOCK }, { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_ASUS_AK1D) }, { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) }, { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) }, @@ -1239,6 +1231,12 @@ static const struct hid_device_id asus_devices[] = { USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD), QUIRK_T100CHI }, { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE_MEDION_E1239T), QUIRK_MEDION_E1239T }, + /* + * Note bind to the HID_GROUP_GENERIC group, so that we only bind to the keyboard + * part, while letting hid-multitouch.c handle the touchpad. + */ + { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, + USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T101HA_KEYBOARD) }, { } }; MODULE_DEVICE_TABLE(hid, asus_devices); From patchwork Wed May 5 21:39:35 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: 12241177 X-Patchwork-Delegate: jikos@jikos.cz 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=-16.4 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=ham 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 A8079C43462 for ; Wed, 5 May 2021 21:40:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8809E613D6 for ; Wed, 5 May 2021 21:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233772AbhEEVlJ (ORCPT ); Wed, 5 May 2021 17:41:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52706 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233722AbhEEVkt (ORCPT ); Wed, 5 May 2021 17:40:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620250792; 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=KJpnGKsjgIiuxbsc1ISPgJdjzVr1zEzqG2Jggbdhcdk=; b=WqMI8kWXuOmoVJt0MBkGsYm1Cu6txENThjgLXmFbv6zZAxjwbnylpchL8oOqdbUWmj4ePw sbXEZNQIXdMDpOPYxzAHKKJv/CI6iPPu6uUfgRQbbDWLDLYmEZ93qycDb8sSzphAKam0YS l3b65xCgltkBNXyVV6J58DSn2hgcpEM= 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-188-ik9t_UfVPuqfoEzwmswfhA-1; Wed, 05 May 2021 17:39:49 -0400 X-MC-Unique: ik9t_UfVPuqfoEzwmswfhA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60AD4801B13; Wed, 5 May 2021 21:39:48 +0000 (UTC) Received: from x1.localdomain.com (ovpn-112-71.ams2.redhat.com [10.36.112.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 741C75D6A8; Wed, 5 May 2021 21:39:47 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires Cc: Hans de Goede , linux-input@vger.kernel.org Subject: [PATCH v2 6/6] HID: asus: Switch to the new hid_is_usb_device() helper Date: Wed, 5 May 2021 23:39:35 +0200 Message-Id: <20210505213935.631351-7-hdegoede@redhat.com> In-Reply-To: <20210505213935.631351-1-hdegoede@redhat.com> References: <20210505213935.631351-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Switch to the new hid_is_usb_device() helper. With this new helper building without USB_HID being enabled should work, so also change the Kconfig depends on from USB_HID to plain HID. Signed-off-by: Hans de Goede --- drivers/hid/Kconfig | 2 +- drivers/hid/hid-asus.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 786b71ef7738..6b244e67c272 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -149,7 +149,7 @@ config HID_APPLEIR config HID_ASUS tristate "Asus" - depends on USB_HID + depends on HID depends on LEDS_CLASS depends on ASUS_WMI || ASUS_WMI=n select POWER_SUPPLY diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 6e24f48f211c..41bc34aaaf09 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -1009,8 +1009,7 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) if (drvdata->quirks & QUIRK_IS_MULTITOUCH) drvdata->tp = &asus_i2c_tp; - if ((drvdata->quirks & QUIRK_T100_KEYBOARD) && - hid_is_using_ll_driver(hdev, &usb_hid_driver)) { + if ((drvdata->quirks & QUIRK_T100_KEYBOARD) && hid_is_usb_device(hdev)) { struct usb_interface *intf = to_usb_interface(hdev->dev.parent); if (intf->altsetting->desc.bInterfaceNumber == T100_TPAD_INTF) { @@ -1038,8 +1037,7 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) drvdata->tp = &asus_t100chi_tp; } - if ((drvdata->quirks & QUIRK_MEDION_E1239T) && - hid_is_using_ll_driver(hdev, &usb_hid_driver)) { + if ((drvdata->quirks & QUIRK_MEDION_E1239T) && hid_is_usb_device(hdev)) { struct usb_host_interface *alt = to_usb_interface(hdev->dev.parent)->altsetting;