From patchwork Fri Dec 18 15:38:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 7886791 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4CAEF9F1AF for ; Fri, 18 Dec 2015 15:40:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7BD45204A9 for ; Fri, 18 Dec 2015 15:40:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B5902047D for ; Fri, 18 Dec 2015 15:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753882AbbLRPkS (ORCPT ); Fri, 18 Dec 2015 10:40:18 -0500 Received: from mga02.intel.com ([134.134.136.20]:19887 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753558AbbLRPkO (ORCPT ); Fri, 18 Dec 2015 10:40:14 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 18 Dec 2015 07:40:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,446,1444719600"; d="scan'208";a="864069145" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.56]) by fmsmga001.fm.intel.com with SMTP; 18 Dec 2015 07:40:11 -0800 Received: by lahna (sSMTP sendmail emulation); Fri, 18 Dec 2015 17:38:02 +0200 Date: Fri, 18 Dec 2015 17:38:02 +0200 From: Mika Westerberg To: Nish Aravamudan Cc: Jiri Kosina , Benjamin Tissoires , Andrew Duggan , Gabriele Mazzotta , Seth Forshee , Dan Carpenter , linux-input@vger.kernel.org, "linux-kernel@vger.kernel.org" Subject: Re: [RESEND] Lenovo Yoga 900 touchpad issues Message-ID: <20151218153802.GL1762@lahna.fi.intel.com> References: <20151216092858.GP1762@lahna.fi.intel.com> <20151218144209.GK1762@lahna.fi.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20151218144209.GK1762@lahna.fi.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Dec 18, 2015 at 04:42:09PM +0200, Mika Westerberg wrote: > On another occasion the faulty input report was received immediatelly > after we call i2c_hid_set_power(). > > With below hack patch suspend/resume works fine but it is far from being > suitable for merging. Still, it would be nice if you could try it out > and see if it helps in your case. Actually it looks like we can handle this by just ignoring input reports while we are resetting the device. Following seems to work as well. Tested-by: Nishanth Aravamudan --- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 10bd8e6..eeaf33a 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -352,13 +352,24 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state) static int i2c_hid_hwreset(struct i2c_client *client) { struct i2c_hid *ihid = i2c_get_clientdata(client); + bool started; int ret; i2c_hid_dbg(ihid, "%s\n", __func__); + /* + * Some touchpads seem to send input reports once their power is + * turned back on after resume. This confuses our reset logic + * below. + * + * Prevent handling any input reports while we are resetting the + * device. + */ + started = test_and_clear_bit(I2C_HID_STARTED, &ihid->flags); + ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); if (ret) - return ret; + goto out; i2c_hid_dbg(ihid, "resetting...\n"); @@ -366,10 +377,14 @@ static int i2c_hid_hwreset(struct i2c_client *client) if (ret) { dev_err(&client->dev, "failed to reset device.\n"); i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); - return ret; + goto out; } - return 0; +out: + if (started) + set_bit(I2C_HID_STARTED, &ihid->flags); + + return ret; } static void i2c_hid_get_input(struct i2c_hid *ihid)