Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp241413pxj; Thu, 20 May 2021 08:24:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrrbRbyPs2vjXyg3ijAp1HH7RzZ+tjwPfiwavHJE9nfEjakvom/aj6yyuKEz/bsm0/2GIF X-Received: by 2002:a05:6e02:1cac:: with SMTP id x12mr4932489ill.43.1621524256581; Thu, 20 May 2021 08:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621524256; cv=none; d=google.com; s=arc-20160816; b=qHIIne4kH62HAwPaLhdFOQNydF/tp7H4X36as1jACB6oj2nqFnhnkBwta6QwgXGxMc 24jPX79NoZUve9yFw2D6fHDMuDCS8Se2KV4RgaJd8cwndgi8ZeXb54+CxHAdUpl7dfbf Q8rKTWCr8wJmDSPx6ct/TpcTOqaCorTsdmcqaea8EW0rkSovG01RBPmhDnFjfdvknmcA vC3fZZy5ahEOfqEm7Txb0o7196K1TmZotPUBURmojBuMTOJRsVImKY83chQDKX1YTIq9 uPmUzXuP8NH0UfMszbscuLzBK4A7yTiUEUtfMl9yiQX1gZ0Y6M6y+cYYOMlEjJCkwkmf cCuA== 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=hweBJm1EbCM8jmfbvTeXXSFgQBCRlvow5SDXSoiU0+4=; b=M5B49p/zn8K27OH/nBKNk+DGUYLivjYtqyxTcx9KU2VGLIS9wFuxuHomMqKbGAlNXZ jQl2yjSAZuaq6BacrXOwsdhmwwn+HS4ulNY7cR4UbqMxSlwnZ7cYW31FjL/iQRd9EOKu Aezt+9DURKxoaIjEQlaI8NSrQYLibWWBmKtuSF6MsJMay8mZaKhrkQasKwXTz9qqMPqw cK+oqg2ljvMzefy2Ogf7OJ2fq3CfES1WyAwU5TYzubnhTXPH2UyyAdFsdFcO3E3uRQmU 0tCX0GGEpcEd2HtbG/WtlVLEVdfxiZpiV8REm9d4rVgeYcQ6K4cF7NbiPilIrpfyWfD8 Da+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zGiHfMIr; 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 f16si1281812ilr.83.2021.05.20.08.24.03; Thu, 20 May 2021 08:24:16 -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=zGiHfMIr; 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 S232580AbhETJd5 (ORCPT + 99 others); Thu, 20 May 2021 05:33:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:54400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232587AbhETJb7 (ORCPT ); Thu, 20 May 2021 05:31:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7CCA613E9; Thu, 20 May 2021 09:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502894; bh=684/IdpLPgL51WJZHx/nazLtQLd22z0MeAZL+5k0VxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zGiHfMIrAUaJT/QdSqzRUokTUDVg/3F2eQSqOVNx6XWCF4ojyWNrAbmDFcN3pCPRU NA65MGPAfIoZCaSIA6SJhShD7Tx7SWAx1pIsvoub8fnHFG4Vr7ik1jSqyE2x8+RSeo SDmP1ANlILkMARj968q11etE0MDvn0DAhBMzSnuE= 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 5.4 14/37] Input: elants_i2c - do not bind to i2c-hid compatible ACPI instantiated devices Date: Thu, 20 May 2021 11:22:35 +0200 Message-Id: <20210520092052.745496208@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092052.265851579@linuxfoundation.org> References: <20210520092052.265851579@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 d4ad24ea54c8..a51e7c85f581 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -36,6 +36,7 @@ #include #include #include +#include #include /* Device, Driver information */ @@ -1127,6 +1128,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) { @@ -1135,9 +1170,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