From patchwork Mon Sep 14 17:00:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 7177651 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 45B019F39B for ; Mon, 14 Sep 2015 17:00:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 357FF2057E for ; Mon, 14 Sep 2015 17:00:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29429203E1 for ; Mon, 14 Sep 2015 17:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753752AbbINRAN (ORCPT ); Mon, 14 Sep 2015 13:00:13 -0400 Received: from mail-bl2on0105.outbound.protection.outlook.com ([65.55.169.105]:35040 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752409AbbINRAM (ORCPT ); Mon, 14 Sep 2015 13:00:12 -0400 Received: from CH1PR03CA003.namprd03.prod.outlook.com (10.255.156.148) by CY1PR0301MB1305.namprd03.prod.outlook.com (10.161.212.15) with Microsoft SMTP Server (TLS) id 15.1.262.15; Mon, 14 Sep 2015 17:00:09 +0000 Received: from BL2FFO11OLC006.protection.gbl (10.255.156.132) by CH1PR03CA003.outlook.office365.com (10.255.156.148) with Microsoft SMTP Server (TLS) id 15.1.268.17 via Frontend Transport; Mon, 14 Sep 2015 17:00:09 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11OLC006.mail.protection.outlook.com (10.173.160.95) with Microsoft SMTP Server (TLS) id 15.1.262.18 via Frontend Transport; Mon, 14 Sep 2015 17:00:09 +0000 Received: from fabio-Latitude-E6410.am.freescale.net (fabio-Latitude-E6410.am.freescale.net [10.29.244.190]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t8EH07ho019064; Mon, 14 Sep 2015 10:00:07 -0700 From: Fabio Estevam To: CC: , , Fabio Estevam Subject: [PATCH v2 1/4] Input: imx6ul_tsc - Propagate the errors Date: Mon, 14 Sep 2015 14:00:00 -0300 Message-ID: <1442250003-4040-1-git-send-email-fabio.estevam@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC006; 1:XZmPlrm1oGsWLlZihrmOl82jeY5pa7vWGeYEDmeM94drNa5DF4kQVjB3GCWlaJXrnkjWBbHT+ocDMxyDvJnB3NZS2XsSfxmnDfjcpESQ+ZhLVQCpRdyl4QPsn401BTDrz/dH+/z9HOZOnzaa6j0ObT8ntbRxKEEJNuekRhrWyAqKktdYCwDw2kAlOVb42ghso6zTxYf22QALM06hc4FhXu/5NrYrfoAxoK5Wsqj6/p3JsayFz09l6JpxV3lgYtn8+V49WDGZpx4TY91+Rt+JudRuipFwb5wKfXeLd6aELo58hqv7x73zD5tTQm8mI2fIVUW7Tq08kpWvMcvfMUZyViHtVLGepeAB2wzFLkgCFij4wAIDnKis820Vz1NMsXeTF4eXdcLURyAVq5jgDiV0Sw== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(77156002)(5001860100001)(2351001)(5001830100001)(87936001)(68736005)(62966003)(77096005)(46102003)(106466001)(92566002)(50226001)(105606002)(33646002)(104016003)(50986999)(48376002)(5001920100001)(5003940100001)(19580395003)(6806004)(86362001)(575784001)(85426001)(19580405001)(110136002)(11100500001)(229853001)(4001540100001)(47776003)(36756003)(50466002)(97736004)(5001960100002)(107886002)(81156007)(5007970100001)(64706001)(189998001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1305; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1305; 2:beZPvCBpGDbF2CtlE7ongoCncB+UAcKokzH33St8Hu3bfLFMFrjBx3hb2ri3IgOGCxPrl0iEI7wZg+ZlbhY+FPb/+74IUvMCQTeee1t120YBdUOeBz9rWoikqMjym3UpYuI8FJptnZvbZbGpY/0derF5c0kWjJMR/xkOQI/5EgQ=; 3:hHGAqup2rsc+2x8jyiTRFNyKc6Dz1/rR7BRNkhOeujkw90hb1hQ2fzqgGPjTRNldFTy8dMnvhctZSMzwHShOy67uGzRszgrpcRHW56ht85ppCQpfzqOhWq6ZsaFDWojseG0K3f75ux1pXv2tNM+gz1P/LlzDOy3TuWnFiaXNHw5aNaxwZSYgzMO5ez4CJWXAiPx0QS+ZKYvT1xSZb1b2KmSjcZ9fuTFzST+8UHOrJc8=; 25:+OscKMQjqVdKGNpvyKYmKRWYiaeIiSw8QIsJzXzSLJaJSnj5olHTQ4EHzRQAQpQKeoBS4bYsyjNZ+GVfiJhTzE2Ao5Q32jnwkfoH76es0GhzdUGiEP8VJpKMFWwoq+2NUsijCVpmaStD4uN/kvy+x80DYpnQjxuaypAuwWsggoTK2rM6cwIx3MMwc9//9qjWLp8aSug57PBjXG8Ygmy7uDGS0CG5wNU+9LbPNTQo2JM2+LjuuJYRTRevljzl+V3bY1gVOD7lLkdUaDT18/YxVA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1305; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1305; 20:PJ9GMkb/nJzkPv8XPOSMie6PMtoqKlisPVmXuXwSvyy9vpsCddDtDV5omCyOFy89nXXyGzEoYdADQvwK2XU9V6Vva0JY11Sti249wwVe9JZEASBE1nQIQRmpPgBC1dDbE+DMGw1jcOO3ZpRZfSzk66b4Di15QH7kmVRONEIBZwFkxKZjAUUoZJutjZrVuhnOizZn+IB7AQeBaGmpZlALBveAI7LnWOC8eK5wBiknPXncuiZGVzZFTjuSumBRnJLzMHjL0frwI6j7TrWutv6RSkfYS9Dq0W/bhWv8E+Pk30L3O10q7X++AT9cBJLcooaG/mVUEAWavZCpm2jtXXNZ3vAMLFt2EvV1/J0gW9wlzNA=; 4:nAso2xldbEyri7sJRDJEYJ0NN0nokMfyuuR+0VlOcMJeI2+xABF2PZg5K+bT7TzUG2nog1V0p2T4mRrl1ro2bvSN44H1NaT23XFPZwZ/oDp6rd2LOyKuXr8s2egq/bVo8gv8HBI8PEv8ULkyIFqN0nfcBjjcG21Ywz4By5ui2CR/GPg52TeC4mEPjVcHPcOOErTV+0VMfwFvjxthUQ57uVR8AkKCmXib79LjntqUH5dfBrmtKUYiXxsPbj81+F0YkYx7r+zVDHfL/Df2gi7ETeEh4SyoqJAj3VcYVW3FsDAtRJaYoXqXl5AhnN50bhIy X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(8121501046)(5005006)(3002001); SRVR:CY1PR0301MB1305; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1305; X-Forefront-PRVS: 0699FCD394 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1305; 23:+22WPRn5sFEqwABqe5QNi20rgEVBjziaCacbLgR?= =?us-ascii?Q?Gnib/BCFX2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PBiS?= =?us-ascii?Q?uC05up9bqq3w59X6rWbc3aulBqhCKcORCxjy08S5ktpN5O8Co9yAyv8Z0h5a?= =?us-ascii?Q?kIEdDlrLmlrSZH3pzW6uafqqPnqJE8yRqHrcBY1d1CPR0zevp+t//U8RY0vs?= =?us-ascii?Q?3GP9uuzU9k7P30ve4/cukfWvLyexISeHChLQ0dk22e+iRVkWT2WhShYelJHw?= =?us-ascii?Q?FxlO/XvLhus3SzrUswiTDUg3t0L5sJc43MxhvPaaLcA7iYef/SQHXWDzdYdK?= =?us-ascii?Q?qtl7S1tfoboywq4yt6Wj4U6BcYmNJVGPKDHRDT75MaBca62+u4Yz6X7o6K2y?= =?us-ascii?Q?5qHlGdjvgEjhr//W5fC2uf/FQzVS8YvzHlLnhDIpQ?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1305; 5:qfFDf87arZ4Ev7PdqtFfXAJaJaAiE4jqw9BKMZFpRV4kuyRqg/isuUv+yAxAbKGjJGr922TYeOVZ0rR1QacPcx/dIRMkCYaC1Mvns+jGuQxz64BAOX6qa9rwdSjR6upBlvEB7vbqlnWWhX68w6z2tQ==; 24:Vy4r1kR9W16UoybLnxP2ZfklZMIlXghVogalxmBShRnk98kNh6OkXKnjP5TZxEjUo4o21ADr4a3o6MrJeupwKii2vyBxO7wiD6F/C8ZkbgU=; 20:v4ncXLSEFFtFX+Zimb4EHZd5YJ7YUnHKhGE40Sjud8wUt669Ln/SseoYOj3yQz0LNNiakNlLqUJ3umdH2qq+4Q== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2015 17:00:09.0823 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1305 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=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 imx6ul_adc_init() may fail in two cases, so we should better propagate the errors and make sure that the callers of this function also check and propagate the errors accordingly. Signed-off-by: Fabio Estevam --- Changes since v1: - Pass 'imx6ul_tsc' in the Subject drivers/input/touchscreen/imx6ul_tsc.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c index ff0b758..0a96b76 100644 --- a/drivers/input/touchscreen/imx6ul_tsc.c +++ b/drivers/input/touchscreen/imx6ul_tsc.c @@ -94,7 +94,7 @@ struct imx6ul_tsc { * TSC module need ADC to get the measure value. So * before config TSC, we should initialize ADC module. */ -static void imx6ul_adc_init(struct imx6ul_tsc *tsc) +static int imx6ul_adc_init(struct imx6ul_tsc *tsc) { int adc_hc = 0; int adc_gc; @@ -122,17 +122,23 @@ static void imx6ul_adc_init(struct imx6ul_tsc *tsc) timeout = wait_for_completion_timeout (&tsc->completion, ADC_TIMEOUT); - if (timeout == 0) + if (timeout == 0) { dev_err(tsc->dev, "Timeout for adc calibration\n"); + return -ETIMEDOUT; + } adc_gs = readl(tsc->adc_regs + REG_ADC_GS); - if (adc_gs & ADC_CALF) + if (adc_gs & ADC_CALF) { dev_err(tsc->dev, "ADC calibration failed\n"); + return -EINVAL; + } /* TSC need the ADC work in hardware trigger */ adc_cfg = readl(tsc->adc_regs + REG_ADC_CFG); adc_cfg |= ADC_HARDWARE_TRIGGER; writel(adc_cfg, tsc->adc_regs + REG_ADC_CFG); + + return 0; } /* @@ -188,11 +194,17 @@ static void imx6ul_tsc_set(struct imx6ul_tsc *tsc) writel(start, tsc->tsc_regs + REG_TSC_FLOW_CONTROL); } -static void imx6ul_tsc_init(struct imx6ul_tsc *tsc) +static int imx6ul_tsc_init(struct imx6ul_tsc *tsc) { - imx6ul_adc_init(tsc); + int err; + + err = imx6ul_adc_init(tsc); + if (err) + return err; imx6ul_tsc_channel_config(tsc); imx6ul_tsc_set(tsc); + + return 0; } static void imx6ul_tsc_disable(struct imx6ul_tsc *tsc) @@ -311,9 +323,7 @@ static int imx6ul_tsc_open(struct input_dev *input_dev) return err; } - imx6ul_tsc_init(tsc); - - return 0; + return imx6ul_tsc_init(tsc); } static void imx6ul_tsc_close(struct input_dev *input_dev) @@ -491,7 +501,7 @@ static int __maybe_unused imx6ul_tsc_resume(struct device *dev) goto out; } - imx6ul_tsc_init(tsc); + retval = imx6ul_tsc_init(tsc); } out: