From patchwork Thu Mar 8 14:52:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 10268213 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 DC157602C8 for ; Thu, 8 Mar 2018 14:55:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFF2B299EB for ; Thu, 8 Mar 2018 14:55:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE3AF299FC; Thu, 8 Mar 2018 14:55:04 +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=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 206BC29D31 for ; Thu, 8 Mar 2018 14:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933976AbeCHOxJ (ORCPT ); Thu, 8 Mar 2018 09:53:09 -0500 Received: from mail.bootlin.com ([62.4.15.54]:51425 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933878AbeCHOxI (ORCPT ); Thu, 8 Mar 2018 09:53:08 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 3F8BA207DA; Thu, 8 Mar 2018 15:53:06 +0100 (CET) Received: from localhost (unknown [185.94.189.190]) by mail.bootlin.com (Postfix) with ESMTPSA id A650920012; Thu, 8 Mar 2018 15:53:05 +0100 (CET) From: Maxime Ripard To: Chen-Yu Tsai , Maxime Ripard , ulf.hansson@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, Quentin Schulz , Thomas Petazzoni Subject: [PATCH v2 4/8] mmc: sunxi: Move the power up action in a separate function Date: Thu, 8 Mar 2018 15:52:50 +0100 Message-Id: <81323d51de103251658535c4c787d687316395c7.1520520655.git-series.maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: References: In-Reply-To: References: 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 We'll need to have the power up behaviour in order to implement runtime_pm. Move it outside of the .set_ios callback for an easier access. And it improves readibility as a bonus. Signed-off-by: Maxime Ripard --- drivers/mmc/host/sunxi-mmc.c | 60 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c index 4e81fe171532..e4b44c4adb8f 100644 --- a/drivers/mmc/host/sunxi-mmc.c +++ b/drivers/mmc/host/sunxi-mmc.c @@ -888,6 +888,37 @@ static void sunxi_mmc_power_on(struct mmc_host *mmc, struct mmc_ios *ios) /* Android code had a usleep_range(50000, 55000); here */ } +static void sunxi_mmc_power_up(struct mmc_host *mmc, struct mmc_ios *ios) +{ + struct sunxi_mmc_host *host = mmc_priv(mmc); + + dev_dbg(mmc_dev(mmc), "Powering up\n"); + + if (!IS_ERR(mmc->supply.vmmc)) { + host->ferror = mmc_regulator_set_ocr(mmc, + mmc->supply.vmmc, + ios->vdd); + if (host->ferror) + return; + } + + if (!IS_ERR(mmc->supply.vqmmc)) { + host->ferror = regulator_enable(mmc->supply.vqmmc); + if (host->ferror) { + dev_err(mmc_dev(mmc), + "failed to enable vqmmc\n"); + return; + } + host->vqmmc_enabled = true; + } + + host->ferror = sunxi_mmc_init_host(mmc); + if (host->ferror) + return; + + sunxi_mmc_power_on(mmc, ios); +} + static void sunxi_mmc_power_off(struct mmc_host *mmc, struct mmc_ios *ios) { struct sunxi_mmc_host *host = mmc_priv(mmc); @@ -906,45 +937,20 @@ static void sunxi_mmc_power_off(struct mmc_host *mmc, struct mmc_ios *ios) static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) { - struct sunxi_mmc_host *host = mmc_priv(mmc); - /* Set the power state */ switch (ios->power_mode) { case MMC_POWER_ON: + sunxi_mmc_power_on(mmc, ios); break; case MMC_POWER_UP: - if (!IS_ERR(mmc->supply.vmmc)) { - host->ferror = mmc_regulator_set_ocr(mmc, - mmc->supply.vmmc, - ios->vdd); - if (host->ferror) - return; - } - - if (!IS_ERR(mmc->supply.vqmmc)) { - host->ferror = regulator_enable(mmc->supply.vqmmc); - if (host->ferror) { - dev_err(mmc_dev(mmc), - "failed to enable vqmmc\n"); - return; - } - host->vqmmc_enabled = true; - } - - host->ferror = sunxi_mmc_init_host(mmc); - if (host->ferror) - return; - - dev_dbg(mmc_dev(mmc), "power on!\n"); + sunxi_mmc_power_up(mmc, ios); break; case MMC_POWER_OFF: sunxi_mmc_power_off(mmc, ios); break; } - - sunxi_mmc_power_on(mmc, ios); } static int sunxi_mmc_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)