From patchwork Fri May 3 13:57:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Schenker X-Patchwork-Id: 10928899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B5081390 for ; Fri, 3 May 2019 14:40:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B0E62863D for ; Fri, 3 May 2019 14:40:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 386662861D; Fri, 3 May 2019 14:40:57 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 D3BED28397 for ; Fri, 3 May 2019 14:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726376AbfECOk4 (ORCPT ); Fri, 3 May 2019 10:40:56 -0400 Received: from mxout014.mail.hostpoint.ch ([217.26.49.174]:26296 "EHLO mxout014.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbfECOkz (ORCPT ); Fri, 3 May 2019 10:40:55 -0400 Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout014.mail.hostpoint.ch with esmtp (Exim 4.91 (FreeBSD)) (envelope-from ) id 1hMYgy-000329-Ma; Fri, 03 May 2019 15:57:36 +0200 Received: from [46.140.72.82] (helo=philippe-pc.toradex.int) by asmtp013.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91 (FreeBSD)) (envelope-from ) id 1hMYgy-0003ks-De; Fri, 03 May 2019 15:57:36 +0200 X-Authenticated-Sender-Id: dev@pschenker.ch From: Philippe Schenker To: linux-iio@vger.kernel.org, Jonathan Cameron , Stefan Agner , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: dev@pschenker.ch, Philippe Schenker , Max Krummenacher , Alexandre Torgue , linux-kernel@vger.kernel.org, Lee Jones , Maxime Coquelin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] iio: stmpe-adc: Remove unnecessary assignment Date: Fri, 3 May 2019 15:57:23 +0200 Message-Id: <20190503135725.9959-1-dev@pschenker.ch> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Philippe Schenker Remove unnecessary assignment. This could potentially cause an issue, if the wait function runs into a timeout. Furthermore is this assignment also not there in stmpe_read_temp() Signed-off-by: Philippe Schenker --- drivers/iio/adc/stmpe-adc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 37f4b74a5d32..87141177fbda 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -78,8 +78,6 @@ static int stmpe_read_voltage(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); - *val = info->value; - ret = wait_for_completion_interruptible_timeout (&info->completion, STMPE_ADC_TIMEOUT); From patchwork Fri May 3 13:57:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Schenker X-Patchwork-Id: 10928849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DF3C912 for ; Fri, 3 May 2019 14:18:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C2E422376 for ; Fri, 3 May 2019 14:18:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2003D284A5; Fri, 3 May 2019 14:18:28 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 B9E5A22376 for ; Fri, 3 May 2019 14:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728116AbfECOS1 (ORCPT ); Fri, 3 May 2019 10:18:27 -0400 Received: from mxout013.mail.hostpoint.ch ([217.26.49.173]:14557 "EHLO mxout013.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728099AbfECOS1 (ORCPT ); Fri, 3 May 2019 10:18:27 -0400 X-Greylist: delayed 1246 seconds by postgrey-1.27 at vger.kernel.org; Fri, 03 May 2019 10:18:25 EDT Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout013.mail.hostpoint.ch with esmtp (Exim 4.91 (FreeBSD)) (envelope-from ) id 1hMYh0-0000Tx-H3; Fri, 03 May 2019 15:57:38 +0200 Received: from [46.140.72.82] (helo=philippe-pc.toradex.int) by asmtp013.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91 (FreeBSD)) (envelope-from ) id 1hMYh0-0003ks-8i; Fri, 03 May 2019 15:57:38 +0200 X-Authenticated-Sender-Id: dev@pschenker.ch From: Philippe Schenker To: linux-iio@vger.kernel.org, Jonathan Cameron , Stefan Agner , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: dev@pschenker.ch, Philippe Schenker , Max Krummenacher , Alexandre Torgue , linux-kernel@vger.kernel.org, Lee Jones , Maxime Coquelin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] iio: stmpe-adc: Make wait_completion non interruptible Date: Fri, 3 May 2019 15:57:24 +0200 Message-Id: <20190503135725.9959-2-dev@pschenker.ch> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503135725.9959-1-dev@pschenker.ch> References: <20190503135725.9959-1-dev@pschenker.ch> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Philippe Schenker In some cases, the wait_completion got interrupted. This caused the error-handling to mutex_unlock the function. The before turned on interrupt then got called anyway. In the ISR then completion() was called causing problems. Making this wait_completion non interruptible solves the problem. Signed-off-by: Philippe Schenker --- drivers/iio/adc/stmpe-adc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 87141177fbda..baa41ffc0d76 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -78,8 +78,7 @@ static int stmpe_read_voltage(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); - ret = wait_for_completion_interruptible_timeout - (&info->completion, STMPE_ADC_TIMEOUT); + ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); if (ret <= 0) { mutex_unlock(&info->lock); @@ -113,8 +112,7 @@ static int stmpe_read_temp(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_TEMP_CTRL, STMPE_START_ONE_TEMP_CONV); - ret = wait_for_completion_interruptible_timeout - (&info->completion, STMPE_ADC_TIMEOUT); + ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); if (ret <= 0) { mutex_unlock(&info->lock); From patchwork Fri May 3 13:57:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Schenker X-Patchwork-Id: 10928851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 99EA114C0 for ; Fri, 3 May 2019 14:22:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B36428623 for ; Fri, 3 May 2019 14:22:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 892102862A; Fri, 3 May 2019 14:22:19 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 2E92B28646 for ; Fri, 3 May 2019 14:22:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728086AbfECOWS (ORCPT ); Fri, 3 May 2019 10:22:18 -0400 Received: from mxout012.mail.hostpoint.ch ([217.26.49.172]:40363 "EHLO mxout012.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728099AbfECOWS (ORCPT ); Fri, 3 May 2019 10:22:18 -0400 Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout012.mail.hostpoint.ch with esmtp (Exim 4.91 (FreeBSD)) (envelope-from ) id 1hMYh1-000K4m-UA; Fri, 03 May 2019 15:57:39 +0200 Received: from [46.140.72.82] (helo=philippe-pc.toradex.int) by asmtp013.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91 (FreeBSD)) (envelope-from ) id 1hMYh1-0003ks-Oj; Fri, 03 May 2019 15:57:39 +0200 X-Authenticated-Sender-Id: dev@pschenker.ch From: Philippe Schenker To: linux-iio@vger.kernel.org, Jonathan Cameron , Stefan Agner , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: dev@pschenker.ch, Philippe Schenker , Max Krummenacher , Alexandre Torgue , linux-kernel@vger.kernel.org, Lee Jones , Maxime Coquelin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] iio: stmpe-adc: Enable all stmpe-adc interrupts just once Date: Fri, 3 May 2019 15:57:25 +0200 Message-Id: <20190503135725.9959-3-dev@pschenker.ch> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503135725.9959-1-dev@pschenker.ch> References: <20190503135725.9959-1-dev@pschenker.ch> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Philippe Schenker This commit will enable the interrupts of all channels handled by this driver only once in the probe function. This will improve performance because one byte less has to be written over i2c on each read out of the adc. On the fastest ADC mode this will improve read out speed by 15%. Signed-off-by: Philippe Schenker --- drivers/iio/adc/stmpe-adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index baa41ffc0d76..427c890c6e7d 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -72,9 +72,6 @@ static int stmpe_read_voltage(struct stmpe_adc *info, return -EINVAL; } - stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_EN, - STMPE_ADC_CH(info->channel)); - stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); @@ -328,6 +325,9 @@ static int stmpe_adc_probe(struct platform_device *pdev) if (ret) return ret; + stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_EN, + ~(norequest_mask & 0xFF)); + return devm_iio_device_register(&pdev->dev, indio_dev); }