This patch intend to simplify code in sh_mmcif_set_ios for how clock and power are being configured. Cc: Guennadi Liakhovetski <g.liakhovetski@xxxxxx> Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx> --- drivers/mmc/host/sh_mmcif.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index a1f421b..07c3af5 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -244,7 +244,6 @@ struct sh_mmcif_host { size_t blocksize; int sg_idx; int sg_blkidx; - bool power; bool card_present; bool ccs_enable; /* Command Completion Signal support */ bool clk_ctrl2_enable; @@ -977,14 +976,13 @@ static int sh_mmcif_clk_update(struct sh_mmcif_host *host) return ret; } -static void sh_mmcif_set_power(struct sh_mmcif_host *host, struct mmc_ios *ios) +static void sh_mmcif_set_power(struct sh_mmcif_host *host, unsigned short vdd) { struct mmc_host *mmc = host->mmc; if (!IS_ERR(mmc->supply.vmmc)) /* Errors ignored... */ - mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, - ios->power_mode ? ios->vdd : 0); + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); } static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) @@ -1010,37 +1008,22 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) sh_mmcif_request_dma(host, host->pd->dev.platform_data); host->card_present = true; } - sh_mmcif_set_power(host, ios); - } else if (ios->power_mode == MMC_POWER_OFF || !ios->clock) { - /* clock stop */ - sh_mmcif_clock_control(host, 0); - if (ios->power_mode == MMC_POWER_OFF) { - if (host->card_present) { - sh_mmcif_release_dma(host); - host->card_present = false; - } - } - if (host->power) { - host->power = false; - if (ios->power_mode == MMC_POWER_OFF) - sh_mmcif_set_power(host, ios); + sh_mmcif_set_power(host, ios->vdd); + sh_mmcif_sync_reset(host); + } else if (ios->power_mode == MMC_POWER_OFF) { + if (host->card_present) { + sh_mmcif_release_dma(host); + host->card_present = false; } - host->state = STATE_IDLE; - goto ret; + sh_mmcif_set_power(host, 0); } - if (ios->clock) { - if (!host->power) { - host->power = true; - sh_mmcif_sync_reset(host); - } - sh_mmcif_clock_control(host, ios->clock); - } + sh_mmcif_clock_control(host, ios->clock); host->timing = ios->timing; host->bus_width = ios->bus_width; host->state = STATE_IDLE; -ret: + pm_runtime_mark_last_busy(mmc_dev(mmc)); pm_runtime_put_autosuspend(mmc_dev(mmc)); } @@ -1430,8 +1413,6 @@ static int sh_mmcif_probe(struct platform_device *pdev) platform_set_drvdata(pdev, host); - host->power = false; - host->hclk = clk_get(&pdev->dev, NULL); if (IS_ERR(host->hclk)) { ret = PTR_ERR(host->hclk); -- 1.7.9.5 -- 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