From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60293C43441 for ; Sun, 11 Nov 2018 12:40:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20EE321479 for ; Sun, 11 Nov 2018 12:40:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z9YL4K1e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20EE321479 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728035AbeKKW3S (ORCPT ); Sun, 11 Nov 2018 17:29:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:56832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727597AbeKKW3R (ORCPT ); Sun, 11 Nov 2018 17:29:17 -0500 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 130D120866; Sun, 11 Nov 2018 12:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541940048; bh=JvhRP/jK66vg9VgQvU3IuGpCdhBfnzHEWe/pGGlzLKo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Z9YL4K1eAHNZUoxzWaL8DOtos8mMuyTJLAUtbzXC64jLTPw/64gJO4/f7nynhMHsL iRLBRSknfYf9pSLGGBBhanyVmZtc9R9jeajcxE1PVJ26g/gtBpOMmxfh3HE+0ER6of +ySN+u7jIphf2eY8hKjNCFGVDy32LrkUJiIUjuFI= Date: Sun, 11 Nov 2018 12:40:44 +0000 From: Jonathan Cameron To: Baolin Wang Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, freeman.liu@unisoc.com, broonie@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: adc: sc27xx: Add ADC data conversion timeout Message-ID: <20181111124044.52f61897@archlinux> In-Reply-To: <208f9043fbd9b14b7a0c2743f68fa424388f5dcd.1541733478.git.baolin.wang@linaro.org> References: <208f9043fbd9b14b7a0c2743f68fa424388f5dcd.1541733478.git.baolin.wang@linaro.org> X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 9 Nov 2018 11:25:31 +0800 Baolin Wang wrote: > From: Freeman Liu > > Sometimes the ADC controller met some problems, and it will not complete > the data conversion, that will can not wake up the read process any more > to block users. So we should add one maximum conversion time to avoid > this issue. > > Signed-off-by: Freeman Liu > Signed-off-by: Baolin Wang Hi. Patch looks good, but sounds like this is a fix so could I have a fixes tag and a patch title that makes that clear? I think we will want this one back ported to stable by the sound of it. If it is just a theoretical issue then perhaps we don't need to bother. Thanks, Jonathan > --- > drivers/iio/adc/sc27xx_adc.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c > index 7940b23..f7f7a189 100644 > --- a/drivers/iio/adc/sc27xx_adc.c > +++ b/drivers/iio/adc/sc27xx_adc.c > @@ -52,6 +52,9 @@ > /* Timeout (ms) for the trylock of hardware spinlocks */ > #define SC27XX_ADC_HWLOCK_TIMEOUT 5000 > > +/* Timeout (ms) for ADC data conversion according to ADC datasheet */ > +#define SC27XX_ADC_RDY_TIMEOUT 100 > + > /* Maximum ADC channel number */ > #define SC27XX_ADC_CHANNEL_MAX 32 > > @@ -223,7 +226,14 @@ static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel, > if (ret) > goto disable_adc; > > - wait_for_completion(&data->completion); > + ret = wait_for_completion_timeout(&data->completion, > + msecs_to_jiffies(SC27XX_ADC_RDY_TIMEOUT)); > + if (!ret) { > + dev_err(data->dev, "read ADC data timeout\n"); > + ret = -ETIMEDOUT; > + } else { > + ret = 0; > + } > > disable_adc: > regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL,