From patchwork Mon Sep 14 16:53:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 7177621 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 C224A9F314 for ; Mon, 14 Sep 2015 16:53:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0BF92056C for ; Mon, 14 Sep 2015 16:53:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD8E620614 for ; Mon, 14 Sep 2015 16:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752409AbbINQxd (ORCPT ); Mon, 14 Sep 2015 12:53:33 -0400 Received: from mail-bn1bon0132.outbound.protection.outlook.com ([157.56.111.132]:25185 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753296AbbINQxb (ORCPT ); Mon, 14 Sep 2015 12:53:31 -0400 Received: from BLUPR03CA002.namprd03.prod.outlook.com (10.255.124.19) by CY1PR03MB1392.namprd03.prod.outlook.com (10.163.17.139) with Microsoft SMTP Server (TLS) id 15.1.268.17; Mon, 14 Sep 2015 16:53:27 +0000 Received: from BL2FFO11FD052.protection.gbl (10.255.124.4) by BLUPR03CA002.outlook.office365.com (10.255.124.19) with Microsoft SMTP Server (TLS) id 15.1.268.17 via Frontend Transport; Mon, 14 Sep 2015 16:53:27 +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 BL2FFO11FD052.mail.protection.outlook.com (10.173.161.214) with Microsoft SMTP Server (TLS) id 15.1.262.18 via Frontend Transport; Mon, 14 Sep 2015 16:53:27 +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 t8EGrOfH017259; Mon, 14 Sep 2015 09:53:25 -0700 From: Fabio Estevam To: CC: , , Fabio Estevam Subject: [PATCH 1/4] Input: touchscreen - Propagate the errors Date: Mon, 14 Sep 2015 13:53:17 -0300 Message-ID: <1442249600-666-1-git-send-email-fabio.estevam@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD052; 1:KB4+r5aXi3dA9CQrbUbpVd4ZiqCZKyBW3d7hGu+dSUmw64oLL7o+By4eJYxbx8D/WT8hU2bdlKGAtN7iA2lfShsdbcmBWPgy/uao6QKg3Pc+krptQllHaBdx72//ip5VgCZ9F5sgmJhofgJ6lT3v1uChWoCaq2H+AdD7m4NHlDzW2E/1DrEls7So0HoCdCabd2pyf9DErpr4+XSjPu54KCcjduSUGwqizkd6Bg3QZQFI/WCSAp6yo/E/4bzCNsVM/wmRLJljzYGJQ5sKLdjOyshIMpchNswDhuGyxR3PTTX2LK8IgQu5etgrcy3iMiIP5x+EVQFcAo83pL4kMmptaj/MbwZ3MOwPGdLA62Tm//9xIk/Gu2ZMMdBC6DIxuUEpdGZ/xrmRIvsTqg/RgiY7aQ== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(48376002)(50986999)(50466002)(19580395003)(6806004)(19580405001)(104016003)(85426001)(86362001)(33646002)(575784001)(47776003)(50226001)(11100500001)(62966003)(107886002)(87936001)(5001860100001)(5001960100002)(77156002)(64706001)(229853001)(2351001)(110136002)(189998001)(46102003)(36756003)(92566002)(5003940100001)(97736004)(105606002)(5001830100001)(68736005)(81156007)(4001540100001)(106466001)(77096005)(5007970100001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR03MB1392; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1392; 2:H8LXs4nP8dARppiZYuVCaJbN1ArpgxQ/AzYOfud/ncYA1xoEMvFmfvSbaivF6H4pAvDxfSk1PwAHvY6aCfGnYtnf9sq5hBTU7NsTvmYWzJpQtckQu9KAUtBGEkamJVv61JDAK5H/8e+fziJzL4LXBMDZouGpT60V7Ei3nd7ApbY=; 3:zco3EZXc4aRoeYVkET0iNW4EkzdQKKMyynH9L+modHt7718JGUKHKU3TXWInoD2nkPipZuZQfh1RSk53OhxUN9vOtgKre5nGjZokO8PO2QragjoPIaxhXfSzF0HD0BH3QkNWz0ROsdV85njw6Ho1TC6f6r6Xw41jmqarc2ZLbn6XU+ZaZxSmBovmu+/Vq67pgp7tXnxZUZJzuyUUjlFK5mCjIoLN7kM8DXwdhEHGRrI=; 25:3c7v81qm0vAN7w32CMXD9FB9vmhEuSYkr7caqNOZb7FUYZy4TlOMjYdObrgNQl6gUIS0qpaTDaXIfT0HtbzeYxSpa5DFcYGxw6eTCZm3H8jascOH6euJ+fT3LzTDlgA/Wplxs3rek3VNSvBR0HbHwfshJrqX2Gi4SVYPuZj6IyJveFIeFajw9Rd47gUf0g7VMUE/d90oMCMbfzHsk8nfdvMbMSqxwPyXWfUwlDrK45NkkokiBAQgeAfXUrOSKAm2ZEWoQlHOrPwFneFC8yRtkw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1392; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1392; 20:X7BOg6GwRFua4YTBha6OKkjsp0PhEyUyWjuqUciMolaQ4rBPaGNVIVgC/722xRzGUFVeBbOLFoUHgWU7VqH4rWwDbFSr52ehaPaCggWsxuW/kx25ZiVx4q3gGcjXVE3BFa/63FDZNO1ZNtH7D7vC/FPmdoM8NNigtLei78GdeIUGyQp8IL1U5pyf3lfubMQbVbFiF45bSZBzRVC4QSTtDGWN+FP+oDykGbf63fHRFFJTdWhZ1rykpBM+XuGvFUoDkzz2udvcFG+yJUoSt3NUvqaFLNzW1dUUI5cq9f7jH9IpBkZhsglCZ/S2Mabhn2zK39vy1mdku0YcH9Ho8wnxLnqi7d4DLsKT0sHHs6McMok=; 4:jWiJfdHj8Lk+6xXHpfoUl8RqMsHzEAoWKzzb2vhUtEBxAXv6Bw5UzyVQnt5L3k7ocMqUoxe7XxgYZPBb32xP9SWJTLFXehVJ4cOQ2F0UDhe2zHa4E8Fuu0lw1aSog5yyL6Nj17sWWeOq6DUvPIkokANRZwJF0/1SZfm/bxkfEGbNtQ2c/Z25epYb5wdVfRHcK9ADiTFa6X84W7F3MCGzS3AE+NVM/eGYZEwjMMy8Mt9sRW08cRUOVhcwxslGN52xCEr/OBwwhMP5LnRDMc2c5yog7NndUYMaVxB7pmsx+PKqimIJyHeq3ng8AwJ7M5uk X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(8121501046)(3002001); SRVR:CY1PR03MB1392; BCL:0; PCL:0; RULEID:; SRVR:CY1PR03MB1392; X-Forefront-PRVS: 0699FCD394 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB1392; 23:I2zr+wH6pI4ZYHaVRyejxBowIsNGDAS+11Lcd0VRv?= =?us-ascii?Q?HdRdLch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bQMOpq7Qs/zOMb?= =?us-ascii?Q?tzsMzUnI646ULBN5nuAVkbpguRBGe16n9+4BmIuiWWcipP1y/dcm2T805GR7?= =?us-ascii?Q?sEfQMlDRpUOEujPsY3Wd5zqvrV3VC0fZ/yh2pga3adQUnN73tqPa/z4JfGuO?= =?us-ascii?Q?r5lwLtm4GiQbkL+XkusglropXKeH8N/UGjIsTStzpVofPBSwkqTyHfO8A0Zt?= =?us-ascii?Q?elAOqeRG3QoogfxZ4DVBwEn+tWPDYBAZbfBOjRJjNwrHus5oYB/D4niaDpR3?= =?us-ascii?Q?uV3YkRMsyuGnWOkV/4loY3LhSaBR23nYy2UUMY9MaKPt8FGBla84/A+EjAbD?= =?us-ascii?Q?hVWNc2DkhJwL7trJxA=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB1392; 5:TaSWgi8jXekh0hyW74FMz7zxeahJqmk2pl1ggJOAdKceI4tfyRTkfElTmM8w0lE3IO9xTXN79YZuu2P+6DwGPv8SsK1RgouCSmaCStTEmZq27JzjrsQXFV8ZmQ85VkXf6a/9eSaEBaOovVHXpQJ0qg==; 24:zZRZReDIR/CGo75g4hfJSYKzMl8WYtTNFoDAdv10jQygX7mPtoHJtki/T0cdGTDWeKL/o60H4ixsmXOFjwTp5eMMJBBy7ysTtHwpu/Zl1Zk=; 20:kGj/uu3AW51DfdV5YacYzWVOjqge8eNHHIfTDfOa8YuKL4Y0bwWYQo0l9TT0SANJmlsLoFwo0yqmCcJyPYNlIQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2015 16:53:27.1609 (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: CY1PR03MB1392 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 --- 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: