From patchwork Sat May 3 06:55:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 4105731 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 148FC9F271 for ; Sat, 3 May 2014 06:55:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2664220259 for ; Sat, 3 May 2014 06:55:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 636162021A for ; Sat, 3 May 2014 06:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750790AbaECGzh (ORCPT ); Sat, 3 May 2014 02:55:37 -0400 Received: from fallback5.mail.ru ([94.100.176.59]:50045 "EHLO fallback5.mail.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750770AbaECGzh (ORCPT ); Sat, 3 May 2014 02:55:37 -0400 Received: from smtp14.mail.ru (smtp14.mail.ru [94.100.176.91]) by fallback5.mail.ru (mPOP.Fallback_MX) with ESMTP id D399D115CFBF4; Sat, 3 May 2014 10:55:34 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=ufeNmuI/OeD3ZHTBhee0qRVMnM8d2ppc6h5EoblUY1k=; b=L94MstEd5qOoLXmd9zaxCJYmJ9ZM3EvFDWKYcjQ9OdSogI4Yx3s2tcLxqrM1441IV2To4BX4C+6xGeaH07zp/LjwCf/YeTz75yQmhbe4bIQi4aYHlkzutIdSjEV2ACKrteLEn7TjJuDdLNu+sBwdprR58Hf7+3t+OrOrDbFHOUo=; Received: from [5.18.98.0] (port=42254 helo=shc.zet) by smtp14.mail.ru with esmtpa (envelope-from ) id 1WgTr0-00083t-Sv; Sat, 03 May 2014 10:55:23 +0400 From: Alexander Shiyan To: linux-mmc@vger.kernel.org Cc: Chris Ball , Ulf Hansson , Alexander Shiyan Subject: [PATCH] mmc: mxcmmc: Use mmc_regulator_get_supply() API Date: Sat, 3 May 2014 10:55:17 +0400 Message-Id: <1399100117-6978-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.3.2 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Mras: Ok Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RDNS_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch replaces regulator manipulation with mmc_regulator_get_supply() function from MMC core. Signed-off-by: Alexander Shiyan --- drivers/mmc/host/mxcmmc.c | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c index 86401c0..ed1cb93 100644 --- a/drivers/mmc/host/mxcmmc.c +++ b/drivers/mmc/host/mxcmmc.c @@ -153,8 +153,6 @@ struct mxcmci_host { struct work_struct datawork; spinlock_t lock; - struct regulator *vcc; - int burstlen; int dmareq; struct dma_slave_config dma_slave_config; @@ -240,30 +238,15 @@ static inline void mxcmci_writew(struct mxcmci_host *host, u16 val, int reg) static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios); -static void mxcmci_init_ocr(struct mxcmci_host *host) +static void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd) { - host->vcc = devm_regulator_get(mmc_dev(host->mmc), "vmmc"); - if (IS_ERR(host->vcc)) { - if (host->pdata && host->pdata->ocr_avail) - host->mmc->ocr_avail = host->pdata->ocr_avail; - else - host->mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; - } else { - host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc); - if (host->pdata && host->pdata->ocr_avail) - dev_warn(mmc_dev(host->mmc), - "pdata->ocr_avail will not be used\n"); - } -} - -static void mxcmci_set_power(struct mxcmci_host *host, unsigned char power_mode, - unsigned int vdd) -{ - if (!IS_ERR(host->vcc)) { - if (power_mode == MMC_POWER_UP) - mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); - else if (power_mode == MMC_POWER_OFF) - mmc_regulator_set_ocr(host->mmc, host->vcc, 0); + if (!IS_ERR(host->mmc->supply.vmmc)) { + if (host->power_mode == MMC_POWER_UP) + mmc_regulator_set_ocr(host->mmc, + host->mmc->supply.vmmc, vdd); + else if (host->power_mode == MMC_POWER_OFF) + mmc_regulator_set_ocr(host->mmc, + host->mmc->supply.vmmc, 0); } if (host->pdata && host->pdata->setpower) @@ -902,8 +885,8 @@ static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4; if (host->power_mode != ios->power_mode) { - mxcmci_set_power(host, ios->power_mode, ios->vdd); host->power_mode = ios->power_mode; + mxcmci_set_power(host, ios->vdd); if (ios->power_mode == MMC_POWER_ON) host->cmdat |= CMD_DAT_CONT_INIT; @@ -1100,7 +1083,14 @@ static int mxcmci_probe(struct platform_device *pdev) && !of_property_read_bool(pdev->dev.of_node, "cd-gpios")) dat3_card_detect = true; - mxcmci_init_ocr(host); + ret = mmc_regulator_get_supply(mmc); + if (ret) { + if (pdata && ret != -EPROBE_DEFER) + mmc->ocr_avail = pdata->ocr_avail ? : + MMC_VDD_32_33 | MMC_VDD_33_34; + else + goto out_free; + } if (dat3_card_detect) host->default_irq_mask =