Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1086838ybl; Wed, 14 Aug 2019 10:29:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4JBiurGX6fH90fr7nWUncTBpcYWEu13Ve3FuBkyPJO6A6w4VOlWpZY/PRlOn7yyrVXm4Z X-Received: by 2002:a17:902:a612:: with SMTP id u18mr451589plq.181.1565803746633; Wed, 14 Aug 2019 10:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803746; cv=none; d=google.com; s=arc-20160816; b=Pe3X/3qpykLCb34GcejlnyvwzCf232q6Xb357V609qWfw/kKen7jWcuHumUdQTJ9Lu nkQRdzzTXRiCM7m1E26PMby+nb15z710N2pPM5RuhH1hehgmwmI7fQx0oWzYPsnaxR4P QtLM7EUvsjUiKJk3JfzFaPa5ho5IUv5fDd1tPF8+FAbOR1y3Eo4av9R2RXxKdkbsE+CT UAyU1wgzge7a7/4QhglfavA1nRM5Rq5LeqjDA7NQVqTu6r9mHz1OGOkZCGMEabpY5z0B nt0ioplhIFedw6ubWtuKz01SrN6B6ox+FnAbRukKOl8hTOZJdmXcaf7GAPgArcF7Saqh OChg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ahXg9lJs9V8ywsxFn0RLw5St25eBxjdbifuOt0n1wAM=; b=OhBmjmZT4Ylj75wISNVv0/QUf3VaPcPgegcL2SVXEHP24D/1ClS/s+Tyu2znEIG9um TuW8GF9TgMa5GOe2RfzQvvZhx5eBXGmq8VmlSeE0Hs4/jaME+TEHvCt2TfKA4zCsPKLZ qk+hiJ0rnkRw6MrWGKMbX5ZzLBn9COaZn0RdAT2ZGaXIi9f9qtIp1ihLVRXXA/XHgHsy XLqisX071BYSfPOALncj1vUmuvQJ5NTZ89mnpZ0zT6rcMmiI//afkrmZpEViub18jHRJ t32Et4dcTTaRxoZJPRuMKwM9cZuXygjbuh5/dSXqrVnBtu6BYt64FX62uLYmoA+iSAty 2GoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mq9l13cq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si249124plm.396.2019.08.14.10.28.51; Wed, 14 Aug 2019 10:29:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Mq9l13cq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728767AbfHNR15 (ORCPT + 99 others); Wed, 14 Aug 2019 13:27:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:51564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728811AbfHNRDC (ORCPT ); Wed, 14 Aug 2019 13:03:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B742421721; Wed, 14 Aug 2019 17:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802181; bh=a0BZRsJPSZLXdum6dP3S6nZ4tj4eiaaRbI+0p0ZpcSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mq9l13cqvuONEvxa9dhUhbxxHGHci/+wuLZd07W5FOAfkU4lxqF74SShIAqk1xvAR W0deRHbwkjxEK2ZVe2j/Ow2e7NpRgYp6r5BWE7Py7qty73D00iIq5gfc9kPRpO9BEQ jtxwZ5R/HobAUGtRFNm9P89kw0TxdGdYCRIdW0Q4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai-Heng Feng , Benjamin Tissoires , Dmitry Torokhov Subject: [PATCH 5.2 025/144] Input: elantech - enable SMBus on new (2018+) systems Date: Wed, 14 Aug 2019 18:59:41 +0200 Message-Id: <20190814165800.898710379@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai-Heng Feng commit 883a2a80f79ca5c0c105605fafabd1f3df99b34c upstream. There are some new HP laptops with Elantech touchpad that don't support multitouch. Currently we use ETP_NEW_IC_SMBUS_HOST_NOTIFY() to check if SMBus is supported, but in addition to firmware version, the bus type also informs us whether the IC can support SMBus. To avoid breaking old ICs, we will only enable SMbus support based the bus type on systems manufactured after 2018. Lastly, let's consolidate all checks into elantech_use_host_notify() and use it to determine whether to use PS/2 or SMBus. Signed-off-by: Kai-Heng Feng Acked-by: Benjamin Tissoires Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/mouse/elantech.c | 54 ++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 29 deletions(-) --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -1807,6 +1807,30 @@ static int elantech_create_smbus(struct leave_breadcrumbs); } +static bool elantech_use_host_notify(struct psmouse *psmouse, + struct elantech_device_info *info) +{ + if (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version)) + return true; + + switch (info->bus) { + case ETP_BUS_PS2_ONLY: + /* expected case */ + break; + case ETP_BUS_SMB_HST_NTFY_ONLY: + case ETP_BUS_PS2_SMB_HST_NTFY: + /* SMbus implementation is stable since 2018 */ + if (dmi_get_bios_year() >= 2018) + return true; + default: + psmouse_dbg(psmouse, + "Ignoring SMBus bus provider %d\n", info->bus); + break; + } + + return false; +} + /** * elantech_setup_smbus - called once the PS/2 devices are enumerated * and decides to instantiate a SMBus InterTouch device. @@ -1826,7 +1850,7 @@ static int elantech_setup_smbus(struct p * i2c_blacklist_pnp_ids. * Old ICs are up to the user to decide. */ - if (!ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version) || + if (!elantech_use_host_notify(psmouse, info) || psmouse_matches_pnp_id(psmouse, i2c_blacklist_pnp_ids)) return -ENXIO; } @@ -1846,34 +1870,6 @@ static int elantech_setup_smbus(struct p return 0; } -static bool elantech_use_host_notify(struct psmouse *psmouse, - struct elantech_device_info *info) -{ - if (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version)) - return true; - - switch (info->bus) { - case ETP_BUS_PS2_ONLY: - /* expected case */ - break; - case ETP_BUS_SMB_ALERT_ONLY: - /* fall-through */ - case ETP_BUS_PS2_SMB_ALERT: - psmouse_dbg(psmouse, "Ignoring SMBus provider through alert protocol.\n"); - break; - case ETP_BUS_SMB_HST_NTFY_ONLY: - /* fall-through */ - case ETP_BUS_PS2_SMB_HST_NTFY: - return true; - default: - psmouse_dbg(psmouse, - "Ignoring SMBus bus provider %d.\n", - info->bus); - } - - return false; -} - int elantech_init_smbus(struct psmouse *psmouse) { struct elantech_device_info info;