From patchwork Mon Oct 24 11:29:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9117 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp456192wru; Mon, 24 Oct 2022 06:33:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6RIcsjytPwYw4tPDxDHQXpfmQ9s3S36s98SPF/HxVbr5V9lRNL7AH+QB0V/j2MINk9LPgu X-Received: by 2002:a17:90b:3901:b0:20b:210d:d5d9 with SMTP id ob1-20020a17090b390100b0020b210dd5d9mr37083908pjb.83.1666618413656; Mon, 24 Oct 2022 06:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618413; cv=none; d=google.com; s=arc-20160816; b=G2JXvsSp7dyAFIn2d9YeLVSZb2247dCK6G/6lkqxsn8TMJETin1os21SIU9g1EnIJd 8ybZUk3+9qqmBS6hwjPIQaKV56srBhBosJcHrPSZRiQLVlFSoYycHpvBkopUb+UH1Vez VEcQQSW/DRhPJyivkcGqu76BaMWjxYzLVMJFugDI6bi73VuBeX1U7+Jj3QYnnI+Y+boI F/oz/6YbmW1AHSaF97ur1kungMKLuDFJpNS6kNLg4Rx1/EYhVfId/7+tg98ZHXB46gBl Hh8QoNuJ6QTN/jfXUqjkF/9RFfdl4TK74Gys0ub5wbA71zt0usFD8mq+rbfsZY/JpQT7 kTfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hA5NASstklLUTD+b+NZQz0HPEGaw7HYzpyYFD6qwKrA=; b=xgULkzUJ9iAFvZRYt7EI72hHId5+L3FAa7zkCod0zqLS87mXTWxql1nq52cMubwwER Tf73XDgadwhQV656VT08cy2P8QzJot1dX2EKzGrTb1eTO++fh2FeFlfpBkK1O33OtgxF 6nrkyN8AnnyDHvEESR4n1yRpjLH7K6lks8IVmCnW6VO/lBzRbzSJjlMcH1HXRnJ4bhsT 5RYO6MlXw4zcxWgyVTXM2iAicwPIaJr4+yn7zX5yxI9310xvOisQgZWhBfaDNPeZPEEC pj26Q3RCmvvLEIhW9D2W7VO67RK3VS4ss+Z8cLwdFJpKu/I9IkZ40kq1hwsNdNCWaArO SuWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jkfDjagW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020a62ee08000000b00557e3e7c420si22044880pfi.213.2022.10.24.06.33.19; Mon, 24 Oct 2022 06:33:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jkfDjagW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235862AbiJXNRI (ORCPT + 99 others); Mon, 24 Oct 2022 09:17:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235825AbiJXNPo (ORCPT ); Mon, 24 Oct 2022 09:15:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA395B13E; Mon, 24 Oct 2022 05:26:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7127E612A0; Mon, 24 Oct 2022 12:25:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86A7CC433C1; Mon, 24 Oct 2022 12:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614331; bh=c1UlfST0IreGSVgy1VtrSqlHFdH8zsS8igVObdDVohA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jkfDjagW7skjLdP6F11f+6sGGAQ+6BWoAVyusBvs9zN8x3Uh03i019giuTkrTlBBs u55xvOvPF+c3NgS5w0ZmtuRO1PcVLjqZpxMxe84BGVw8puoT9EQUTbMfYiwC/Q8GAK R0gHAJJpWLD2KuDffW2n/zGYZZgc+SZv9WasVw3o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudiu Beznea , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.10 188/390] iio: adc: at91-sama5d2_adc: disable/prepare buffer on suspend/resume Date: Mon, 24 Oct 2022 13:29:45 +0200 Message-Id: <20221024113030.767076920@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747576069803646415?= X-GMAIL-MSGID: =?utf-8?q?1747576069803646415?= From: Claudiu Beznea [ Upstream commit 808175e21d9b7f866eda742e8970f27b78afe5db ] In case triggered buffers are enabled while system is suspended they will not work anymore after resume. For this call at91_adc_buffer_postdisable() on suspend and at91_adc_buffer_prepare() on resume. On tests it has been seen that at91_adc_buffer_postdisable() call is not necessary but it has been kept because it also does the book keeping for DMA. On resume path there is no need to call at91_adc_configure_touch() as it is embedded in at91_adc_buffer_prepare(). Fixes: 073c662017f2f ("iio: adc: at91-sama5d2_adc: add support for DMA") Signed-off-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220803102855.2191070-5-claudiu.beznea@microchip.com Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/adc/at91-sama5d2_adc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index ef6dc85024c1..250b78ee1625 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1907,6 +1907,9 @@ static __maybe_unused int at91_adc_suspend(struct device *dev) struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); + if (iio_buffer_enabled(indio_dev)) + at91_adc_buffer_postdisable(indio_dev); + /* * Do a sofware reset of the ADC before we go to suspend. * this will ensure that all pins are free from being muxed by the ADC @@ -1950,14 +1953,11 @@ static __maybe_unused int at91_adc_resume(struct device *dev) if (!iio_buffer_enabled(indio_dev)) return 0; - /* check if we are enabling triggered buffer or the touchscreen */ - if (at91_adc_current_chan_is_touch(indio_dev)) - return at91_adc_configure_touch(st, true); - else - return at91_adc_configure_trigger(st->trig, true); + ret = at91_adc_buffer_prepare(indio_dev); + if (ret) + goto vref_disable_resume; - /* not needed but more explicit */ - return 0; + return at91_adc_configure_trigger(st->trig, true); vref_disable_resume: regulator_disable(st->vref);