From patchwork Thu Jun 9 09:44:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9166667 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 54C576048F for ; Thu, 9 Jun 2016 09:53:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 429B32766D for ; Thu, 9 Jun 2016 09:53:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36C0928328; Thu, 9 Jun 2016 09:53:53 +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 BBB892766D for ; Thu, 9 Jun 2016 09:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161272AbcFIJwN (ORCPT ); Thu, 9 Jun 2016 05:52:13 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:58853 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932981AbcFIJo6 (ORCPT ); Thu, 9 Jun 2016 05:44: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 <0O8I00CB10ETQM70@mailout1.w1.samsung.com>; Thu, 09 Jun 2016 10:44:54 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-90-57593a95085d Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id C4.E6.05254.59A39575; Thu, 9 Jun 2016 10:44:53 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O8I006RA0EHZZ10@eusync1.samsung.com>; Thu, 09 Jun 2016 10:44:53 +0100 (BST) From: Krzysztof Kozlowski To: Ulf Hansson , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Krzysztof Kozlowski , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Liam Girdwood , Mark Brown , Greg Kroah-Hartman , Hans de Goede , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Heiko Stuebner , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, hzpeterchen@gmail.com Cc: Bartlomiej Zolnierkiewicz Subject: [RFC v4 07/14] power: pwrseq: Generalize mmc_pwrseq operations by removing mmc prefix Date: Thu, 09 Jun 2016 11:44:24 +0200 Message-id: <1465465471-28740-8-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1465465471-28740-1-git-send-email-k.kozlowski@samsung.com> References: <1465465471-28740-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRmVeSWpSXmKPExsVy+t/xy7pTrSLDDbZ917XYOGM9q8XUh0/Y LCY9ec9sMf/IOVaLiSsnM1v0v1nIatG8eD2bxZvj05ks/j96zWrRdXUTm8W5VysZLV6/MLT4 dqWDyWLT42usFif6PrBaXN41h83iyP9+RovPvUcYLWac38dksWhZK7PF0usXmSwmTF/LYrHu 4Qsmi9a9R9gtTu8usVg//xabxfG14Q7SHmvmrWH0uNzXy+Sxc9Zddo+Vy7+weWxeoeXx6sId Fo9NqzrZPO5c28PmsX/uGnaPzUvqPd7vu8rm0bdlFaPH9mvzmD2O39jO5PF5k1wAfxSXTUpq TmZZapG+XQJXxqS/UxkLllhXPPy0la2B8ZlRFyMHh4SAicSZY0ldjJxAppjEhXvr2boYuTiE BJYyStz/fpgZwmlkkrj76BQTSBWbgLHE5uVLwKpEBC6xS9y4tB0swSxgIbF162p2EFtYIEHi wcV9bCA2i4CqxLpFR1hBbF4Bd4lF0+YzQ6yTkzh5bDJYnFPAQ+LRvcdgcSGgmr2LJ7NNYORd wMiwilE0tTS5oDgpPddQrzgxt7g0L10vOT93EyMk8r7sYFx8zOoQowAHoxIPr2ZKRLgQa2JZ cWXuIUYJDmYlEd4f5pHhQrwpiZVVqUX58UWlOanFhxilOViUxHnn7nofIiSQnliSmp2aWpBa BJNl4uCUamCUOq9kGcr3UOb7dstD9tHPT23UydAwfcmTt8WmUzc4iy3xg2/56yfGjln7LnrW XMqLDnHpV5NJWBvo7bPpcGPBznWMq4ML+ON+prT8zRGatuW6xN5Z2Sv5F025oVu95OVazhth J7w4Z0/zc5JWWKey7pGNUMks03fVJ25ZnmS6HXL/9s5KkQ1KLMUZiYZazEXFiQBUlCZUuAIA AA== Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@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 */