diff mbox

[3/5] iio: exynos_adc: reduce timeout and use wait_for_completion_timeout

Message ID 1398420888-5506-4-git-send-email-ch.naveen@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Naveen Krishna Chatradhi April 25, 2014, 10:14 a.m. UTC
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 <ch.naveen@samsung.com>
---
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(-)

Comments

Doug Anderson April 25, 2014, 4:28 p.m. UTC | #1
Naveen,

On Fri, Apr 25, 2014 at 3:14 AM, Naveen Krishna Chatradhi
<ch.naveen@samsung.com> wrote:
> 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.

You probably didn't need to mention this--it's just a natural part of
changing from wait_for_completion_interruptible_timeout() to
wait_for_completion_timeout().

>
> Change-Id: Icb8cade162094b2777c9f3c77120635deef5947c

Please don't send upstream with Change-Id.  Have you considered patman
<http://git.denx.de/?p=u-boot.git;a=blob;f=tools/patman/README;hb=refs/heads/master>?

> Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
> ---
> 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(-)

Other than problems above, this looks fine to me.  If you fix them,
feel free to add my Reviewed-by tag.

-Doug
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)