From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sascha Hauer Subject: Re: [PATCH v2 2/5] mmc: mediatek: Add Mediatek MMC driver Date: Fri, 17 Apr 2015 11:12:13 +0200 Message-ID: <20150417091213.GM4946@pengutronix.de> References: <1426562035-16709-1-git-send-email-chaotian.jing@mediatek.com> <1426562035-16709-3-git-send-email-chaotian.jing@mediatek.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Ulf Hansson Cc: Chaotian Jing , Mark Rutland , James Liao , Arnd Bergmann , srv_heupstream@mediatek.com, "devicetree@vger.kernel.org" , Hongzhou Yang , Catalin Marinas , bin.zhang@mediatek.com, linux-mmc , Chris Ball , Will Deacon , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" , Rob Herring , linux-mediatek@lists.infradead.org, Sascha Hauer , Matthias Brugger , "Joe.C" , Eddie Huang , "linux-arm-kernel@lists.infradead.org" List-Id: linux-gpio@vger.kernel.org Ulf, On Tue, Mar 31, 2015 at 02:23:06PM +0200, Ulf Hansson wrote: > On 17 March 2015 at 04:13, Chaotian Jing wrote: > > + > > + msdc_set_buswidth(host, ios->bus_width); > > + > > + /* Suspend/Resume will do power off/on */ > > + switch (ios->power_mode) { > > + case MMC_POWER_UP: > > + msdc_init_hw(host); > > + if (!IS_ERR(mmc->supply.vmmc)) { > > + ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, > > + ios->vdd); > > + if (ret) { > > + dev_err(host->dev, "Failed to set vmmc power!\n"); > > + return; > > + } > > + } > > + break; > > + case MMC_POWER_ON: > > + if (!IS_ERR(mmc->supply.vqmmc)) { > > + ret = regulator_enable(mmc->supply.vqmmc); > > The calls to regulator_enable|disable() for the vqmmc will not be > balanced properly here. You need a local cache variable like > "is_enabled" to keep track of this. Shouldn't the MMC core provide balanced hooks for this? What about MMC_POWER_UP, can this be used for enabling regulators? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | From mboxrd@z Thu Jan 1 00:00:00 1970 From: s.hauer@pengutronix.de (Sascha Hauer) Date: Fri, 17 Apr 2015 11:12:13 +0200 Subject: [PATCH v2 2/5] mmc: mediatek: Add Mediatek MMC driver In-Reply-To: References: <1426562035-16709-1-git-send-email-chaotian.jing@mediatek.com> <1426562035-16709-3-git-send-email-chaotian.jing@mediatek.com> Message-ID: <20150417091213.GM4946@pengutronix.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Ulf, On Tue, Mar 31, 2015 at 02:23:06PM +0200, Ulf Hansson wrote: > On 17 March 2015 at 04:13, Chaotian Jing wrote: > > + > > + msdc_set_buswidth(host, ios->bus_width); > > + > > + /* Suspend/Resume will do power off/on */ > > + switch (ios->power_mode) { > > + case MMC_POWER_UP: > > + msdc_init_hw(host); > > + if (!IS_ERR(mmc->supply.vmmc)) { > > + ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, > > + ios->vdd); > > + if (ret) { > > + dev_err(host->dev, "Failed to set vmmc power!\n"); > > + return; > > + } > > + } > > + break; > > + case MMC_POWER_ON: > > + if (!IS_ERR(mmc->supply.vqmmc)) { > > + ret = regulator_enable(mmc->supply.vqmmc); > > The calls to regulator_enable|disable() for the vqmmc will not be > balanced properly here. You need a local cache variable like > "is_enabled" to keep track of this. Shouldn't the MMC core provide balanced hooks for this? What about MMC_POWER_UP, can this be used for enabling regulators? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753838AbbDQJM3 (ORCPT ); Fri, 17 Apr 2015 05:12:29 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:34797 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753749AbbDQJM1 (ORCPT ); Fri, 17 Apr 2015 05:12:27 -0400 Date: Fri, 17 Apr 2015 11:12:13 +0200 From: Sascha Hauer To: Ulf Hansson Cc: Chaotian Jing , Mark Rutland , James Liao , Arnd Bergmann , srv_heupstream@mediatek.com, "devicetree@vger.kernel.org" , Hongzhou Yang , Catalin Marinas , bin.zhang@mediatek.com, linux-mmc , Chris Ball , Will Deacon , "linux-kernel@vger.kernel.org" , "linux-gpio@vger.kernel.org" , Rob Herring , linux-mediatek@lists.infradead.org, Sascha Hauer , Matthias Brugger , "Joe.C" , Eddie Huang , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH v2 2/5] mmc: mediatek: Add Mediatek MMC driver Message-ID: <20150417091213.GM4946@pengutronix.de> References: <1426562035-16709-1-git-send-email-chaotian.jing@mediatek.com> <1426562035-16709-3-git-send-email-chaotian.jing@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 10:59:04 up 31 days, 20:50, 77 users, load average: 0.01, 0.08, 0.11 User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ulf, On Tue, Mar 31, 2015 at 02:23:06PM +0200, Ulf Hansson wrote: > On 17 March 2015 at 04:13, Chaotian Jing wrote: > > + > > + msdc_set_buswidth(host, ios->bus_width); > > + > > + /* Suspend/Resume will do power off/on */ > > + switch (ios->power_mode) { > > + case MMC_POWER_UP: > > + msdc_init_hw(host); > > + if (!IS_ERR(mmc->supply.vmmc)) { > > + ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, > > + ios->vdd); > > + if (ret) { > > + dev_err(host->dev, "Failed to set vmmc power!\n"); > > + return; > > + } > > + } > > + break; > > + case MMC_POWER_ON: > > + if (!IS_ERR(mmc->supply.vqmmc)) { > > + ret = regulator_enable(mmc->supply.vqmmc); > > The calls to regulator_enable|disable() for the vqmmc will not be > balanced properly here. You need a local cache variable like > "is_enabled" to keep track of this. Shouldn't the MMC core provide balanced hooks for this? What about MMC_POWER_UP, can this be used for enabling regulators? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |