Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp397218pxj; Thu, 20 May 2021 11:51:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCxYDsPPxXMRvU6k/kCrsSmqZ69AnnKqh54RcXPUCOq93L0f3d5ht5592LfE+rgVVgmM0B X-Received: by 2002:a92:b07:: with SMTP id b7mr6118812ilf.268.1621536715877; Thu, 20 May 2021 11:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621536715; cv=none; d=google.com; s=arc-20160816; b=JGCkz/lWymiGxqmkyPN06biofMOjE78KqMWgdt6Xb8wBxxpEvldMRpj8iTTBaN2bVr 3Fr5azDXWsP9IlcxWJlxdxDtb1YfKPTO1vYvA9p5utpwyrOhUw9x2REnNKOOhtkzHFv5 qPlopuJJejw2DmDqOBiEkHvyzD0vI7x4oBoQ2PUOiLCMtXcl72te7VQ1rCqwNDHldipH aDZ8U21805/T7UIA0uAx6YOJpf1r0ZI+041xy77bfJl86X7go3HMz+j54FK8zJCFiWVA XbfCy3X1CnF/x2CswFcciUNLnTfCmrDsBSGJxfYHZr77yCV9fPeGxC4OnYnXX/JQfJ/F VkKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N9azrrFtcX08Nl9RO717V1TCUG3LiRXczDWPxYwdGZk=; b=zPAPueDbRsynVKIrlB1czg0VyyxdXb0+QXLxonoYPx/PXcJvud6uW93akYOllk7jTd 7dnyxh9Y+04X0Lwel+br/uOV2KBTkqH8Ib29iBza4E/Wf9rkzQqYExPz2JeyMeMt79h0 PC0Kh3i1cflG4QQcjic2zwNlKd1rdLjqDk1EvZnwyFco6YHe5rBNDWLdu/02M/5zTEkH CGlF+uN2ZeXBv+yFwN+voQhpAZ4xbXPrfes6CxFvG1Vd3Y/GUtwmxu0lGpyOGp4ZReGu SznhvEUWrb0y3nmo7FaZRNlw3xFAqz6YDypLIBpDGkbq+ByjwXKRs9lJpELEI4eIKu2v hYog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=16je6CFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y5si3862228ily.21.2021.05.20.11.51.43; Thu, 20 May 2021 11:51:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=16je6CFn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235915AbhETKZh (ORCPT + 99 others); Thu, 20 May 2021 06:25:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:48106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236234AbhETKOr (ORCPT ); Thu, 20 May 2021 06:14:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0CB436197C; Thu, 20 May 2021 09:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503896; bh=lK8V9T+YuM+HsVSC7+YpskaDIG8urlQUQd+fRB5YOyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=16je6CFnsA7GwPXu1acKRAqbdmT3bYIceTImY55j7IGAaJdhdL84dONtzadQ7pOzz tqH3eKv05MapBF1DTLRyCnPR1BHfArg8KWxIpCax7UlhJIj+bN4i4bpVMfBNdP1V9m epd40+I5xt6aerdh03+cSRvN+DcyniCHsIDXpPl0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Tissoires , Hans de Goede , Dmitry Torokhov , Sasha Levin Subject: [PATCH 4.19 405/425] Input: elants_i2c - do not bind to i2c-hid compatible ACPI instantiated devices Date: Thu, 20 May 2021 11:22:54 +0200 Message-Id: <20210520092144.700209931@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit 65299e8bfb24774e6340e93ae49f6626598917c8 ] Several users have been reporting that elants_i2c gives several errors during probe and that their touchscreen does not work on their Lenovo AMD based laptops with a touchscreen with a ELAN0001 ACPI hardware-id: [ 0.550596] elants_i2c i2c-ELAN0001:00: i2c-ELAN0001:00 supply vcc33 not found, using dummy regulator [ 0.551836] elants_i2c i2c-ELAN0001:00: i2c-ELAN0001:00 supply vccio not found, using dummy regulator [ 0.560932] elants_i2c i2c-ELAN0001:00: elants_i2c_send failed (77 77 77 77): -121 [ 0.562427] elants_i2c i2c-ELAN0001:00: software reset failed: -121 [ 0.595925] elants_i2c i2c-ELAN0001:00: elants_i2c_send failed (77 77 77 77): -121 [ 0.597974] elants_i2c i2c-ELAN0001:00: software reset failed: -121 [ 0.621893] elants_i2c i2c-ELAN0001:00: elants_i2c_send failed (77 77 77 77): -121 [ 0.622504] elants_i2c i2c-ELAN0001:00: software reset failed: -121 [ 0.632650] elants_i2c i2c-ELAN0001:00: elants_i2c_send failed (4d 61 69 6e): -121 [ 0.634256] elants_i2c i2c-ELAN0001:00: boot failed: -121 [ 0.699212] elants_i2c i2c-ELAN0001:00: invalid 'hello' packet: 00 00 ff ff [ 1.630506] elants_i2c i2c-ELAN0001:00: Failed to read fw id: -121 [ 1.645508] elants_i2c i2c-ELAN0001:00: unknown packet 00 00 ff ff Despite these errors, the elants_i2c driver stays bound to the device (it returns 0 from its probe method despite the errors), blocking the i2c-hid driver from binding. Manually unbinding the elants_i2c driver and binding the i2c-hid driver makes the touchscreen work. Check if the ACPI-fwnode for the touchscreen contains one of the i2c-hid compatiblity-id strings and if it has the I2C-HID spec's DSM to get the HID descriptor address, If it has both then make elants_i2c not bind, so that the i2c-hid driver can bind. This assumes that non of the (older) elan touchscreens which actually need the elants_i2c driver falsely advertise an i2c-hid compatiblity-id + DSM in their ACPI-fwnodes. If some of them actually do have this false advertising, then this change may lead to regressions. While at it also drop the unnecessary DEVICE_NAME prefixing of the "I2C check functionality error", dev_err already outputs the driver-name. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207759 Acked-by: Benjamin Tissoires Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20210405202756.16830-1-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/touchscreen/elants_i2c.c | 44 ++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index d21ca39b0fdb..adfae2d88707 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -41,6 +41,7 @@ #include #include #include +#include #include /* Device, Driver information */ @@ -1131,6 +1132,40 @@ static void elants_i2c_power_off(void *_data) } } +#ifdef CONFIG_ACPI +static const struct acpi_device_id i2c_hid_ids[] = { + {"ACPI0C50", 0 }, + {"PNP0C50", 0 }, + { }, +}; + +static const guid_t i2c_hid_guid = + GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555, + 0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE); + +static bool elants_acpi_is_hid_device(struct device *dev) +{ + acpi_handle handle = ACPI_HANDLE(dev); + union acpi_object *obj; + + if (acpi_match_device_ids(ACPI_COMPANION(dev), i2c_hid_ids)) + return false; + + obj = acpi_evaluate_dsm_typed(handle, &i2c_hid_guid, 1, 1, NULL, ACPI_TYPE_INTEGER); + if (obj) { + ACPI_FREE(obj); + return true; + } + + return false; +} +#else +static bool elants_acpi_is_hid_device(struct device *dev) +{ + return false; +} +#endif + static int elants_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1139,9 +1174,14 @@ static int elants_i2c_probe(struct i2c_client *client, unsigned long irqflags; int error; + /* Don't bind to i2c-hid compatible devices, these are handled by the i2c-hid drv. */ + if (elants_acpi_is_hid_device(&client->dev)) { + dev_warn(&client->dev, "This device appears to be an I2C-HID device, not binding\n"); + return -ENODEV; + } + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(&client->dev, - "%s: i2c check functionality error\n", DEVICE_NAME); + dev_err(&client->dev, "I2C check functionality error\n"); return -ENXIO; } -- 2.30.2