Received: by 10.223.176.5 with SMTP id f5csp1408199wra; Sun, 28 Jan 2018 00:20:07 -0800 (PST) X-Google-Smtp-Source: AH8x226dk27yHKI/SX59scFioO+1dC5mKuFRYbnlgwCcjDJZFmsSOuCZUAA9oBL5yAs1dY8onXkx X-Received: by 10.98.0.194 with SMTP id 185mr6362102pfa.63.1517127607527; Sun, 28 Jan 2018 00:20:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517127607; cv=none; d=google.com; s=arc-20160816; b=T4PM0iR/e8C/M6fuN48o5pTQu/NMWUP6SK3ZyPY1lxPfEl5Phi8H8Kwj0gVihR9ZVS ifR8DExhGJPqobqXKGH/b3ybDAl9WpqkngP5ICId4GG3+2oyAOHGGYg1+V5FpIFTY+5V hMwa7fkLQTmgqz+2DXmYc/Hap45PtU8v25B4BOWUYEk9pZ7i8SyI2yGVQYKwnBKw2rUM u0uaZmJbw74spWcxZtMjK20kkIX7SMMe+Zx2s1WHhx4XpVQ0gk2MwGunATUHM2pBP+PP r5IP2trE9SGZl+T4dbTQhOTN612gAPyIYGnZqU9fzf3zTkIZ9qEPqZdh9Wcdt15a1yLx k64w== 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:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=cxh+ab1M5CIT2zp6RqSE7MoeSaLjLHtPu96fNBXJ6XU=; b=XH7MJk8UcvpidLJbNcKffbEXoV7Symye2DnGAzsePUgRoFGGJgHX88MnKijYuvSsKd VeZvOYhdEzGRSiiY0CZHYS2LSguKhVfeIVlo05OLbik4M+bcRRp14H78IJ5CZDnaNwPn VsSMasK8nxuafAw/7NOMQIeWBvisRFIlqcLiz1iBuc7M3OBj/wX2mChiCb24JdzshO7a /JMG1YfOxnEOmo3vnyk0YXWCX43il44MhPweSA3vInC7vLLLtjY+2L9TLxbVFHs/Lqlc WOeBZPTsRAmzf97N6PTvTnn3gv8+Q8VVlKjHpZvUBlLXmXZ5zY1zmWGA+Hd0ysIBdg9H YtvQ== 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 j21si9284863pfe.97.2018.01.28.00.19.51; Sun, 28 Jan 2018 00:20:07 -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; 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 S1752085AbeA1IT3 (ORCPT + 99 others); Sun, 28 Jan 2018 03:19:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:34930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbeA1IT1 (ORCPT ); Sun, 28 Jan 2018 03:19:27 -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 65EEA21759; Sun, 28 Jan 2018 08:19:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65EEA21759 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jic23@kernel.org Date: Sun, 28 Jan 2018 08:19:25 +0000 From: Jonathan Cameron To: Fabrice Gasnier Cc: , , , , , , , Subject: Re: [PATCH] iio: adc: stm32: fix stm32h7_adc_enable error handling Message-ID: <20180128081925.524a3e08@archlinux> In-Reply-To: <1516723497-9018-1-git-send-email-fabrice.gasnier@st.com> References: <1516723497-9018-1-git-send-email-fabrice.gasnier@st.com> X-Mailer: Claws Mail 3.16.0 (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 Tue, 23 Jan 2018 17:04:56 +0100 Fabrice Gasnier wrote: > Error handling in stm32h7_adc_enable routine doesn't unwind enable > sequence correctly. ADEN can only be cleared by hardware (e.g. by > writing one to ADDIS). > It's also better to clear ADRDY just after it's been set by hardware. > > Fixes: 95e339b6e85d ("iio: adc: stm32: add support for STM32H7") > > Signed-off-by: Fabrice Gasnier Applied to fixes-togreg-post-rc1 branch of iio.git and marked for stable. Thanks, Jonathan > --- > drivers/iio/adc/stm32-adc.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c > index ca3b865..8177a92 100644 > --- a/drivers/iio/adc/stm32-adc.c > +++ b/drivers/iio/adc/stm32-adc.c > @@ -735,8 +735,6 @@ static int stm32h7_adc_enable(struct stm32_adc *adc) > int ret; > u32 val; > > - /* Clear ADRDY by writing one, then enable ADC */ > - stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY); > stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN); > > /* Poll for ADRDY to be set (after adc startup time) */ > @@ -744,8 +742,11 @@ static int stm32h7_adc_enable(struct stm32_adc *adc) > val & STM32H7_ADRDY, > 100, STM32_ADC_TIMEOUT_US); > if (ret) { > - stm32_adc_clr_bits(adc, STM32H7_ADC_CR, STM32H7_ADEN); > + stm32_adc_set_bits(adc, STM32H7_ADC_CR, STM32H7_ADDIS); > dev_err(&indio_dev->dev, "Failed to enable ADC\n"); > + } else { > + /* Clear ADRDY by writing one */ > + stm32_adc_set_bits(adc, STM32H7_ADC_ISR, STM32H7_ADRDY); > } > > return ret;