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: 9540623 X-Patchwork-Delegate: agross@codeaurora.org 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 0E95260415 for ; Fri, 27 Jan 2017 06:32:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F26B527F8F for ; Fri, 27 Jan 2017 06:32:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E34A627F9F; Fri, 27 Jan 2017 06:32:12 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 6BDEE27F8F for ; Fri, 27 Jan 2017 06:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754018AbdA0GcL (ORCPT ); Fri, 27 Jan 2017 01:32:11 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:34395 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753898AbdA0GcK (ORCPT ); Fri, 27 Jan 2017 01:32:10 -0500 Received: by mail-pf0-f173.google.com with SMTP id e4so70987986pfg.1 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=LDvNPQFjp/kHFuLIQvWeKKnKEu5LK/2w0ovFk9LYC/fqZou2iVs8g3W5MwkLQ+d6zU T49pjLVmCzJtXM2OMyAaD8dYCmTglYQEvFUvbR6vqhuclylX2ZjTUG6dKATcMuQwir9t dTwKHRfNa0q73WUgO6epythkhDOmePLJ5NWGGd4NHdE6Wdn1yfNp6UbqYHGxeHfz48mt iOcJ1vxaAHjPE7hGT9pj/foCiSzSGrj9x7mWZWz9NlUP3rDVG1PEPMS36aj8wbzs1Gtb us4N/jC38kOonC8MCUokpuZDottcLtqDOzaPYYDC8f6PXxW36Hn2/EOIymHTbFphqhsj PpPg== X-Gm-Message-State: AIkVDXIskJFEX9mqfxuV8eTXmTd1NXaa8jVIykqZVFEH5FmrE8LigJZk18ZWfEmranybfeRZ 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 */