mmc: pxamci: Use devm_mmc_alloc_host() helper

Use new function devm_mmc_alloc_host() to simplify the code.

Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/3d8a815f898b977f76c7ed07f56185990a34abac.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Binbin Zhou 2025-06-03 20:27:17 +08:00 committed by Ulf Hansson
parent fb2f73107f
commit 58c40f3faf

View File

@ -615,11 +615,9 @@ static int pxamci_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return irq; return irq;
mmc = mmc_alloc_host(sizeof(struct pxamci_host), dev); mmc = devm_mmc_alloc_host(dev, sizeof(*host));
if (!mmc) { if (!mmc)
ret = -ENOMEM; return -ENOMEM;
goto out;
}
mmc->ops = &pxamci_ops; mmc->ops = &pxamci_ops;
@ -646,7 +644,7 @@ static int pxamci_probe(struct platform_device *pdev)
ret = pxamci_of_init(pdev, mmc); ret = pxamci_of_init(pdev, mmc);
if (ret) if (ret)
goto out; return ret;
host = mmc_priv(mmc); host = mmc_priv(mmc);
host->mmc = mmc; host->mmc = mmc;
@ -655,9 +653,8 @@ static int pxamci_probe(struct platform_device *pdev)
host->clk = devm_clk_get(dev, NULL); host->clk = devm_clk_get(dev, NULL);
if (IS_ERR(host->clk)) { if (IS_ERR(host->clk)) {
ret = PTR_ERR(host->clk);
host->clk = NULL; host->clk = NULL;
goto out; return PTR_ERR(host->clk);
} }
host->clkrate = clk_get_rate(host->clk); host->clkrate = clk_get_rate(host->clk);
@ -670,7 +667,7 @@ static int pxamci_probe(struct platform_device *pdev)
ret = pxamci_init_ocr(host); ret = pxamci_init_ocr(host);
if (ret < 0) if (ret < 0)
goto out; return ret;
mmc->caps = 0; mmc->caps = 0;
host->cmdat = 0; host->cmdat = 0;
@ -686,10 +683,8 @@ static int pxamci_probe(struct platform_device *pdev)
host->imask = MMC_I_MASK_ALL; host->imask = MMC_I_MASK_ALL;
host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r); host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
if (IS_ERR(host->base)) { if (IS_ERR(host->base))
ret = PTR_ERR(host->base); return PTR_ERR(host->base);
goto out;
}
host->res = r; host->res = r;
/* /*
@ -704,16 +699,15 @@ static int pxamci_probe(struct platform_device *pdev)
ret = devm_request_irq(dev, irq, pxamci_irq, 0, ret = devm_request_irq(dev, irq, pxamci_irq, 0,
DRIVER_NAME, host); DRIVER_NAME, host);
if (ret) if (ret)
goto out; return ret;
platform_set_drvdata(pdev, mmc); platform_set_drvdata(pdev, mmc);
host->dma_chan_rx = dma_request_chan(dev, "rx"); host->dma_chan_rx = dma_request_chan(dev, "rx");
if (IS_ERR(host->dma_chan_rx)) { if (IS_ERR(host->dma_chan_rx)) {
dev_err(dev, "unable to request rx dma channel\n");
ret = PTR_ERR(host->dma_chan_rx);
host->dma_chan_rx = NULL; host->dma_chan_rx = NULL;
goto out; return dev_err_probe(dev, PTR_ERR(host->dma_chan_rx),
"unable to request rx dma channel\n");
} }
host->dma_chan_tx = dma_request_chan(dev, "tx"); host->dma_chan_tx = dma_request_chan(dev, "tx");
@ -771,14 +765,10 @@ static int pxamci_probe(struct platform_device *pdev)
return 0; return 0;
out: out:
if (host) {
if (host->dma_chan_rx) if (host->dma_chan_rx)
dma_release_channel(host->dma_chan_rx); dma_release_channel(host->dma_chan_rx);
if (host->dma_chan_tx) if (host->dma_chan_tx)
dma_release_channel(host->dma_chan_tx); dma_release_channel(host->dma_chan_tx);
}
if (mmc)
mmc_free_host(mmc);
return ret; return ret;
} }
@ -803,8 +793,6 @@ static void pxamci_remove(struct platform_device *pdev)
dmaengine_terminate_all(host->dma_chan_tx); dmaengine_terminate_all(host->dma_chan_tx);
dma_release_channel(host->dma_chan_rx); dma_release_channel(host->dma_chan_rx);
dma_release_channel(host->dma_chan_tx); dma_release_channel(host->dma_chan_tx);
mmc_free_host(mmc);
} }
} }