From patchwork Tue Feb 7 21:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 54084 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3083646wrn; Tue, 7 Feb 2023 13:21:27 -0800 (PST) X-Google-Smtp-Source: AK7set8a7FqcrBRo5G7RwjfA+CNIh4yCPoiASFRFE7cLKKCL1qHC5EqXwzuiTAiwHHtZcBMoZTL9 X-Received: by 2002:a50:99dd:0:b0:4aa:9722:1c01 with SMTP id n29-20020a5099dd000000b004aa97221c01mr5056755edb.10.1675804887556; Tue, 07 Feb 2023 13:21:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675804887; cv=none; d=google.com; s=arc-20160816; b=KJAlMVbIC/sQr2Nt0K6wcU+8zUU6eSqsKHKCSYWWzzSpeytno4DW1b5BkGVW5e1koY Mnn21yANuNW+l5xFAh4t6XwQJqL1VzGa6xoN5w/plIq9yJ8uegD/dwZs9V+yjA9lFRAw Me23luQYlfodQZa9ZOijPjkffbDJPFINbHZI+IgpgTFgnCImCwuhbR9ugG/yxC33Acpb 7nSZX8g5LDJS8kmoBxN2GvgZ7a8tRCvByyVzttoPUvkj/d4ocGwjnLXY5Mc1sh7cnfm5 Q5yO/e7GvFyjcLb6u1F2BW/WFr2aIhnwHq7E/XtxqfuaLbfEgYVdtVAEq6GolweMj6QS Y+VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=TAcU8WxhB+WVoNrLiEKubw7Fb6wa6bNM3w1NxWFiTsM=; b=Dg3m0BsUE35yQ2ZAvaRhf1zGHXRm3kyJCu4e3vLPg3+W2tAsImPtkSzXcBpilFW/VD BvcGG/0FqqbNRbqvyR77NWmdHFkMMFHer4wH2FuwXyD8Ra83mP4DY4meLtczlzmusCeK 6JoD3Blpbpo5QRO7BjpE260LUbYedw6aJbKL4c9LDMz9iDFRc6d2kDW/VQfWUiZPA5Xh yMcShfM5J1Bs8Ut6ZQEhqhy166UQ5QXznFbwc5LyPF2bvKdgOwEQHn/1Zf79IGzOsEfs B5EuN/i/K9GY3IsEdZ266P27grzawLI1s7dAtHOtzWrM3yP9uDQey14Y+FFy3Lmu/ZrB OZbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="AjUdYU/m"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a056402430300b004a22ce03f86si22035735edc.134.2023.02.07.13.21.04; Tue, 07 Feb 2023 13:21:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="AjUdYU/m"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbjBGVQC (ORCPT + 99 others); Tue, 7 Feb 2023 16:16:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjBGVQB (ORCPT ); Tue, 7 Feb 2023 16:16:01 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35E6C37555; Tue, 7 Feb 2023 13:16:00 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id j1so10457962pjd.0; Tue, 07 Feb 2023 13:16:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=TAcU8WxhB+WVoNrLiEKubw7Fb6wa6bNM3w1NxWFiTsM=; b=AjUdYU/mpefYpxPczmxS+Nyv9tTQPLG964qAkyvowIFxkA7I2gX3DaFVS8SAhRk7f/ rt5KoYbcpn4e1yXwaGWU2MkaEtVUQ0PgU82jYFNN+ab05lmG7bi19MS5J6Ppf2m0Qu/y XohIOZrSBhd2bPmL7oeS1LWDxqp6YaOr/f9E7/OOOl4dg3O6NlYbQNp7NKQHtrzSG47Y 0xEyhhGWN1dGUOEm6illHzA+JUNtGLjvpSkeDUzlvoiBjUW6yomCuv3W9KdP65xZlzfH Frdw7xuMdcDHMxgifCsAvb3KVdxD567aHGGkNZbghgc6MOV0+/Hwo1AJJjZ4sPChvpnd iETw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TAcU8WxhB+WVoNrLiEKubw7Fb6wa6bNM3w1NxWFiTsM=; b=iIOHs8waqsDPRNCFshMend2x8ZSozH5UW1DvOZ2tK+Qbrmu3COGzCUR1ha/XyzL9zE tw2k8ai7PRPGD5xTeii0iwvzdO3POnJJG/FmTEhSI9UnfmpmMeAnljkkMeDWRDhAcEM/ 63y3V79k6SLpDDWv1FZYtk/CVY7OJuN/SFGmqUHn+LJeeVjplLB/Ld30AXyi8ils6LCi d5lPVDwrC341xLPymEU/bgW3zgMV867ZT7kTTvuu8PQz92MqWQ/N5ySa/nlkbnOXfi1T 2euZYGnG3oJVpuPhJ5zuMcnHAOw6QAfdgmkZFf1CT26TRj91+lqT4gUNAdTIevt17L+e qCyg== X-Gm-Message-State: AO0yUKVeLvyqzEiRiVWTGM9zAc2GkjWQ8raGkCVSELG/5iT4Epew/Sna QgrKDk6JcW+unMuxDpizYx0= X-Received: by 2002:a17:90b:3b8a:b0:230:86d2:5832 with SMTP id pc10-20020a17090b3b8a00b0023086d25832mr5613362pjb.2.1675804559452; Tue, 07 Feb 2023 13:15:59 -0800 (PST) Received: from google.com ([2620:15c:9d:2:c930:81ab:3aec:b9cb]) by smtp.gmail.com with ESMTPSA id w10-20020a17090a5e0a00b002262dd8a39bsm11779971pjf.49.2023.02.07.13.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 13:15:58 -0800 (PST) Date: Tue, 7 Feb 2023 13:15:55 -0800 From: Dmitry Torokhov To: Jiri Kosina , Benjamin Tissoires Cc: Allen Ballway , Hans de Goede , Alistair Francis , Guenter Roeck , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: retain initial quirks set up when creating HID devices Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757208785415256307?= X-GMAIL-MSGID: =?utf-8?q?1757208785415256307?= In certain circumstances, such as when creating I2C-connected HID devices, we want to pass and retain some querks (axis inversion, etc). The source of such quirks may be device tree, or DMI data, or something else not readily available to the HID core itself and therefore cannot be reconstructed easily. To allow this introduce "initial_quirks" field in hid_device structure and use it when determining the final set of quirks. This fixes problem with i2c-hid setting up device-tree sourced quirks too late and losing them on device rebind, and also allows to sever the tie between hid-code and i2c-hid when applying DMI-based quirks. Fixes: b60d3c803d76 ("HID: i2c-hid-of: Expose the touchscreen-inverted properties") Fixes: a2f416bf062a ("HID: multitouch: Add quirks for flipped axes") Signed-off-by: Dmitry Torokhov Reviewed-by: Guenter Roeck --- Compiled only, not tested on hardware. drivers/hid/hid-quirks.c | 8 +------- drivers/hid/i2c-hid/i2c-hid-core.c | 6 ++++-- drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c | 1 - include/linux/hid.h | 1 + 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 30e35f79def4..66e64350f138 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -19,7 +19,6 @@ #include #include "hid-ids.h" -#include "i2c-hid/i2c-hid.h" /* * Alphabetically sorted by vendor then product. @@ -1238,7 +1237,7 @@ EXPORT_SYMBOL_GPL(hid_quirks_exit); static unsigned long hid_gets_squirk(const struct hid_device *hdev) { const struct hid_device_id *bl_entry; - unsigned long quirks = 0; + unsigned long quirks = hdev->initial_quirks; if (hid_match_id(hdev, hid_ignore_list)) quirks |= HID_QUIRK_IGNORE; @@ -1299,11 +1298,6 @@ unsigned long hid_lookup_quirk(const struct hid_device *hdev) quirks = hid_gets_squirk(hdev); mutex_unlock(&dquirks_lock); - /* Get quirks specific to I2C devices */ - if (IS_ENABLED(CONFIG_I2C_DMI_CORE) && IS_ENABLED(CONFIG_DMI) && - hdev->bus == BUS_I2C) - quirks |= i2c_hid_get_dmi_quirks(hdev->vendor, hdev->product); - return quirks; } EXPORT_SYMBOL_GPL(hid_lookup_quirk); diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index 0ab8f47a84e9..efbba0465eef 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -1025,6 +1025,10 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); hid->product = le16_to_cpu(ihid->hdesc.wProductID); + hid->initial_quirks = quirks; + hid->initial_quirks |= i2c_hid_get_dmi_quirks(hid->vendor, + hid->product); + snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", client->name, (u16)hid->vendor, (u16)hid->product); strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); @@ -1038,8 +1042,6 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, goto err_mem_free; } - hid->quirks |= quirks; - return 0; err_mem_free: diff --git a/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c b/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c index 554a7dc28536..210f17c3a0be 100644 --- a/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c +++ b/drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c @@ -492,4 +492,3 @@ u32 i2c_hid_get_dmi_quirks(const u16 vendor, const u16 product) return quirks; } -EXPORT_SYMBOL_GPL(i2c_hid_get_dmi_quirks); diff --git a/include/linux/hid.h b/include/linux/hid.h index daaac4d7f370..56dac09c99d9 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -622,6 +622,7 @@ struct hid_device { /* device report descriptor */ unsigned long status; /* see STAT flags above */ unsigned claimed; /* Claimed by hidinput, hiddev? */ unsigned quirks; /* Various quirks the device can pull on us */ + unsigned initial_quirks; /* Initial set of quirks supplied when creating device */ bool io_started; /* If IO has started */ struct list_head inputs; /* The list of inputs */