From patchwork Tue Dec 17 20:16:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Heiny X-Patchwork-Id: 3365111 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 AAE7E9F314 for ; Tue, 17 Dec 2013 20:16:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67D79203AA for ; Tue, 17 Dec 2013 20:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EB6B203A9 for ; Tue, 17 Dec 2013 20:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751910Ab3LQUQG (ORCPT ); Tue, 17 Dec 2013 15:16:06 -0500 Received: from us-mx2.synaptics.com ([192.147.44.131]:58635 "EHLO us-mx2.synaptics.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751593Ab3LQUQF (ORCPT ); Tue, 17 Dec 2013 15:16:05 -0500 Received: from unknown (HELO securemail.synaptics.com) ([172.20.21.135]) by us-mx2.synaptics.com with ESMTP; 17 Dec 2013 12:16:05 -0800 Received: from USW-OWA1.synaptics-inc.local ([10.20.24.16]) by securemail.synaptics.com (PGP Universal service); Tue, 17 Dec 2013 12:06:49 -0800 X-PGP-Universal: processed; by securemail.synaptics.com on Tue, 17 Dec 2013 12:06:49 -0800 Received: from brontomerus.synaptics.com (10.3.20.103) by USW-OWA1.synaptics-inc.local (10.20.24.15) with Microsoft SMTP Server (TLS) id 14.3.123.3; Tue, 17 Dec 2013 12:16:03 -0800 From: Christopher Heiny To: Dmitry Torokhov CC: Linux Input , Christopher Heiny , Andrew Duggan , Vincent Huang , Vivian Ly , Daniel Rosenberg , Jean Delvare , Joerie de Gram , Linus Walleij , Benjamin Tissoires Subject: [PATCH V2] input synaptics-rmi4: Bug fixes to ATTN GPIO handling. Date: Tue, 17 Dec 2013 12:16:01 -0800 Message-ID: <1387311361-29411-1-git-send-email-cheiny@synaptics.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.3.20.103] X-Brightmail-Tracker: AAAAAQAAAWE= 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.4 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 This patch fixes two bugs in handling of the RMI4 attention line GPIO. 1) in enable_sensor(), make sure the attn_gpio is defined before attempting to get its value. 2) in rmi_driver_probe(), declare the name of the attn_gpio, then request the attn_gpio before attempting to export it. Also introduces a GPIO_LABEL constant for identifying the attention GPIO. Signed-off-by: Christopher Heiny Cc: Dmitry Torokhov Cc: Benjamin Tissoires --- drivers/input/rmi4/rmi_driver.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) -- 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/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index a30c7d3..33fb8f8 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -169,7 +169,7 @@ static int enable_sensor(struct rmi_device *rmi_dev) data->enabled = true; - if (!pdata->level_triggered && + if (pdata->attn_gpio && !pdata->level_triggered && gpio_get_value(pdata->attn_gpio) == pdata->attn_polarity) retval = process_interrupt_requests(rmi_dev); @@ -807,6 +807,8 @@ static int rmi_driver_remove(struct device *dev) return 0; } +static const char GPIO_LABEL[] = "attn"; + static int rmi_driver_probe(struct device *dev) { struct rmi_driver *rmi_driver; @@ -959,20 +961,24 @@ static int rmi_driver_probe(struct device *dev) } if (IS_ENABLED(CONFIG_RMI4_DEV) && pdata->attn_gpio) { - retval = gpio_export(pdata->attn_gpio, false); + retval = gpio_request(pdata->attn_gpio, GPIO_LABEL); if (retval) { - dev_warn(dev, "WARNING: Failed to export ATTN gpio!\n"); - retval = 0; + dev_warn(dev, "WARNING: Failed to request ATTN gpio %d, code: %d.\n", + pdata->attn_gpio, retval); } else { - retval = gpio_export_link(dev, - "attn", pdata->attn_gpio); + retval = gpio_export(pdata->attn_gpio, false); if (retval) { - dev_warn(dev, - "WARNING: Failed to symlink ATTN gpio!\n"); - retval = 0; + dev_warn(dev, "WARNING: Failed to export ATTN gpio %d, code: %d.\n", + pdata->attn_gpio, retval); } else { - dev_info(dev, "Exported ATTN GPIO %d.", - pdata->attn_gpio); + retval = gpio_export_link(dev, GPIO_LABEL, + pdata->attn_gpio); + if (retval) + dev_warn(dev, + "WARNING: Failed to symlink ATTN gpio!\n"); + else + dev_info(dev, "Exported ATTN GPIO %d.", + pdata->attn_gpio); } } }