From patchwork Wed Jun 1 08:02:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9146281 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 2064560757 for ; Wed, 1 Jun 2016 08:07:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10C5622473 for ; Wed, 1 Jun 2016 08:07:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 055542654B; Wed, 1 Jun 2016 08:07:06 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 75B7122473 for ; Wed, 1 Jun 2016 08:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757667AbcFAIDO (ORCPT ); Wed, 1 Jun 2016 04:03:14 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:31126 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754341AbcFAIC6 (ORCPT ); Wed, 1 Jun 2016 04:02:58 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O83003BO2COU440@mailout1.w1.samsung.com>; Wed, 01 Jun 2016 09:02:48 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-4e-574e96a8aa62 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id BC.AB.05254.8A69E475; Wed, 1 Jun 2016 09:02:48 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O830012K2CGIS90@eusync3.samsung.com>; Wed, 01 Jun 2016 09:02:48 +0100 (BST) From: Krzysztof Kozlowski To: hzpeterchen@gmail.com, Ulf Hansson , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Krzysztof Kozlowski , Javier Martinez Canillas , linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-pm@vger.kernel.or, Alan Stern , linux-usb@vger.kernel.org, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Kukjin Kim , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz Subject: [PATCH v3 05/12] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix Date: Wed, 01 Jun 2016 10:02:14 +0200 Message-id: <1464768141-25420-6-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1464768141-25420-1-git-send-email-k.kozlowski@samsung.com> References: <1464768141-25420-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeLIzCtJLcpLzFFi42I5/e/4Vd0V0/zCDVrO81hsnLGe1WLSk/fM FvOPnGO1mLhyMrNF/5uFrBbNi9ezWXRd3cRmce7VSkaLN2/XMFm8fmFo0f/4NbPFpsfXWC0u 75rDZnHkfz+jxcyLq1ksZpzfx2SxaFkrs8XS6xeZLCZMX8ti0br3CLvF6d0lFhN+X2CzOL42 3EHcY828NYwel/t6mTx2zrrL7rFy+Rc2j80rtDw2repk87hzbQ+bx/65a9g9Ni+p99jSD1Qw ++4PRo++LasYPY58nc7i8XmTXABfFJdNSmpOZllqkb5dAlfGpL9TGQuWWFc8/LSVrYHxmVEX IyeHhICJxJFzv9khbDGJC/fWs3UxcnEICSxllFix8y0ThNPIJNG/YQcTSBWbgLHE5uVLwKpE BDrYJDZtfQPWziyQLXHq3ntWEFtYIEmic8d6sDiLgKrEs8OnmUFsXgF3iY7HE5kg1slJnDw2 GayeU8BD4sSE/4wgthBQTeO0yawTGHkXMDKsYhRNLU0uKE5KzzXUK07MLS7NS9dLzs/dxAiJ pC87GBcfszrEKMDBqMTDq3DRN1yINbGsuDL3EKMEB7OSCK/gZL9wId6UxMqq1KL8+KLSnNTi Q4zSHCxK4rxzd70PERJITyxJzU5NLUgtgskycXBKNTBWPK21Fzkt23/IdL/g5FWXhFt97Czv Msw+1dr+LzB73QWJmAMh2aoKFydoPf+ZFHmi+OJ3F9bri76UMjeXl0VXcF35bnHF1rrhxcPf 2bEXBZbv+Szys1Nh0/2HfE5ckzbZlZ7ri88uLnU6Eqg0/wAbX+TKDUwrt2//Yqmx8Qmj65oz LEF+U8qUWIozEg21mIuKEwGXdkaMoAIAAA== Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The power sequence hooks (mmc_pwrseq_pre_power_on(), mmc_pwrseq_post_power_on() and mmc_pwrseq_power_off()) can be made more generic to allow re-use in other subsystems. They do not need to take pointer to struct mmc_host but instead the struct pwrseq should be sufficient. Remove the "mmc" prefix and use the pointer to struct pwrseq as argument. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Javier Martinez Canillas --- drivers/mmc/core/core.c | 6 +++--- drivers/power/pwrseq/pwrseq.c | 24 +++++++++--------------- drivers/power/pwrseq/pwrseq_emmc.c | 6 ++---- drivers/power/pwrseq/pwrseq_simple.c | 14 ++++++-------- include/linux/pwrseq.h | 18 +++++++++--------- 5 files changed, 29 insertions(+), 39 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index edefc3fbebe6..09a4722f9037 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1719,7 +1719,7 @@ void mmc_power_up(struct mmc_host *host, u32 ocr) if (host->ios.power_mode == MMC_POWER_ON) return; - mmc_pwrseq_pre_power_on(host); + pwrseq_pre_power_on(host->pwrseq); host->ios.vdd = fls(ocr) - 1; host->ios.power_mode = MMC_POWER_UP; @@ -1740,7 +1740,7 @@ void mmc_power_up(struct mmc_host *host, u32 ocr) */ mmc_delay(10); - mmc_pwrseq_post_power_on(host); + pwrseq_post_power_on(host->pwrseq); host->ios.clock = host->f_init; @@ -1759,7 +1759,7 @@ void mmc_power_off(struct mmc_host *host) if (host->ios.power_mode == MMC_POWER_OFF) return; - mmc_pwrseq_power_off(host); + pwrseq_power_off(host->pwrseq); host->ios.clock = 0; host->ios.vdd = 0; diff --git a/drivers/power/pwrseq/pwrseq.c b/drivers/power/pwrseq/pwrseq.c index 9c665821f890..495a19d3c30b 100644 --- a/drivers/power/pwrseq/pwrseq.c +++ b/drivers/power/pwrseq/pwrseq.c @@ -52,32 +52,26 @@ int mmc_pwrseq_alloc(struct mmc_host *host) } EXPORT_SYMBOL_GPL(mmc_pwrseq_alloc); -void mmc_pwrseq_pre_power_on(struct mmc_host *host) +void pwrseq_pre_power_on(struct pwrseq *pwrseq) { - struct pwrseq *pwrseq = host->pwrseq; - if (pwrseq && pwrseq->ops->pre_power_on) - pwrseq->ops->pre_power_on(host); + pwrseq->ops->pre_power_on(pwrseq); } -EXPORT_SYMBOL_GPL(mmc_pwrseq_pre_power_on); +EXPORT_SYMBOL_GPL(pwrseq_pre_power_on); -void mmc_pwrseq_post_power_on(struct mmc_host *host) +void pwrseq_post_power_on(struct pwrseq *pwrseq) { - struct pwrseq *pwrseq = host->pwrseq; - if (pwrseq && pwrseq->ops->post_power_on) - pwrseq->ops->post_power_on(host); + pwrseq->ops->post_power_on(pwrseq); } -EXPORT_SYMBOL_GPL(mmc_pwrseq_post_power_on); +EXPORT_SYMBOL_GPL(pwrseq_post_power_on); -void mmc_pwrseq_power_off(struct mmc_host *host) +void pwrseq_power_off(struct pwrseq *pwrseq) { - struct pwrseq *pwrseq = host->pwrseq; - if (pwrseq && pwrseq->ops->power_off) - pwrseq->ops->power_off(host); + pwrseq->ops->power_off(pwrseq); } -EXPORT_SYMBOL_GPL(mmc_pwrseq_power_off); +EXPORT_SYMBOL_GPL(pwrseq_power_off); void mmc_pwrseq_free(struct mmc_host *host) { diff --git a/drivers/power/pwrseq/pwrseq_emmc.c b/drivers/power/pwrseq/pwrseq_emmc.c index a68ac9a68e04..dbb7e753beb2 100644 --- a/drivers/power/pwrseq/pwrseq_emmc.c +++ b/drivers/power/pwrseq/pwrseq_emmc.c @@ -19,8 +19,6 @@ #include #include -#include - struct mmc_pwrseq_emmc { struct pwrseq pwrseq; struct notifier_block reset_nb; @@ -37,9 +35,9 @@ static void __mmc_pwrseq_emmc_reset(struct mmc_pwrseq_emmc *pwrseq) udelay(200); } -static void mmc_pwrseq_emmc_reset(struct mmc_host *host) +static void mmc_pwrseq_emmc_reset(struct pwrseq *_pwrseq) { - struct mmc_pwrseq_emmc *pwrseq = to_pwrseq_emmc(host->pwrseq); + struct mmc_pwrseq_emmc *pwrseq = to_pwrseq_emmc(_pwrseq); __mmc_pwrseq_emmc_reset(pwrseq); } diff --git a/drivers/power/pwrseq/pwrseq_simple.c b/drivers/power/pwrseq/pwrseq_simple.c index d5fbd653153e..93807a6ef162 100644 --- a/drivers/power/pwrseq/pwrseq_simple.c +++ b/drivers/power/pwrseq/pwrseq_simple.c @@ -18,8 +18,6 @@ #include #include -#include - struct mmc_pwrseq_simple { struct pwrseq pwrseq; bool clk_enabled; @@ -46,9 +44,9 @@ static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq, } } -static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host) +static void mmc_pwrseq_simple_pre_power_on(struct pwrseq *_pwrseq) { - struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq); + struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq); if (!IS_ERR(pwrseq->ext_clk) && !pwrseq->clk_enabled) { clk_prepare_enable(pwrseq->ext_clk); @@ -58,16 +56,16 @@ static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host) mmc_pwrseq_simple_set_gpios_value(pwrseq, 1); } -static void mmc_pwrseq_simple_post_power_on(struct mmc_host *host) +static void mmc_pwrseq_simple_post_power_on(struct pwrseq *_pwrseq) { - struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq); + struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq); mmc_pwrseq_simple_set_gpios_value(pwrseq, 0); } -static void mmc_pwrseq_simple_power_off(struct mmc_host *host) +static void mmc_pwrseq_simple_power_off(struct pwrseq *_pwrseq) { - struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq); + struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(_pwrseq); mmc_pwrseq_simple_set_gpios_value(pwrseq, 1); diff --git a/include/linux/pwrseq.h b/include/linux/pwrseq.h index 6d2d2a44ad35..fcc8fd855d4c 100644 --- a/include/linux/pwrseq.h +++ b/include/linux/pwrseq.h @@ -11,9 +11,9 @@ #include struct pwrseq_ops { - void (*pre_power_on)(struct mmc_host *host); - void (*post_power_on)(struct mmc_host *host); - void (*power_off)(struct mmc_host *host); + void (*pre_power_on)(struct pwrseq *pwrseq); + void (*post_power_on)(struct pwrseq *pwrseq); + void (*power_off)(struct pwrseq *pwrseq); }; struct pwrseq { @@ -28,10 +28,10 @@ struct pwrseq { int pwrseq_register(struct pwrseq *pwrseq); void pwrseq_unregister(struct pwrseq *pwrseq); +void pwrseq_pre_power_on(struct pwrseq *pwrseq); +void pwrseq_post_power_on(struct pwrseq *pwrseq); +void pwrseq_power_off(struct pwrseq *pwrseq); int mmc_pwrseq_alloc(struct mmc_host *host); -void mmc_pwrseq_pre_power_on(struct mmc_host *host); -void mmc_pwrseq_post_power_on(struct mmc_host *host); -void mmc_pwrseq_power_off(struct mmc_host *host); void mmc_pwrseq_free(struct mmc_host *host); #else /* CONFIG_POWER_SEQ */ @@ -41,10 +41,10 @@ static inline int pwrseq_register(struct pwrseq *pwrseq) return -ENOSYS; } static inline void pwrseq_unregister(struct pwrseq *pwrseq) {} +static inline void pwrseq_pre_power_on(struct pwrseq *pwrseq) {} +static inline void pwrseq_post_power_on(struct pwrseq *pwrseq) {} +static inline void pwrseq_power_off(struct pwrseq *pwrseq) {} static inline int mmc_pwrseq_alloc(struct mmc_host *host) { return 0; } -static inline void mmc_pwrseq_pre_power_on(struct mmc_host *host) {} -static inline void mmc_pwrseq_post_power_on(struct mmc_host *host) {} -static inline void mmc_pwrseq_power_off(struct mmc_host *host) {} static inline void mmc_pwrseq_free(struct mmc_host *host) {} #endif /* CONFIG_POWER_SEQ */