From patchwork Tue Nov 6 11:20:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10670129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C92ED14BD for ; Tue, 6 Nov 2018 11:20:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A12BD29DBC for ; Tue, 6 Nov 2018 11:20:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94D722A02A; Tue, 6 Nov 2018 11:20:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B24C029DBC for ; Tue, 6 Nov 2018 11:20:37 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 717412678F2; Tue, 6 Nov 2018 12:20:35 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3C3002679F7; Tue, 6 Nov 2018 12:20:33 +0100 (CET) Received: from mail.bugwerft.de (mail.bugwerft.de [46.23.86.59]) by alsa0.perex.cz (Postfix) with ESMTP id 154CD2678DF for ; Tue, 6 Nov 2018 12:20:30 +0100 (CET) Received: from localhost.localdomain (unknown [195.37.61.178]) by mail.bugwerft.de (Postfix) with ESMTPSA id 76C6B2A6F61; Tue, 6 Nov 2018 11:18:10 +0000 (UTC) From: Daniel Mack To: broonie@kernel.org Date: Tue, 6 Nov 2018 12:20:20 +0100 Message-Id: <20181106112020.10901-1-daniel@zonque.org> X-Mailer: git-send-email 2.17.2 Cc: alsa-devel@alsa-project.org, Daniel Mack Subject: [alsa-devel] [PATCH] ASoC: pxa-ssp: make suspend call resilient against multiple invocations X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The suspend callback is called twice when the machine is suspended, once through the ASoC layer and once through the platform device layer. Make sure not to confuse the clock layer with unbalanced calls, and bail out early if we are already suspended. Signed-off-by: Daniel Mack --- sound/soc/pxa/pxa-ssp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index adcf8ba9d287..fd93706702a6 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c @@ -51,6 +51,7 @@ struct ssp_priv { uint32_t cr1; uint32_t to; uint32_t psp; + bool suspended; #endif }; @@ -142,6 +143,9 @@ static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai) struct ssp_priv *priv = snd_soc_dai_get_drvdata(cpu_dai); struct ssp_device *ssp = priv->ssp; + if (priv->suspended) + return 0; + if (!cpu_dai->active) clk_prepare_enable(ssp->clk); @@ -152,6 +156,8 @@ static int pxa_ssp_suspend(struct snd_soc_dai *cpu_dai) pxa_ssp_disable(ssp); clk_disable_unprepare(ssp->clk); + priv->suspended = true; + return 0; } @@ -161,6 +167,9 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai) struct ssp_device *ssp = priv->ssp; uint32_t sssr = SSSR_ROR | SSSR_TUR | SSSR_BCE; + if (!priv->suspended) + return 0; + clk_prepare_enable(ssp->clk); __raw_writel(sssr, ssp->mmio_base + SSSR); @@ -174,6 +183,8 @@ static int pxa_ssp_resume(struct snd_soc_dai *cpu_dai) else clk_disable_unprepare(ssp->clk); + priv->suspended = false; + return 0; }