Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3821243yba; Tue, 7 May 2019 07:37:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxcHb9+7YSRgILAAqae+KdRQjaYn+F4EtTPAj0jwRhAB+1Bwfk5ieuyC8AY0cgW3CcWktK X-Received: by 2002:a65:62cc:: with SMTP id m12mr40167204pgv.118.1557239869696; Tue, 07 May 2019 07:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557239869; cv=none; d=google.com; s=arc-20160816; b=zkx1KVc1OYOONePymrIlhKBXhK4wpXRg6CFaMaDsL1k9pfEvbuXX0/w2IX7hzvHFR0 C7xCOpq+Fpm2qbzdy0T31JNN/rpWIa922lvegdNoeQlQoxCpV/KbkD0+PXPjoJQ6dNWF rcRAhPogF8sRTEfYBVpJdxliQZ+q0VLR1gGAdlzgWoxwyDnMXxpGPm9Qw/MiP3RSdPXQ I64CototUH9orb4E42EdrJdEuquW3LeyT4Fm4dn3UxmLexQTSgD0eyQO3wgnb1eMuuL0 bXmRyKRCz5SNxhiU9M0z4PpOfaRu1f6ufRS/Z98RHsiIKg5bMePx4A6SuHMjL8ZOUwcb wt+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vCLSeyXXvBRR3T9RiW0X0rO+vL+M/OJkg2QqDMzroeg=; b=awXj+5Y8IW9IlNmyjX0tL+R3a365Q8FGXkUpHjpIRe+5L8daOFjUjYsfHj2ZPP1koY 3mQv4qhx51dTKTDc/udIats15ExosdQUJkzDE52ls+aHBCi29ruqCNK6EtQpK0fwF71O pbsbP8txJoPieg7edp/Zw7mjrvEJLVZd7ZS/Oi373V5qdpWgbFERifK9BDzxpSXOesxJ POOU6eFaoKodsX6o1ts/BoR7TVYnqqtAHr7MugL74ah+OhhC6e+nZDs3ScIqLcy4iA0V ZK6nm3308AU8inymG3uIPBmr8o2E+FanJfKXqcvNwVElkHgQ7qZa3/+/2fQj87EX/xfO OCYA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f22si19056148pgf.227.2019.05.07.07.37.33; Tue, 07 May 2019 07:37:49 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbfEGOg2 (ORCPT + 99 others); Tue, 7 May 2019 10:36:28 -0400 Received: from mxout012.mail.hostpoint.ch ([217.26.49.172]:63402 "EHLO mxout012.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbfEGOg0 (ORCPT ); Tue, 7 May 2019 10:36:26 -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 1hO1Ce-000454-QD; Tue, 07 May 2019 16:36:20 +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 1hO1Ce-0008oW-Jv; Tue, 07 May 2019 16:36:20 +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: Marcel Ziswiler , David Laight , 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/5] iio: stmpe-adc: Reinit completion struct on begin conversion Date: Tue, 7 May 2019 16:36:12 +0200 Message-Id: <20190507143615.28477-2-dev@pschenker.ch> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190507143615.28477-1-dev@pschenker.ch> References: <20190507143615.28477-1-dev@pschenker.ch> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 wrong adc-values returned in a following adc-readout. Reinitialise completion struct to make sure the counter is zero when beginning a new adc-conversion. Signed-off-by: Philippe Schenker --- drivers/iio/adc/stmpe-adc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 9ec338ba3440..b3872eb37293 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -65,6 +65,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info, mutex_lock(&info->lock); + reinit_completion(&info->completion); + info->channel = (u8)chan->channel; if (info->channel > STMPE_ADC_LAST_NR) { @@ -105,6 +107,8 @@ static int stmpe_read_temp(struct stmpe_adc *info, mutex_lock(&info->lock); + reinit_completion(&info->completion); + info->channel = (u8)chan->channel; if (info->channel != STMPE_TEMP_CHANNEL) { -- 2.21.0