Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3067825imu; Sun, 11 Nov 2018 07:01:44 -0800 (PST) X-Google-Smtp-Source: AJdET5f4mbFaO6ku/ekWtZfVf0lqx3kYmnHO53KD2xffMrTaTQ9rljBr96iJSUM6uLoqywfkHGGm X-Received: by 2002:a17:902:1105:: with SMTP id d5-v6mr17057692pla.28.1541948504149; Sun, 11 Nov 2018 07:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541948504; cv=none; d=google.com; s=arc-20160816; b=QFnNrJ99xh4D8vezdt8Ougz6nBckQgJUCZITrFNhXpGthE9zJFUQTuodpXw/z3rD62 +EanLSjXdeAeZuk2Up+ptKMMBKrKNmqm64SMLkn5SHoIaiMbRGjsZjth2fzl/wf5c+XU A7ZDNZYg66CCBey+8eC65Gh/yPa2TAcnBgW2jKEifGis21QYT6vPVBwRPZAA2H7LAajo /By8G+9h6LEOSsq5spljK6eD0PaJPddFO4AUA+3fQpVJr3l/drkqECvoWuSNpjGOtUeo 11s7G3x86YeL6xvgcyqvklyyjzod2IpTibYFqEOIDWJFTVmBqKBznpxnG2s04M4hGf2q OCYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=qAkZBofw5H1C8HzfEHSsBJfso/xMo+VN2B/NBJcBaaQ=; b=t42L1nhTELaN55HkDohbGpqUWKwfkFBkbGOTXeqK4Wssw/yQTtBH2wUnjNnYqnFC1Y 7VdHUYM5ydaII+GTtKB2TXZYTQmIQtw2AwM7ewCG3o92ARYRlgryHk5PweTCmuzPfq++ FXelWA+xfe19TMdx6L+KY9iVl1OpMGtF0HRsv5FCNiw3vmK9x103bFtCct+vzgwRA26z Mgj123M61kM7BngK6mKoEcT1SqlC/b7ZRbuut13dcusp52rXpiGHbITtftjfzxGZ3akW SdPBm9xci97j/H7uq9oDIiTW/AgOByAn8f3UH5DwoxBkwi+tHd2/u7mQqKHEob2BFSti vvzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WSGH1YeT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a128-v6si15777730pfb.24.2018.11.11.07.01.26; Sun, 11 Nov 2018 07:01:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WSGH1YeT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728624AbeKLAtI (ORCPT + 99 others); Sun, 11 Nov 2018 19:49:08 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35322 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728585AbeKLAtI (ORCPT ); Sun, 11 Nov 2018 19:49:08 -0500 Received: by mail-lf1-f66.google.com with SMTP id e26so2651264lfc.2 for ; Sun, 11 Nov 2018 07:00:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qAkZBofw5H1C8HzfEHSsBJfso/xMo+VN2B/NBJcBaaQ=; b=WSGH1YeTiGFmDbCRwakmHKatuN3aS1Tgy9KsSqYqETfHTceA1XxMBeCwxgqnzTI34h klRquBqmB7bsyVQorKxo/M83eW2dfzFTfmn/eIHT2xHl0Lt1NOxnPKtNRbkqCE/58SQk cXEwyFHr0r0f7zw5zs8qyBz4tX/O4sMmDUH2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qAkZBofw5H1C8HzfEHSsBJfso/xMo+VN2B/NBJcBaaQ=; b=IQxGSfAEfpRD6LmDQVpTHHGnn75tEvehYZU5RDvonHLE1XcpFr3+lLkz0wDLS1oegN vyDntxpkL7qSdXJwBwj9qXAF4eUlqqTJqrmwl6jru90qMZu4c9VDrgQuOaOYtbQM1NUv rUQUBy2CAWJhKlwHEx5S8MYnHsAHC5J2dt3LJuPdZcEb7c3rqoCuJAXo5FVAOH7PZOt+ BtVs5XYjmUaVATx6QAMQbF9EPDP4wrdMWhcTXExxKqh1DS7Qruo2pajJrLk37eA7VeE5 /3UBJ6MYQWqlEeLx5xt2tuQeTFnDxFY60x6mAxz5EYGpEpNeLcCbPwIg16tjkpfmcB7e vx8Q== X-Gm-Message-State: AGRZ1gJ8CFKYoU3uLDt0SSOFebnVnMw45zkejveeaAfXurPKuVT4qoFk oasTPlDGLBwDUB6Fa+8l0wCmbAaygkNF/l1SHMedPw== X-Received: by 2002:a19:ca51:: with SMTP id h17mr8835126lfj.126.1541948419254; Sun, 11 Nov 2018 07:00:19 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a2e:95ca:0:0:0:0:0 with HTTP; Sun, 11 Nov 2018 07:00:18 -0800 (PST) In-Reply-To: <20181111124044.52f61897@archlinux> References: <208f9043fbd9b14b7a0c2743f68fa424388f5dcd.1541733478.git.baolin.wang@linaro.org> <20181111124044.52f61897@archlinux> From: Baolin Wang Date: Sun, 11 Nov 2018 23:00:18 +0800 Message-ID: Subject: Re: [PATCH] iio: adc: sc27xx: Add ADC data conversion timeout To: Jonathan Cameron Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , freeman.liu@unisoc.com, Mark Brown , linux-iio@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, On 11 November 2018 at 20:40, Jonathan Cameron wrote: > 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 for your review. This patch is not one bug fix, just make the code more robust in case of some bad cases. So I think we do not need the stable tag. > > 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, > -- Baolin Wang Best Regards