From patchwork Fri Jul 11 23:34:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Duggan X-Patchwork-Id: 4538151 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA57F9F333 for ; Fri, 11 Jul 2014 23:42:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E920820272 for ; Fri, 11 Jul 2014 23:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7ACB20266 for ; Fri, 11 Jul 2014 23:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751066AbaGKXl5 (ORCPT ); Fri, 11 Jul 2014 19:41:57 -0400 Received: from us-mx2.synaptics.com ([192.147.44.131]:15096 "EHLO us-mx2.synaptics.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751012AbaGKXl5 (ORCPT ); Fri, 11 Jul 2014 19:41:57 -0400 Received: from unknown (HELO securemail.synaptics.com) ([172.20.21.135]) by us-mx2.synaptics.com with ESMTP; 11 Jul 2014 16:41:56 -0700 Received: from USW-OWA1.synaptics-inc.local ([10.20.24.16]) by securemail.synaptics.com (PGP Universal service); Fri, 11 Jul 2014 16:49:44 -0700 X-PGP-Universal: processed; by securemail.synaptics.com on Fri, 11 Jul 2014 16:49:44 -0700 Received: from noble.synaptics-inc.local (10.2.20.38) by USW-OWA1.synaptics-inc.local (10.20.24.15) with Microsoft SMTP Server (TLS) id 14.3.123.3; Fri, 11 Jul 2014 16:41:07 -0700 From: Andrew Duggan To: , CC: Andrew Duggan , Jiri Kosina , Benjamin Tissoires , Vincent Huang Subject: [PATCH] HID: i2c-hid: call the hid driver's suspend and resume callbacks Date: Fri, 11 Jul 2014 16:34:18 -0700 Message-ID: <1405121658-3853-1-git-send-email-aduggan@synaptics.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.2.20.38] Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Currently, the i2c-hid driver does not call the suspend, resume, and reset_resume callbacks in the hid_driver struct when those events occur. This means that HID drivers for i2c-hid devices will not be able to execute commands which may be needed during suspend or resume. One example is when a touchpad using the hid-multitouch driver gets reset by i2c-hid coming out of resume. Since the reset_resume callback never gets called the device is never put back into the correct input mode. This patch calls the suspend and resume callbacks and tries to duplicate the functionality of the usb-hid driver. Signed-off-by: Andrew Duggan Signed-off-by: Vincent Huang Reviewed-by: Benjamin Tissoires --- Hi Benjamin, This is the patch which Vincent and I came up with to fix the behavior which we were seeing with touchpads not being operational after resuming. We only use the reset_resume callback since i2c_hid_resume is always doing a hardware reset and it doesn't seem like there is a condition in which the standard resume callback would be appropriate. Also, is a full hardware reset always needed when resuming? drivers/hid/i2c-hid/i2c-hid.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 21aafc8..747d544 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -1054,21 +1054,29 @@ static int i2c_hid_remove(struct i2c_client *client) static int i2c_hid_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct i2c_hid *ihid = i2c_get_clientdata(client); + struct hid_device *hid = ihid->hid; + int ret = 0; disable_irq(client->irq); if (device_may_wakeup(&client->dev)) enable_irq_wake(client->irq); + if (hid->driver && hid->driver->suspend) + ret = hid->driver->suspend(hid, PMSG_SUSPEND); + /* Save some power */ i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); - return 0; + return ret; } static int i2c_hid_resume(struct device *dev) { int ret; struct i2c_client *client = to_i2c_client(dev); + struct i2c_hid *ihid = i2c_get_clientdata(client); + struct hid_device *hid = ihid->hid; enable_irq(client->irq); ret = i2c_hid_hwreset(client); @@ -1078,6 +1086,11 @@ static int i2c_hid_resume(struct device *dev) if (device_may_wakeup(&client->dev)) disable_irq_wake(client->irq); + if (hid->driver && hid->driver->reset_resume) { + ret = hid->driver->reset_resume(hid); + return ret; + } + return 0; } #endif