On 8 March 2018 at 15:52, Maxime Ripard <maxime.ripard@xxxxxxxxxxx> wrote: > We'll need to have the power off behaviour in order to implement > runtime_pm. Move it outside of the .set_ios callback for an easier access. This isn't correct. To implement runtime PM for the sunxi device, which I think is what your goal is, you should not disable/enable regulators to the (e)MMC/SD/SDIO card. If you also want runtime PM deployment for the card, that is managed by the mmc core already. All you have to do is to set MMC_CAP_AGGRESSIVE_PM for your mmc host, if you want that. > > And it improves readibility as a bonus. > > Signed-off-by: Maxime Ripard <maxime.ripard@xxxxxxxxxxx> > --- > drivers/mmc/host/sunxi-mmc.c | 25 +++++++++++++++++-------- > 1 file changed, 17 insertions(+), 8 deletions(-) > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c > index f9723797a9f8..a53e39d8b07e 100644 > --- a/drivers/mmc/host/sunxi-mmc.c > +++ b/drivers/mmc/host/sunxi-mmc.c > @@ -855,6 +855,22 @@ static int sunxi_mmc_clk_set_rate(struct sunxi_mmc_host *host, > return 0; > } > > +static void sunxi_mmc_power_off(struct mmc_host *mmc, struct mmc_ios *ios) > +{ > + struct sunxi_mmc_host *host = mmc_priv(mmc); > + > + dev_dbg(mmc_dev(mmc), "Powering off\n"); > + > + sunxi_mmc_reset_host(host); > + if (!IS_ERR(mmc->supply.vmmc)) > + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); > + > + if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) > + regulator_disable(mmc->supply.vqmmc); > + > + host->vqmmc_enabled = false; > +} > + > static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > { > struct sunxi_mmc_host *host = mmc_priv(mmc); > @@ -892,14 +908,7 @@ static void sunxi_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > break; > > case MMC_POWER_OFF: > - dev_dbg(mmc_dev(mmc), "power off!\n"); > - sunxi_mmc_reset_host(host); > - if (!IS_ERR(mmc->supply.vmmc)) > - mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0); > - > - if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) > - regulator_disable(mmc->supply.vqmmc); > - host->vqmmc_enabled = false; > + sunxi_mmc_power_off(mmc, ios); > break; > } > > -- > git-series 0.9.1 Kind regards Uffe -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html