From patchwork Fri Apr 25 10:14:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 4058941 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 785199F3EE for ; Fri, 25 Apr 2014 10:18:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A052A203A9 for ; Fri, 25 Apr 2014 10:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2E042039D for ; Fri, 25 Apr 2014 10:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753057AbaDYKSo (ORCPT ); Fri, 25 Apr 2014 06:18:44 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:28122 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751866AbaDYKQl (ORCPT ); Fri, 25 Apr 2014 06:16:41 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N4L00NZL0JS2860@mailout1.samsung.com>; Fri, 25 Apr 2014 19:16:40 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 74.C2.09952.8063A535; Fri, 25 Apr 2014 19:16:40 +0900 (KST) X-AuditID: cbfee690-b7fcd6d0000026e0-00-535a3608b5d1 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AE.F6.27725.7063A535; Fri, 25 Apr 2014 19:16:40 +0900 (KST) Received: from chnaveen-ubuntu.sisodomain.com ([107.108.83.161]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N4L00LYZ0JCQJ30@mmp2.samsung.com>; Fri, 25 Apr 2014 19:16:39 +0900 (KST) From: Naveen Krishna Chatradhi To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, dianders@chromium.org, gregkh@linuxfoundation.org, naveenkrishna.ch@gmail.com, lars@metafoo.de, cpgs@samsung.com, grundler@chromium.org Subject: [PATCH 3/5] iio: exynos_adc: reduce timeout and use wait_for_completion_timeout Date: Fri, 25 Apr 2014 15:44:45 +0530 Message-id: <1398420888-5506-4-git-send-email-ch.naveen@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1398420888-5506-1-git-send-email-ch.naveen@samsung.com> References: <1398420888-5506-1-git-send-email-ch.naveen@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeLIzCtJLcpLzFFi42JZI2JSq8thFhVs0DSD1+LlIU2Ls8sOslk0 L17PZvHqyA8miyWT57NazDvyjsXi8q45bBYzzu9jsli07T+zA6fH7IaLLB47Z91l99g/dw27 x5I3h1g9+rasYvT4vEkugC2KyyYlNSezLLVI3y6BK2P2lvOsBTP4K5r37mRuYNzD08XIySEh YCLxcOFFNghbTOLCvfVANheHkMBSRonTTy8wdzFygBX17C6HiE9nlFiw5AALhNPPJLH870Ym kG42ATOJg4tWs4M0iAjISszs1gOpYRa4wCjx88sEVpAaYYEoiclLvzCB1LAIqErsmywCEuYV cJGY8uIdK8QuBYk5k2xAwpwCrhLrdx8D6xQCKrm/5Q8ryEgJgW3sEhefdIOtZREQkPg2+RAL RK+sxKYDzBC/SEocXHGDZQKj8AJGhlWMoqkFyQXFSelFJnrFibnFpXnpesn5uZsYgeF/+t+z CTsY7x2wPsSY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3sk40vzlr9dW 89N6dAyqSmyztqUvN3Kf0SWgFDFj3fLQmdenKLtXRdZMepopeVI+zXzGcrU9EXole46zdvMr sRRnJBpqMRcVJwIAKvk3fPICAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 ADC module on Exynos5 SoCs runs at 600KSPS. At this conversion rate, waiting for 1000 msecs is wasteful (incase of h/w failure). Hence, reduce the time out to 100msecs and use wait_for_completion_timeout() instead of wait_for_completion_interruptible_timeout() Also, handle the return values in exynos_raw_read() call. Change-Id: Icb8cade162094b2777c9f3c77120635deef5947c Signed-off-by: Naveen Krishna Chatradhi --- This change is a part of the patch reviewd at https://lkml.org/lkml/2013/11/5/92 drivers/iio/adc/exynos_adc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index a2b8b1a..4d2467a 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -82,7 +82,7 @@ enum adc_version { #define ADC_CON_EN_START (1u << 0) #define ADC_DATX_MASK 0xFFF -#define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(1000)) +#define EXYNOS_ADC_TIMEOUT (msecs_to_jiffies(100)) struct exynos_adc { void __iomem *regs; @@ -121,6 +121,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev, struct exynos_adc *info = iio_priv(indio_dev); unsigned long timeout; u32 con1, con2; + int ret; if (mask != IIO_CHAN_INFO_RAW) return -EINVAL; @@ -145,16 +146,19 @@ static int exynos_read_raw(struct iio_dev *indio_dev, ADC_V1_CON(info->regs)); } - timeout = wait_for_completion_interruptible_timeout + timeout = wait_for_completion_timeout (&info->completion, EXYNOS_ADC_TIMEOUT); - *val = info->value; + if (timeout == 0) { + ret = -ETIMEDOUT; + } else { + *val = info->value; + *val2 = 0; + ret = IIO_VAL_INT; + } mutex_unlock(&indio_dev->mlock); - if (timeout == 0) - return -ETIMEDOUT; - - return IIO_VAL_INT; + return ret; } static irqreturn_t exynos_adc_isr(int irq, void *dev_id)