Commit 52f5336d authored by Adrian Hunter's avatar Adrian Hunter Committed by Ulf Hansson

mmc: sdhci: Split sdhci_add_host()

Split sdhci-add_host() in order to further our objective to make
sdhci into a library.

The split divides code that sets up mmc and sdhci parameters, from
code that actually activates things - such as tasklet initialization,
requesting the irq, and adding (and starting) the host.

This gives drivers an opportunity to change various settings before
committing to start the host.

Drivers can continue to call sdhci_add_host() but drivers that want
to take advantage of the split instead call sdhci_setup_host() followed
by __sdhci_add_host().
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent d3940f27
...@@ -2833,7 +2833,7 @@ static int sdhci_set_dma_mask(struct sdhci_host *host) ...@@ -2833,7 +2833,7 @@ static int sdhci_set_dma_mask(struct sdhci_host *host)
return ret; return ret;
} }
int sdhci_add_host(struct sdhci_host *host) int sdhci_setup_host(struct sdhci_host *host)
{ {
struct mmc_host *mmc; struct mmc_host *mmc;
u32 caps[2] = {0, 0}; u32 caps[2] = {0, 0};
...@@ -3314,6 +3314,28 @@ int sdhci_add_host(struct sdhci_host *host) ...@@ -3314,6 +3314,28 @@ int sdhci_add_host(struct sdhci_host *host)
*/ */
mmc->max_blk_count = (host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK) ? 1 : 65535; mmc->max_blk_count = (host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK) ? 1 : 65535;
return 0;
unreg:
if (!IS_ERR(mmc->supply.vqmmc))
regulator_disable(mmc->supply.vqmmc);
undma:
if (host->align_buffer)
dma_free_coherent(mmc_dev(mmc), host->align_buffer_sz +
host->adma_table_sz, host->align_buffer,
host->align_addr);
host->adma_table = NULL;
host->align_buffer = NULL;
return ret;
}
EXPORT_SYMBOL_GPL(sdhci_setup_host);
int __sdhci_add_host(struct sdhci_host *host)
{
struct mmc_host *mmc = host->mmc;
int ret;
/* /*
* Init tasklets. * Init tasklets.
*/ */
...@@ -3370,10 +3392,10 @@ int sdhci_add_host(struct sdhci_host *host) ...@@ -3370,10 +3392,10 @@ int sdhci_add_host(struct sdhci_host *host)
free_irq(host->irq, host); free_irq(host->irq, host);
untasklet: untasklet:
tasklet_kill(&host->finish_tasklet); tasklet_kill(&host->finish_tasklet);
unreg:
if (!IS_ERR(mmc->supply.vqmmc)) if (!IS_ERR(mmc->supply.vqmmc))
regulator_disable(mmc->supply.vqmmc); regulator_disable(mmc->supply.vqmmc);
undma:
if (host->align_buffer) if (host->align_buffer)
dma_free_coherent(mmc_dev(mmc), host->align_buffer_sz + dma_free_coherent(mmc_dev(mmc), host->align_buffer_sz +
host->adma_table_sz, host->align_buffer, host->adma_table_sz, host->align_buffer,
...@@ -3383,7 +3405,18 @@ int sdhci_add_host(struct sdhci_host *host) ...@@ -3383,7 +3405,18 @@ int sdhci_add_host(struct sdhci_host *host)
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(__sdhci_add_host);
int sdhci_add_host(struct sdhci_host *host)
{
int ret;
ret = sdhci_setup_host(host);
if (ret)
return ret;
return __sdhci_add_host(host);
}
EXPORT_SYMBOL_GPL(sdhci_add_host); EXPORT_SYMBOL_GPL(sdhci_add_host);
void sdhci_remove_host(struct sdhci_host *host, int dead) void sdhci_remove_host(struct sdhci_host *host, int dead)
......
...@@ -645,6 +645,8 @@ static inline void *sdhci_priv(struct sdhci_host *host) ...@@ -645,6 +645,8 @@ static inline void *sdhci_priv(struct sdhci_host *host)
} }
extern void sdhci_card_detect(struct sdhci_host *host); extern void sdhci_card_detect(struct sdhci_host *host);
extern int sdhci_setup_host(struct sdhci_host *host);
extern int __sdhci_add_host(struct sdhci_host *host);
extern int sdhci_add_host(struct sdhci_host *host); extern int sdhci_add_host(struct sdhci_host *host);
extern void sdhci_remove_host(struct sdhci_host *host, int dead); extern void sdhci_remove_host(struct sdhci_host *host, int dead);
extern void sdhci_send_command(struct sdhci_host *host, extern void sdhci_send_command(struct sdhci_host *host,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment