Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1068467ybl; Wed, 14 Aug 2019 10:11:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqy79qtd5donk1vjbezp3jvxtnBMpINfUOBLRxBH6k8Vi1wWeO/Q/WH3aVP/YmNDXP6/vXfF X-Received: by 2002:a63:5f95:: with SMTP id t143mr204545pgb.304.1565802691254; Wed, 14 Aug 2019 10:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802691; cv=none; d=google.com; s=arc-20160816; b=Nw7qo5b+1g2hib3Y8leARAAvoXOQT3ozsulgtoUd0Qzm41Sfch597S0sZcvISxFVhd ObiyGtpbPerIzzyvPUbyQ4kJcIi4FrpF9PerWq3TkUnfZtnzzuHgANVrQk2aAtJds9+c J5wesDEPyruM5EKuehvtwmIVReP0I8/gbZc/fQucRNO9Y3WqHDkeJU9xQet/CZJSwsSo yA2P50oXCzr1sTtGMr5awlODbk48dpW6unRaND/1N6rvGrSx1XhYX2lDf77B2PAAlbX6 70f7zPsI7jbgoxoThIG6C0Mp4TEmANJ2rzzZeL7+Knl0IWgOqAcT16exru1yIQuWZuVT F6Zg== 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=mXr6x4K0h3AJ3uuj/oidhRL0ViRaQMm9Wc2nRQyLl1A=; b=dRmGG1YYWRzI1nK678iMM/CrOGJSemc1Km0khleNEXGhDFI4LiLeOSWiJmJP5hpZZh iNeKCCVXXUR63/GuH5v1+s4G6Gs5GYGyzZAvVm5xYa+bCir/QHNEibcJi86P6KnzQ2IO W+2Rq/GGnT99gai+HzTx+jznxTYHR8msqahApoOjaJ9Y6duJc9ek6XhCtKHDT8jTvARM fl6zaHQhMW2DY77nlpedyp16Oc51A6uysD7aYz4mLvqTNKUxxNyKxDKU7jiv9fDTO3HU zL9X8rOfbYISs+78xlVR6vH2GChanGLJrrG/Wg61DhTXitWfEzhwwzvXu+9Bovl3fCPY 75aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JOkUrV2h; 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 r139si60320pfc.276.2019.08.14.10.11.15; Wed, 14 Aug 2019 10:11:31 -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=JOkUrV2h; 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 S1730203AbfHNRIq (ORCPT + 99 others); Wed, 14 Aug 2019 13:08:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:58892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729696AbfHNRIo (ORCPT ); Wed, 14 Aug 2019 13:08:44 -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 20951208C2; Wed, 14 Aug 2019 17:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802523; bh=gsOo6Nmmrf4fHlsUHWk/5Gr78ehI+V0PVi3XhQBTb7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JOkUrV2hVCeQNTNQaM3syE9kDJlDyvzTfuh8u4xqWKj6rzLFh0VIwlyY7e2zT20DI 3Go4a4DxnazdVvkly/FNRvhJrPJn/nLkcSt9E7p6jVZ7seRKnn1E85I1WPmyfF8xoh pzzjnU/SvGgkEnk+Qgxxzh7lUSduP26C/g87CNbk= 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 4.19 15/91] Input: elantech - enable SMBus on new (2018+) systems Date: Wed, 14 Aug 2019 19:00:38 +0200 Message-Id: <20190814165750.408653075@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 @@ -1810,6 +1810,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. @@ -1829,7 +1853,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; } @@ -1849,34 +1873,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;