From patchwork Wed May 15 09:40:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 16915 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 36E962396C for ; Wed, 15 May 2013 09:42:13 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id s10sf713765qcv.7 for ; Wed, 15 May 2013 02:41:36 -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:in-reply-to:references :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=bi/wrOXZ9eBd0CwUGzSTufZxcZSWA8ZRL643IXiEN0KKJK06FR+qRAKt5ddMDhjZfl TvM3Cn02hoRCOD8vYM4AhXJvC+fIzxaBU1qYdxkytNRzZx2JBusl1gm7ucDtI+IG2cOH FnJTWUbWmGd7tGgnnTFWL6NgXNGvzNeorQKmTbEH68U/GdRioxjUflvifeCOItBQbEmQ JSIxFSnzc2TrRgK9ltz0ua2WZpxI+vR2Vnhs8uLliSzW+EoZyvaWoEkgWzgHls/wtkYp TzyCRea7hiKIudJl5vF93YXF5Ex4uBE7MCD0w5pu1Bi9JChdobY2r9v0AOUUyxh9YrpK jZLg== X-Received: by 10.224.42.141 with SMTP id s13mr23041627qae.3.1368610896741; Wed, 15 May 2013 02:41:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.96.137 with SMTP id ds9ls42722qeb.73.gmail; Wed, 15 May 2013 02:41:36 -0700 (PDT) X-Received: by 10.52.122.109 with SMTP id lr13mr20774994vdb.91.1368610896617; Wed, 15 May 2013 02:41:36 -0700 (PDT) Received: from mail-vb0-x231.google.com (mail-vb0-x231.google.com [2607:f8b0:400c:c02::231]) by mx.google.com with ESMTPS id ha8si990234vdb.152.2013.05.15.02.41.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 May 2013 02:41:36 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::231 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:c02::231; Received: by mail-vb0-f49.google.com with SMTP id q12so268202vbe.8 for ; Wed, 15 May 2013 02:41:36 -0700 (PDT) X-Received: by 10.221.4.131 with SMTP id oc3mr1782829vcb.49.1368610896346; Wed, 15 May 2013 02:41:36 -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 hk15csp10981vcb; Wed, 15 May 2013 02:41:35 -0700 (PDT) X-Received: by 10.14.181.131 with SMTP id l3mr53210992eem.16.1368610895077; Wed, 15 May 2013 02:41:35 -0700 (PDT) Received: from eu1sys200aog123.obsmtp.com (eu1sys200aog123.obsmtp.com [207.126.144.155]) by mx.google.com with SMTP id u1si2487855eeo.256.2013.05.15.02.41.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 15 May 2013 02:41:35 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.155 is neither permitted nor denied by best guess record for domain of ulf.hansson@stericsson.com) client-ip=207.126.144.155; Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob123.postini.com ([207.126.147.11]) with SMTP ID DSNKUZNYMqdXCEGGmog7C78nCuIrgQ0YS1Hx@postini.com; Wed, 15 May 2013 09:41:34 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 1FA2534B; Wed, 15 May 2013 09:40:32 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CDA404705; Wed, 15 May 2013 09:40:19 +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 0BFD2A8072; Wed, 15 May 2013 11:40:28 +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; Wed, 15 May 2013 11:40:31 +0200 From: Ulf Hansson To: , Russell King Cc: , Chris Ball , Linus Walleij , Ulf Hansson Subject: [PATCH 1/4] mmc: mmci: Fixup regulator handling for vqmmc Date: Wed, 15 May 2013 11:40:19 +0200 Message-ID: <1368610823-14113-2-git-send-email-ulf.hansson@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1368610823-14113-1-git-send-email-ulf.hansson@stericsson.com> References: <1368610823-14113-1-git-send-email-ulf.hansson@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm+IgLlnWIJqIyFXAcIDqTTeoRzU+mOJDCC8/L4g7IWM2zCOghznaDFVkNd26kN76XeLLIu X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::231 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;