Skip to content

Commit 07e7716

Browse files
rjarzmikstorulf
authored andcommitted
mmc: pxamci: fix the device-tree probe deferral path
When the gpio driver is probed after the mmc one, the read/write gpio and card detection one return -EPROBE_DEFER. Unfortunately, the memory region remains requested, and upon the next probe, the probe will fail anyway with -EBUSY. Fix this by releasing the memory resource upon probe failure. More broadly, this patch uses devm_*() primitives whenever possible in the probe function. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent b006631 commit 07e7716

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

drivers/mmc/host/pxamci.c

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct pxamci_host {
8686
static inline void pxamci_init_ocr(struct pxamci_host *host)
8787
{
8888
#ifdef CONFIG_REGULATOR
89-
host->vcc = regulator_get_optional(mmc_dev(host->mmc), "vmmc");
89+
host->vcc = devm_regulator_get_optional(mmc_dev(host->mmc), "vmmc");
9090

9191
if (IS_ERR(host->vcc))
9292
host->vcc = NULL;
@@ -654,12 +654,8 @@ static int pxamci_probe(struct platform_device *pdev)
654654

655655
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
656656
irq = platform_get_irq(pdev, 0);
657-
if (!r || irq < 0)
658-
return -ENXIO;
659-
660-
r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
661-
if (!r)
662-
return -EBUSY;
657+
if (irq < 0)
658+
return irq;
663659

664660
mmc = mmc_alloc_host(sizeof(struct pxamci_host), &pdev->dev);
665661
if (!mmc) {
@@ -695,7 +691,7 @@ static int pxamci_probe(struct platform_device *pdev)
695691
host->pdata = pdev->dev.platform_data;
696692
host->clkrt = CLKRT_OFF;
697693

698-
host->clk = clk_get(&pdev->dev, NULL);
694+
host->clk = devm_clk_get(&pdev->dev, NULL);
699695
if (IS_ERR(host->clk)) {
700696
ret = PTR_ERR(host->clk);
701697
host->clk = NULL;
@@ -727,9 +723,9 @@ static int pxamci_probe(struct platform_device *pdev)
727723
host->irq = irq;
728724
host->imask = MMC_I_MASK_ALL;
729725

730-
host->base = ioremap(r->start, SZ_4K);
731-
if (!host->base) {
732-
ret = -ENOMEM;
726+
host->base = devm_ioremap_resource(&pdev->dev, r);
727+
if (IS_ERR(host->base)) {
728+
ret = PTR_ERR(host->base);
733729
goto out;
734730
}
735731

@@ -742,7 +738,8 @@ static int pxamci_probe(struct platform_device *pdev)
742738
writel(64, host->base + MMC_RESTO);
743739
writel(host->imask, host->base + MMC_I_MASK);
744740

745-
ret = request_irq(host->irq, pxamci_irq, 0, DRIVER_NAME, host);
741+
ret = devm_request_irq(&pdev->dev, host->irq, pxamci_irq, 0,
742+
DRIVER_NAME, host);
746743
if (ret)
747744
goto out;
748745

@@ -833,14 +830,9 @@ static int pxamci_probe(struct platform_device *pdev)
833830
dma_release_channel(host->dma_chan_rx);
834831
if (host->dma_chan_tx)
835832
dma_release_channel(host->dma_chan_tx);
836-
if (host->base)
837-
iounmap(host->base);
838-
if (host->clk)
839-
clk_put(host->clk);
840833
}
841834
if (mmc)
842835
mmc_free_host(mmc);
843-
release_resource(r);
844836
return ret;
845837
}
846838

@@ -859,9 +851,6 @@ static int pxamci_remove(struct platform_device *pdev)
859851
gpio_ro = host->pdata->gpio_card_ro;
860852
gpio_power = host->pdata->gpio_power;
861853
}
862-
if (host->vcc)
863-
regulator_put(host->vcc);
864-
865854
if (host->pdata && host->pdata->exit)
866855
host->pdata->exit(&pdev->dev, mmc);
867856

@@ -870,16 +859,10 @@ static int pxamci_remove(struct platform_device *pdev)
870859
END_CMD_RES|PRG_DONE|DATA_TRAN_DONE,
871860
host->base + MMC_I_MASK);
872861

873-
free_irq(host->irq, host);
874862
dmaengine_terminate_all(host->dma_chan_rx);
875863
dmaengine_terminate_all(host->dma_chan_tx);
876864
dma_release_channel(host->dma_chan_rx);
877865
dma_release_channel(host->dma_chan_tx);
878-
iounmap(host->base);
879-
880-
clk_put(host->clk);
881-
882-
release_resource(host->res);
883866

884867
mmc_free_host(mmc);
885868
}

0 commit comments

Comments
 (0)