Received: by 10.223.185.116 with SMTP id b49csp4192348wrg; Mon, 26 Feb 2018 12:55:44 -0800 (PST) X-Google-Smtp-Source: AG47ELuY5TKK6W8SgJIhR7NtBzDcj4hMtUgapUB5I1swvEpnb0fK0dOdaM7fY3e8hC9Mid6+JDaL X-Received: by 10.101.76.134 with SMTP id m6mr975502pgt.445.1519678544513; Mon, 26 Feb 2018 12:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519678544; cv=none; d=google.com; s=arc-20160816; b=O4tpRZCk7EzfGpSuiFqgtC5kbSwwzRGVup3gyhloSXkdCFGAp4hWhqxC9w57gLS1p8 EL9mHx9X5AVsYQlJ4d6W390K2UDfMzWSu4f891+N+E+rCJLGCz3W5ea0lPusD4WLOBBZ ktbc9uRb1K0Dt1ox5rRzWbgXo8taNk3WiasgfunMOtZ6ixZ2xWx/sQsBIY0E1Mtm8cQ/ hfIQ4ooqJFkqAS3kYVRnk0UBfbSRhIf4KjR5St2HZZmRVXsXVUKq9N5mvb4JVsvRm9QB toTCu+QCANctuTuX/UPSqaXAC4+cepA7zNlS+7Lxbtd+PR4rVY2Ffj3ATDcRKMaCiTao uUqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Nj9t3hySp4V9grbFqVBZ+iMgpP/aWdwMlyWLQNKiFB8=; b=YCrDKLvgE9yF5MabKceH5kqscVvHb5yLrpMQnSlIGRr07E7VrqHdlSJn61GGI/nYVV DHOKbj1JWuj/DiBG0EbtE6VKunGeeE8GnENjZzX2jWvY6R3J4YofjmqmwMfjJvbQO5wP s69FQ1egbgLWxoK01RkzDKPLfA5v5//d/uT6mK/pfElHL+0qyfhyCBHe41BsN4sW0DK+ ctAnSUvL32h7Sjc00LpoCmuUXtxqOjr3MInlknRU2tekNaQlZg2oI6twDu3VU7LVoRMj wegm7PBVYHwlrw9VNUbq5yf0oan38kinI2PElLd0XtxETu/jrD1eHowBsyeQ5xwIpab9 a2fQ== 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 o19si6012681pgn.180.2018.02.26.12.55.27; Mon, 26 Feb 2018 12:55: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; 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 S1752782AbeBZUX4 (ORCPT + 99 others); Mon, 26 Feb 2018 15:23:56 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34930 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752745AbeBZUXz (ORCPT ); Mon, 26 Feb 2018 15:23:55 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 673AEF4A; Mon, 26 Feb 2018 20:23:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabrice Gasnier , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 4.14 21/54] iio: adc: stm32: fix stm32h7_adc_enable error handling Date: Mon, 26 Feb 2018 21:21:58 +0100 Message-Id: <20180226202145.463670002@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202144.375869933@linuxfoundation.org> References: <20180226202144.375869933@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fabrice Gasnier commit a3b5655ebdb501a98a45c0d3265dca9f2fe0218a upstream. 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 Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/stm32-adc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -764,8 +764,6 @@ static int stm32h7_adc_enable(struct stm 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) */ @@ -773,8 +771,11 @@ static int stm32h7_adc_enable(struct stm 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;