From patchwork Tue May 14 12:43:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 16892 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-fa0-f71.google.com (mail-fa0-f71.google.com [209.85.161.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 410FB25D00 for ; Tue, 14 May 2013 12:45:06 +0000 (UTC) Received: by mail-fa0-f71.google.com with SMTP id t1sf459884fae.6 for ; Tue, 14 May 2013 05:44:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :from:to:cc:subject:date:message-id:x-mailer:mime-version :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=C2Gs1MvnTjmuIVN33+dZIghJfxF8lnei03Uu2NF02Ek=; b=Oog4xvCNCZyH4VYt25DpA+ZNCYz6XvPUrQ8tCEzASr51cK/skX2Cz+BjZynkw64yDI v5ziPkRCMUOT12vhb32crNpJv/wOdwdUsFg1udzwoyRvl4QLikufSL0R94IOxraWhkX8 X0NModNiSajTQH+M8VlIcPZZcDmzhtZc2jm8o0qDzu9ukR8El9ygM37h62nIithAvcEp 4fUV9nlwJBFjH0jR99cKyli9OovYXdO/0bhqKLc31vb948rmWdlIPPK2mo7oyxR/QQTg OOPekyNkg2ghaRC1bbwcOocaq1vBvYk9CePbRPZkq4NU0ECpIzOSwGawqe46Ptw+7p+l 4IXw== X-Received: by 10.180.21.226 with SMTP id y2mr761037wie.5.1368535470632; Tue, 14 May 2013 05:44:30 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.95.35 with SMTP id dh3ls1151179wib.7.canary; Tue, 14 May 2013 05:44:30 -0700 (PDT) X-Received: by 10.205.24.201 with SMTP id rf9mr7989525bkb.73.1368535470347; Tue, 14 May 2013 05:44:30 -0700 (PDT) Received: from mail-ve0-x230.google.com (mail-ve0-x230.google.com [2607:f8b0:400c:c01::230]) by mx.google.com with ESMTPS id nh3si5200577wic.99.2013.05.14.05.44.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 14 May 2013 05:44:30 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::230; Received: by mail-ve0-f176.google.com with SMTP id c13so500363vea.35 for ; Tue, 14 May 2013 05:44:29 -0700 (PDT) X-Received: by 10.52.36.115 with SMTP id p19mr1075979vdj.8.1368535469179; Tue, 14 May 2013 05:44:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.217.15 with SMTP id hk15csp60830vcb; Tue, 14 May 2013 05:44:28 -0700 (PDT) X-Received: by 10.205.116.17 with SMTP id fg17mr7964182bkc.61.1368535467951; Tue, 14 May 2013 05:44:27 -0700 (PDT) Received: from eu1sys200aog124.obsmtp.com (eu1sys200aog124.obsmtp.com [207.126.144.157]) by mx.google.com with SMTP id n3si18830036eeg.229.2013.05.14.05.44.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 14 May 2013 05:44:27 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.157 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.157; Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob124.postini.com ([207.126.147.11]) with SMTP ID DSNKUZIxf/XRr9YWxrbgqv6brMPWU6F1cxj3@postini.com; Tue, 14 May 2013 12:44:27 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9B2AF15E; Tue, 14 May 2013 12:43:33 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3C0754CF8; Tue, 14 May 2013 12:43:20 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 13768A8072; Tue, 14 May 2013 14:43:27 +0200 (CEST) Received: from steludxu1397.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.279.5; Tue, 14 May 2013 14:43:31 +0200 From: Ulf Hansson To: , Russell King Cc: , Chris Ball , Ulf Hansson Subject: [PATCH] mmc: mmci: Fixup regulator handling for vqmmc Date: Tue, 14 May 2013 14:43:22 +0200 Message-ID: <1368535402-8897-1-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlB+ZTNTWg4g7G781oDhlQ6oGPrb7FgmPrqumMO137W5eplrnQkIbjwVvLtaX7G4Czi8jsk X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Ulf Hansson We can not rely on regulator_is_enabled to decide whether to enable|disable the regulator. It would mean that the reference counter for it is not balanced properly. Instead keep track of our internal state by using a new flag in the host struct, so we can take correct decisions. Signed-off-by: Ulf Hansson --- drivers/mmc/host/mmci.c | 10 ++++++---- drivers/mmc/host/mmci.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index f4f3038..2983c15 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1143,9 +1143,10 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) if (!IS_ERR(mmc->supply.vmmc)) mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); - if (!IS_ERR(mmc->supply.vqmmc) && - regulator_is_enabled(mmc->supply.vqmmc)) + if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) { regulator_disable(mmc->supply.vqmmc); + host->vqmmc_enabled = false; + } break; case MMC_POWER_UP: @@ -1161,12 +1162,13 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) break; case MMC_POWER_ON: - if (!IS_ERR(mmc->supply.vqmmc) && - !regulator_is_enabled(mmc->supply.vqmmc)) { + if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { ret = regulator_enable(mmc->supply.vqmmc); if (ret < 0) dev_err(mmc_dev(mmc), "failed to enable vqmmc regulator\n"); + else + host->vqmmc_enabled = true; } pwr |= MCI_PWR_ON; diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h index 1f33ad5..1383c9c 100644 --- a/drivers/mmc/host/mmci.h +++ b/drivers/mmc/host/mmci.h @@ -183,6 +183,7 @@ struct mmci_host { unsigned int cclk; u32 pwr_reg; u32 clk_reg; + bool vqmmc_enabled; struct mmci_platform_data *plat; struct variant_data *variant;