Skip to content

Commit 4180ffa

Browse files
ahunter6storulf
authored andcommitted
mmc: sdhci: Add sdhci_cleanup_host
Add sdhci_cleanup_host() to cleanup __sdhci_add_host(). Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
1 parent 15becf6 commit 4180ffa

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3568,6 +3568,22 @@ int sdhci_setup_host(struct sdhci_host *host)
35683568
}
35693569
EXPORT_SYMBOL_GPL(sdhci_setup_host);
35703570

3571+
void sdhci_cleanup_host(struct sdhci_host *host)
3572+
{
3573+
struct mmc_host *mmc = host->mmc;
3574+
3575+
if (!IS_ERR(mmc->supply.vqmmc))
3576+
regulator_disable(mmc->supply.vqmmc);
3577+
3578+
if (host->align_buffer)
3579+
dma_free_coherent(mmc_dev(mmc), host->align_buffer_sz +
3580+
host->adma_table_sz, host->align_buffer,
3581+
host->align_addr);
3582+
host->adma_table = NULL;
3583+
host->align_buffer = NULL;
3584+
}
3585+
EXPORT_SYMBOL_GPL(sdhci_cleanup_host);
3586+
35713587
int __sdhci_add_host(struct sdhci_host *host)
35723588
{
35733589
struct mmc_host *mmc = host->mmc;
@@ -3632,16 +3648,6 @@ int __sdhci_add_host(struct sdhci_host *host)
36323648
untasklet:
36333649
tasklet_kill(&host->finish_tasklet);
36343650

3635-
if (!IS_ERR(mmc->supply.vqmmc))
3636-
regulator_disable(mmc->supply.vqmmc);
3637-
3638-
if (host->align_buffer)
3639-
dma_free_coherent(mmc_dev(mmc), host->align_buffer_sz +
3640-
host->adma_table_sz, host->align_buffer,
3641-
host->align_addr);
3642-
host->adma_table = NULL;
3643-
host->align_buffer = NULL;
3644-
36453651
return ret;
36463652
}
36473653
EXPORT_SYMBOL_GPL(__sdhci_add_host);
@@ -3654,7 +3660,16 @@ int sdhci_add_host(struct sdhci_host *host)
36543660
if (ret)
36553661
return ret;
36563662

3657-
return __sdhci_add_host(host);
3663+
ret = __sdhci_add_host(host);
3664+
if (ret)
3665+
goto cleanup;
3666+
3667+
return 0;
3668+
3669+
cleanup:
3670+
sdhci_cleanup_host(host);
3671+
3672+
return ret;
36583673
}
36593674
EXPORT_SYMBOL_GPL(sdhci_add_host);
36603675

drivers/mmc/host/sdhci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ void sdhci_card_detect(struct sdhci_host *host);
660660
void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps,
661661
u32 *caps1);
662662
int sdhci_setup_host(struct sdhci_host *host);
663+
void sdhci_cleanup_host(struct sdhci_host *host);
663664
int __sdhci_add_host(struct sdhci_host *host);
664665
int sdhci_add_host(struct sdhci_host *host);
665666
void sdhci_remove_host(struct sdhci_host *host, int dead);

0 commit comments

Comments
 (0)