From patchwork Fri Jan 27 06:32:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pramod Gurav X-Patchwork-Id: 9540627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 80FCA60415 for ; Fri, 27 Jan 2017 06:32:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7255927F8F for ; Fri, 27 Jan 2017 06:32:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 669C327F9F; Fri, 27 Jan 2017 06:32:24 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E276327F8F for ; Fri, 27 Jan 2017 06:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753898AbdA0GcM (ORCPT ); Fri, 27 Jan 2017 01:32:12 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:35951 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753998AbdA0GcK (ORCPT ); Fri, 27 Jan 2017 01:32:10 -0500 Received: by mail-pf0-f182.google.com with SMTP id 189so71313928pfu.3 for ; Thu, 26 Jan 2017 22:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=nasBhU7sC5JWt/UVe2iL/35g/wutzNvkB7CjlbH2M6A=; b=Ywi3E5WDdK94b2Zf/H5zEX4re1SdM/5T16BFFY0LdcP5iZJjZxwWW1G0rLGJxtgvv7 nbJkpy36dRKgoHKX7wkMfPNEMLiztsb5w4qoXi5N85c2g9dAZsYLWL4cngwKp99hugbE A2+qHuExiUEWTn9//uj6YmLSwiUywCPgJvU4A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nasBhU7sC5JWt/UVe2iL/35g/wutzNvkB7CjlbH2M6A=; b=PEHll+fj4hdoIwPYtgjh+ETLcfb9P5sTGFFit3qx/XB+CnMzcHWdGK32hQKb/ocMH1 nq4q8QKr5yYzy6KGrVWgpszsvV+8wVG1iUl58l54eJbxoPNtsiA8fuoI1ODhw2cTeDhN B9kP9I0DrdZrrrt3JM1YzUlJelknVsrlJmLDwnraBWS80dMZNsXsWnztT8KHxQosU+HP Dd00vVp64WFYVCSNZqWQ0aWtXGpJ6wtDABsiKxBKXRiiqtivLp5iOmVBq/vDnl+r8I/K REosGPtlVzfiAF0kJFCwxB/HvYFUUAuEUxnD4NEsJLFZILZWugKtnsXk2l/F+7Z4DKMg s+Ew== X-Gm-Message-State: AIkVDXK2I01CbMzCkXBdE7ad+Ztg+RJ+OVUEeATobiUwwcvEbRqZrWYk/SGExj189JVFiz4E X-Received: by 10.98.18.75 with SMTP id a72mr7356952pfj.16.1485498729609; Thu, 26 Jan 2017 22:32:09 -0800 (PST) Received: from blr-ubuntu-56.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id b75sm7847411pfb.90.2017.01.26.22.32.06 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Jan 2017 22:32:09 -0800 (PST) From: Pramod Gurav To: broonie@kernel.org, linux-spi@vger.kernel.org Cc: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Pramod Gurav Subject: [PATCH] spi: qup: Fix runtime and system PM callbacks. Date: Fri, 27 Jan 2017 12:02:01 +0530 Message-Id: <20170127063201.13529-1-pramod.gurav@linaro.org> X-Mailer: git-send-email 2.10.2 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The SPI clocks were being turned on every suspend/resume cycle. This was increamenting the prepare/enable count after every resume. Fix the same. Signed-off-by: Pramod Gurav --- Tested on db410c drivers/spi/spi-qup.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c index 1bfa889..a9731e8 100644 --- a/drivers/spi/spi-qup.c +++ b/drivers/spi/spi-qup.c @@ -956,8 +956,10 @@ static int spi_qup_pm_resume_runtime(struct device *device) return ret; ret = clk_prepare_enable(controller->cclk); - if (ret) + if (ret) { + clk_disable_unprepare(controller->iclk); return ret; + } /* Disable clocks auto gaiting */ config = readl_relaxed(controller->base + QUP_CONFIG); @@ -983,8 +985,7 @@ static int spi_qup_suspend(struct device *device) return ret; if (!pm_runtime_suspended(device)) { - clk_disable_unprepare(controller->cclk); - clk_disable_unprepare(controller->iclk); + pm_runtime_put(device); } return 0; } @@ -995,18 +996,17 @@ static int spi_qup_resume(struct device *device) struct spi_qup *controller = spi_master_get_devdata(master); int ret; - ret = clk_prepare_enable(controller->iclk); - if (ret) - return ret; - - ret = clk_prepare_enable(controller->cclk); - if (ret) + ret = pm_runtime_get_sync(device); + if (ret < 0) { + dev_err(device, "pm runtime failed in resume\n"); return ret; + } ret = spi_qup_set_state(controller, QUP_STATE_RESET); if (ret) return ret; + pm_runtime_put(device); return spi_master_resume(master); } #endif /* CONFIG_PM_SLEEP */