From patchwork Thu Oct 13 15:51:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 9375241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B3336075E for ; Thu, 13 Oct 2016 15:53:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BD9E286A3 for ; Thu, 13 Oct 2016 15:53:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 405022A138; Thu, 13 Oct 2016 15:53:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAB80286A3 for ; Thu, 13 Oct 2016 15:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932203AbcJMPxi (ORCPT ); Thu, 13 Oct 2016 11:53:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53348 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756395AbcJMPwA (ORCPT ); Thu, 13 Oct 2016 11:52:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 29895C0567B5; Thu, 13 Oct 2016 15:51:59 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-116-101.ams2.redhat.com [10.36.116.101]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9DFpERs008109; Thu, 13 Oct 2016 11:51:56 -0400 From: Benjamin Tissoires To: Dmitry Torokhov , Andrew Duggan , Lyude Paul , Christopher Heiny , Nick Dyer , Bjorn Andersson , Dennis Wassenberg Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v3 17/18] Input: synaptics-rmi4 - smbus: on resume, try 3 times if init fails Date: Thu, 13 Oct 2016 17:51:11 +0200 Message-Id: <1476373872-18027-18-git-send-email-benjamin.tissoires@redhat.com> In-Reply-To: <1476373872-18027-1-git-send-email-benjamin.tissoires@redhat.com> References: <1476373872-18027-1-git-send-email-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 13 Oct 2016 15:51:59 +0000 (UTC) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In some rare cases, we can't retrieve the SMBus version and so we fail binding the touchpad back. Instead of leaving a touchpad dead, try again to reinitialize it. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/input/rmi4/rmi_smbus.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c index 8d7ffe4..b2d5932 100644 --- a/drivers/input/rmi4/rmi_smbus.c +++ b/drivers/input/rmi4/rmi_smbus.c @@ -265,10 +265,29 @@ static int rmi_smb_reset(struct rmi_transport_dev *xport, u16 reset_addr) { struct rmi_smb_xport *rmi_smb = container_of(xport, struct rmi_smb_xport, xport); + struct i2c_client *client = rmi_smb->client; + struct rmi_device_platform_data *pdata; + int tries, ret; rmi_smb_clear_state(rmi_smb); - return rmi_smb_enable_smbus_mode(rmi_smb); + for (tries = 3; tries > 0; tries--) { + ret = rmi_smb_enable_smbus_mode(rmi_smb); + if (!ret) + break; + + /* we failed enabling SMBus, try again later */ + msleep(500); + } + + if (ret < 0) { + dev_warn(&client->dev, + "failed to enable SMBus mode, giving up.\n"); + pdata = dev_get_platdata(&rmi_smb->client->dev); + rmi_transport_enable(pdata, false); + } + + return ret; } static const struct rmi_transport_ops rmi_smb_ops = {