From patchwork Mon Jul 31 12:56:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 109022 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp189339qge; Mon, 31 Jul 2017 05:58:57 -0700 (PDT) X-Received: by 10.84.229.136 with SMTP id c8mr17694789plk.351.1501505937217; Mon, 31 Jul 2017 05:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501505937; cv=none; d=google.com; s=arc-20160816; b=kAKln+akZeFvlmUXLYeGbetz1PX+1ed3P95xkoQKPt28+cfDSo0jbg881F8TWODAKs KD7igAk7w/jewhzp9Dc3RGRymqE4BtILpcSYKNGyIV6xtG3JabCpovworDQUjAVHrs5l 1hVmREaAa+5ggbY1socX5flmnpqo0DuUozkBnOaX28N2D6m11AF25j4fPYnaqi5tVfYo 8gXQ7KbUqLhfjAf27VpjeD281txXFUOp+ijNFo+un1z/OYuC143LLWOzQqEPP/wBTqmn VGToCD9p2duxvRVNMaH8kpgTr9GEBzPGBlVLSV6hnsp3kFgez1fbW/M7TTLGNqHt0C4m owUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=DYQjXyA+2fs/Rryq9oGCtsYhd+bEGPaY/abmf4NAoYA=; b=KxQlCg7j9s/Ze/WSCQEblPx9l/5F4eAOpnfdD+eA6QWlmy8VFH8pFf10As195Ev+rx CE5O2fT4OMiHFwmzUWyjV2XIbuXKSSFuoHB0RGEcFCCRzwxN6AbmdQMVQjTO/T5Sjvua qCeBKKaNjKVOXEzYM4g86vFfCZt0KyjgB5EnCiK/+prKd4XRzbXMA6wFPYvxMoJHMMY/ 0Izz823UmU/uPC4antiZMCTBbz4PAjno4N/Vt4OQ/c3fu7okku5+3qXXAxFKt8e4drbm CtEEF04bIRBSbdhi0mxpXrLjnJT9woLQ6T/9L7iTKNRDGwecyW6EXD8hP9GiecDuV4DG DSEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.b=b0jwR/5y; 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 s19si15998070pfj.461.2017.07.31.05.58.56; Mon, 31 Jul 2017 05:58:57 -0700 (PDT) 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; dkim=pass header.i=@nifty.com header.b=b0jwR/5y; 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 S1752267AbdGaM6y (ORCPT + 26 others); Mon, 31 Jul 2017 08:58:54 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:53527 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752231AbdGaM6x (ORCPT ); Mon, 31 Jul 2017 08:58:53 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v6VCvU8w019404; Mon, 31 Jul 2017 21:57:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v6VCvU8w019404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1501505854; bh=DYQjXyA+2fs/Rryq9oGCtsYhd+bEGPaY/abmf4NAoYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0jwR/5yChbHCJ90pHwaIzhb83zJNzhSPhjI5J+Ng08JjjnKaZ92ekYvXIhCzMwKF ySc/+/5hQOKtcGvTP91viWdxBWxPPVCAeZC8IYkMfdPYxQorxG7q56Cm6C3B5EFsbn zFUibbF3nwQJsSpXrf3BgmsbeCJaFET5keHeDMEFl8GzmgDVhLIO3H/2+UMXnbpdtS gNbMyhpLu41BtGgiC6iOxPSC9KcCkOio3zuSAYmKX2y4kdt9fTb8zs6DTrIbV4BvHv w5yW01XLwkqNhF+vUlRRaca0K/i2NinAfEJ4kD9zGQAD5R1yE6OZgnBcSv6aU1rIAT f7OwugxK+FAag== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mmc@vger.kernel.org Cc: Piotr Sroka , Adrian Hunter , Masahiro Yamada , Al Cooper , linux-kernel@vger.kernel.org, Brian Norris , bcm-kernel-feedback-list@broadcom.com, Barry Song , Florian Fainelli , Gregory Fong , linux-arm-kernel@lists.infradead.org, Ulf Hansson Subject: [PATCH 1/3] mmc: sdhci: enable/disable the clock in sdhci_pltfm_suspend/resume Date: Mon, 31 Jul 2017 21:56:47 +0900 Message-Id: <1501505809-393-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501505809-393-1-git-send-email-yamada.masahiro@socionext.com> References: <1501505809-393-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit provides similar cleanups as commit 83eacdfa2529 ("mmc: sdhci: disable the clock in sdhci_pltfm_unregister()") did for unregister hooks. Some drivers duplicate code to handle pltfm_host->clk in their own hooks. The clock can be handled in sdhci_pltfm.c so that drivers can reuse sdhci_pltfm_pmops. Signed-off-by: Masahiro Yamada --- drivers/mmc/host/sdhci-brcmstb.c | 37 +------------------------------------ drivers/mmc/host/sdhci-pltfm.c | 16 +++++++++++++++- drivers/mmc/host/sdhci-sirf.c | 39 +-------------------------------------- 3 files changed, 17 insertions(+), 75 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index e2f638338e8f..6d461fcdd663 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -21,41 +21,6 @@ #include "sdhci-pltfm.h" -#ifdef CONFIG_PM_SLEEP - -static int sdhci_brcmstb_suspend(struct device *dev) -{ - struct sdhci_host *host = dev_get_drvdata(dev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - int res; - - if (host->tuning_mode != SDHCI_TUNING_MODE_3) - mmc_retune_needed(host->mmc); - - res = sdhci_suspend_host(host); - if (res) - return res; - clk_disable_unprepare(pltfm_host->clk); - return res; -} - -static int sdhci_brcmstb_resume(struct device *dev) -{ - struct sdhci_host *host = dev_get_drvdata(dev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - int err; - - err = clk_prepare_enable(pltfm_host->clk); - if (err) - return err; - return sdhci_resume_host(host); -} - -#endif /* CONFIG_PM_SLEEP */ - -static SIMPLE_DEV_PM_OPS(sdhci_brcmstb_pmops, sdhci_brcmstb_suspend, - sdhci_brcmstb_resume); - static const struct sdhci_ops sdhci_brcmstb_ops = { .set_clock = sdhci_set_clock, .set_bus_width = sdhci_set_bus_width, @@ -131,7 +96,7 @@ MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match); static struct platform_driver sdhci_brcmstb_driver = { .driver = { .name = "sdhci-brcmstb", - .pm = &sdhci_brcmstb_pmops, + .pm = &sdhci_pltfm_pmops, .of_match_table = of_match_ptr(sdhci_brcm_of_match), }, .probe = sdhci_brcmstb_probe, diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index e090d8c42ddb..be9a79d62e22 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -212,16 +212,30 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister); static int sdhci_pltfm_suspend(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + int ret; if (host->tuning_mode != SDHCI_TUNING_MODE_3) mmc_retune_needed(host->mmc); - return sdhci_suspend_host(host); + ret = sdhci_suspend_host(host); + if (ret) + return ret; + + clk_disable_unprepare(pltfm_host->clk); + + return 0; } static int sdhci_pltfm_resume(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + int ret; + + ret = clk_prepare_enable(pltfm_host->clk); + if (ret) + return ret; return sdhci_resume_host(host); } diff --git a/drivers/mmc/host/sdhci-sirf.c b/drivers/mmc/host/sdhci-sirf.c index c251c6c0a112..dd4680a0ada4 100644 --- a/drivers/mmc/host/sdhci-sirf.c +++ b/drivers/mmc/host/sdhci-sirf.c @@ -230,43 +230,6 @@ static int sdhci_sirf_probe(struct platform_device *pdev) return ret; } -#ifdef CONFIG_PM_SLEEP -static int sdhci_sirf_suspend(struct device *dev) -{ - struct sdhci_host *host = dev_get_drvdata(dev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - int ret; - - if (host->tuning_mode != SDHCI_TUNING_MODE_3) - mmc_retune_needed(host->mmc); - - ret = sdhci_suspend_host(host); - if (ret) - return ret; - - clk_disable(pltfm_host->clk); - - return 0; -} - -static int sdhci_sirf_resume(struct device *dev) -{ - struct sdhci_host *host = dev_get_drvdata(dev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - int ret; - - ret = clk_enable(pltfm_host->clk); - if (ret) { - dev_dbg(dev, "Resume: Error enabling clock\n"); - return ret; - } - - return sdhci_resume_host(host); -} -#endif - -static SIMPLE_DEV_PM_OPS(sdhci_sirf_pm_ops, sdhci_sirf_suspend, sdhci_sirf_resume); - static const struct of_device_id sdhci_sirf_of_match[] = { { .compatible = "sirf,prima2-sdhc" }, { } @@ -276,7 +239,7 @@ MODULE_DEVICE_TABLE(of, sdhci_sirf_of_match); static struct platform_driver sdhci_sirf_driver = { .driver = { .name = "sdhci-sirf", - .of_match_table = sdhci_sirf_of_match, + .of_match_table = sdhci_pltfm_pmops, .pm = &sdhci_sirf_pm_ops, }, .probe = sdhci_sirf_probe, From patchwork Mon Jul 31 12:56:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 109021 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp188967qge; Mon, 31 Jul 2017 05:58:26 -0700 (PDT) X-Received: by 10.98.236.137 with SMTP id e9mr4803739pfm.159.1501505906154; Mon, 31 Jul 2017 05:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501505906; cv=none; d=google.com; s=arc-20160816; b=Zh8t/p4/heCa/MGbH01x1r8vS0UGQry3glIhi5amezjNyZRJMoVkWdtu1Jo42spMop eMyR5lyGOQDFe+4o82W9zr6EYokQHTfHQH+luglSKyQlZEDKQ63A+ASbPRr+5FoHamtk KG1gt3Fi3GNHrEhRMDpDBUeSlRgthhBfeENVnvoY4rCR4Ankact2lwO4D2scbon9nUv+ YOipHeuufgZ4v3sdKWRT7+u8A1eFczW5vX0AxjdT5yR3jiDWx/U3edru3BrzoboBMjb5 FYZ1QL+gAJ1W03N5/C7NbHIUe/pPgLLFEP5T9LYMTypmJkQ6pv8P14kFol7LNF6f//MW E1Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=Yr/OpvPGZ8t9RddJ3zxwF5Nm/Ty4RkqJFBLUno9FOAM=; b=qPgLOAHKF2CxZTcLQgEfcq26bqFQkAqrgMU5le4Z3KHs9Y2SDXHDxgTK4weQ+H8KVL jDGbcg8bQZqRsuPn1ffuMium0YL3ZCEEWVCyB9W1XDb2tUoN9kIdCBxwg/b4AAsnXM3v yQMse+xlHmH0IxQ1e7BqylzywEsGbxNeouA/mhsYJ1RriK5nkRhs8rUYRDa16fx81z+8 LiwrO8qKP+Ff4Er3sfuqVN9oEQTjN6yP5O/omP+v1kXNYsI0TX8prPLGmtS198v12rLW mhn241Mxd0LfjIfqaYl0EM029jrOOClorhmDg0EcXoQ2lvWA/uXE/d1N8DKq5BnNP+Uy YA/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.b=Ci46y/5t; 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 h7si11313893pln.778.2017.07.31.05.58.25; Mon, 31 Jul 2017 05:58:26 -0700 (PDT) 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; dkim=pass header.i=@nifty.com header.b=Ci46y/5t; 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 S1752220AbdGaM6X (ORCPT + 26 others); Mon, 31 Jul 2017 08:58:23 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:52618 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784AbdGaM6U (ORCPT ); Mon, 31 Jul 2017 08:58:20 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id v6VCvU8x019404; Mon, 31 Jul 2017 21:57:34 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com v6VCvU8x019404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1501505855; bh=Yr/OpvPGZ8t9RddJ3zxwF5Nm/Ty4RkqJFBLUno9FOAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ci46y/5tD4buiAH2g1ADCEm1Q2ZmtfefaFame40kmEBRzAWx6Z95i7/iNw7WbwmmO 43Mep4HxR3NCW9uxZbe0KCOrPHg3YroBjYqU+n/YXTYxKwjHF/GhLA76Uo9gGUfiAq gQAgFfM8FSDeGBy2WdhlmIbfFClobFyjfzztVysc/svYum+o/rT4GgZflwwMIhYs6C FVfhNA/uoZJIldz67TTKmJz2erZAPiSu2BpOc8Iqk1DmLgMGd8ajojBSbY91kzhaai oKSXZEYjIwfx0DWWSOx8VIFvrgNmEIsWSzTwsJllFoNWIoQ0eKRZ5rHz4QLqdM1al6 ESxqe8LAnAiTw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mmc@vger.kernel.org Cc: Piotr Sroka , Adrian Hunter , Masahiro Yamada , linux-kernel@vger.kernel.org, Ulf Hansson Subject: [PATCH 2/3] mmc: sdhci-pltfm: export sdhci_pltfm_suspend/resume Date: Mon, 31 Jul 2017 21:56:48 +0900 Message-Id: <1501505809-393-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501505809-393-1-git-send-email-yamada.masahiro@socionext.com> References: <1501505809-393-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be useful when drivers want to reuse only the suspend/resume callbacks instead of whole of sdhci_pltfm_pmops. Signed-off-by: Masahiro Yamada --- drivers/mmc/host/sdhci-pltfm.c | 6 ++++-- drivers/mmc/host/sdhci-pltfm.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c index be9a79d62e22..a34eacac612f 100644 --- a/drivers/mmc/host/sdhci-pltfm.c +++ b/drivers/mmc/host/sdhci-pltfm.c @@ -209,7 +209,7 @@ int sdhci_pltfm_unregister(struct platform_device *pdev) EXPORT_SYMBOL_GPL(sdhci_pltfm_unregister); #ifdef CONFIG_PM_SLEEP -static int sdhci_pltfm_suspend(struct device *dev) +int sdhci_pltfm_suspend(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -226,8 +226,9 @@ static int sdhci_pltfm_suspend(struct device *dev) return 0; } +EXPORT_SYMBOL_GPL(sdhci_pltfm_suspend); -static int sdhci_pltfm_resume(struct device *dev) +int sdhci_pltfm_resume(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -239,6 +240,7 @@ static int sdhci_pltfm_resume(struct device *dev) return sdhci_resume_host(host); } +EXPORT_SYMBOL_GPL(sdhci_pltfm_resume); #endif const struct dev_pm_ops sdhci_pltfm_pmops = { diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h index 957839d0fe37..1e91fb1c020e 100644 --- a/drivers/mmc/host/sdhci-pltfm.h +++ b/drivers/mmc/host/sdhci-pltfm.h @@ -109,6 +109,8 @@ static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host) return host->private; } +int sdhci_pltfm_suspend(struct device *dev); +int sdhci_pltfm_resume(struct device *dev); extern const struct dev_pm_ops sdhci_pltfm_pmops; #endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */