mmc: Move regulator handling closer to core
After discovering a problem in regulator reference counting I took Mark Brown's advice to move the reference count into the MMC core by making the regulator status a member of struct mmc_host. I took this opportunity to also implement NULL versions of the regulator functions so as to rid the driver code from some ugly #ifdef CONFIG_REGULATOR clauses. Signed-off-by: Linus Walleij <linus.walleij@stericsson.com> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Liam Girdwood <lrg@slimlogic.co.uk> Cc: Tony Lindgren <tony@atomide.com> Cc: Adrian Hunter <adrian.hunter@nokia.com> Cc: Robert Jarzmik <robert.jarzmik@free.fr> Cc: Sundar Iyer <sundar.iyer@stericsson.com> Cc: Daniel Mack <daniel@caiaq.de> Cc: Pierre Ossman <pierre@ossman.eu> Cc: Matt Fleming <matt@console-pimps.org> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Russell King <rmk+kernel@arm.linux.org.uk> Cc: Eric Miao <eric.y.miao@gmail.com> Cc: Cliff Brake <cbrake@bec-systems.com> Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com> Cc: <linux-mmc@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Chris Ball <cjb@laptop.org>
This commit is contained in:

committed by
Chris Ball

vanhempi
4d0b8611cd
commit
99fc513101
@@ -250,9 +250,9 @@ static int omap_hsmmc_1_set_power(struct device *dev, int slot, int power_on,
|
||||
mmc_slot(host).before_set_reg(dev, slot, power_on, vdd);
|
||||
|
||||
if (power_on)
|
||||
ret = mmc_regulator_set_ocr(host->vcc, vdd);
|
||||
ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
|
||||
else
|
||||
ret = mmc_regulator_set_ocr(host->vcc, 0);
|
||||
ret = mmc_regulator_set_ocr(host->mmc, host->vcc, 0);
|
||||
|
||||
if (mmc_slot(host).after_set_reg)
|
||||
mmc_slot(host).after_set_reg(dev, slot, power_on, vdd);
|
||||
@@ -291,18 +291,23 @@ static int omap_hsmmc_23_set_power(struct device *dev, int slot, int power_on,
|
||||
* chips/cards need an interface voltage rail too.
|
||||
*/
|
||||
if (power_on) {
|
||||
ret = mmc_regulator_set_ocr(host->vcc, vdd);
|
||||
ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
|
||||
/* Enable interface voltage rail, if needed */
|
||||
if (ret == 0 && host->vcc_aux) {
|
||||
ret = regulator_enable(host->vcc_aux);
|
||||
if (ret < 0)
|
||||
ret = mmc_regulator_set_ocr(host->vcc, 0);
|
||||
ret = mmc_regulator_set_ocr(host->mmc,
|
||||
host->vcc, 0);
|
||||
}
|
||||
} else {
|
||||
/* Shut down the rail */
|
||||
if (host->vcc_aux)
|
||||
ret = regulator_disable(host->vcc_aux);
|
||||
if (ret == 0)
|
||||
ret = mmc_regulator_set_ocr(host->vcc, 0);
|
||||
if (!ret) {
|
||||
/* Then proceed to shut down the local regulator */
|
||||
ret = mmc_regulator_set_ocr(host->mmc,
|
||||
host->vcc, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (mmc_slot(host).after_set_reg)
|
||||
@@ -343,9 +348,9 @@ static int omap_hsmmc_23_set_sleep(struct device *dev, int slot, int sleep,
|
||||
if (cardsleep) {
|
||||
/* VCC can be turned off if card is asleep */
|
||||
if (sleep)
|
||||
err = mmc_regulator_set_ocr(host->vcc, 0);
|
||||
err = mmc_regulator_set_ocr(host->mmc, host->vcc, 0);
|
||||
else
|
||||
err = mmc_regulator_set_ocr(host->vcc, vdd);
|
||||
err = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
|
||||
} else
|
||||
err = regulator_set_mode(host->vcc, mode);
|
||||
if (err)
|
||||
|
Viittaa uudesa ongelmassa
Block a user