mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
mmc: pxamci: Simplify pxamci_probe() error handling using devm APIs
commit9e80562521upstream. This patch refactors pxamci_probe() to use devm-managed resource allocation (e.g. devm_dma_request_chan) and dev_err_probe() for improved readability and automatic cleanup on probe failure. It also removes redundant NULL assignments and manual resource release logic from pxamci_probe(), and eliminates the corresponding release calls from pxamci_remove(). Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202510041841.pRlunIfl-lkp@intel.com/ Fixes:58c40f3faf("mmc: pxamci: Use devm_mmc_alloc_host() helper") Suggested-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Signed-off-by: Rakuram Eswaran <rakuram.e96@gmail.com> Reviewed-by: Khalid Aziz <khalid@kernel.org> Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9e3901a040
commit
3b935c5353
@@ -652,10 +652,9 @@ static int pxamci_probe(struct platform_device *pdev)
|
||||
host->clkrt = CLKRT_OFF;
|
||||
|
||||
host->clk = devm_clk_get(dev, NULL);
|
||||
if (IS_ERR(host->clk)) {
|
||||
host->clk = NULL;
|
||||
return PTR_ERR(host->clk);
|
||||
}
|
||||
if (IS_ERR(host->clk))
|
||||
return dev_err_probe(dev, PTR_ERR(host->clk),
|
||||
"Failed to acquire clock\n");
|
||||
|
||||
host->clkrate = clk_get_rate(host->clk);
|
||||
|
||||
@@ -703,46 +702,37 @@ static int pxamci_probe(struct platform_device *pdev)
|
||||
|
||||
platform_set_drvdata(pdev, mmc);
|
||||
|
||||
host->dma_chan_rx = dma_request_chan(dev, "rx");
|
||||
if (IS_ERR(host->dma_chan_rx)) {
|
||||
host->dma_chan_rx = NULL;
|
||||
host->dma_chan_rx = devm_dma_request_chan(dev, "rx");
|
||||
if (IS_ERR(host->dma_chan_rx))
|
||||
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");
|
||||
if (IS_ERR(host->dma_chan_tx)) {
|
||||
dev_err(dev, "unable to request tx dma channel\n");
|
||||
ret = PTR_ERR(host->dma_chan_tx);
|
||||
host->dma_chan_tx = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
host->dma_chan_tx = devm_dma_request_chan(dev, "tx");
|
||||
if (IS_ERR(host->dma_chan_tx))
|
||||
return dev_err_probe(dev, PTR_ERR(host->dma_chan_tx),
|
||||
"unable to request tx dma channel\n");
|
||||
|
||||
if (host->pdata) {
|
||||
host->detect_delay_ms = host->pdata->detect_delay_ms;
|
||||
|
||||
host->power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(host->power)) {
|
||||
ret = PTR_ERR(host->power);
|
||||
dev_err(dev, "Failed requesting gpio_power\n");
|
||||
goto out;
|
||||
}
|
||||
if (IS_ERR(host->power))
|
||||
return dev_err_probe(dev, PTR_ERR(host->power),
|
||||
"Failed requesting gpio_power\n");
|
||||
|
||||
/* FIXME: should we pass detection delay to debounce? */
|
||||
ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0);
|
||||
if (ret && ret != -ENOENT) {
|
||||
dev_err(dev, "Failed requesting gpio_cd\n");
|
||||
goto out;
|
||||
}
|
||||
if (ret && ret != -ENOENT)
|
||||
return dev_err_probe(dev, ret, "Failed requesting gpio_cd\n");
|
||||
|
||||
if (!host->pdata->gpio_card_ro_invert)
|
||||
mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
|
||||
|
||||
ret = mmc_gpiod_request_ro(mmc, "wp", 0, 0);
|
||||
if (ret && ret != -ENOENT) {
|
||||
dev_err(dev, "Failed requesting gpio_ro\n");
|
||||
goto out;
|
||||
}
|
||||
if (ret && ret != -ENOENT)
|
||||
return dev_err_probe(dev, ret, "Failed requesting gpio_ro\n");
|
||||
|
||||
if (!ret)
|
||||
host->use_ro_gpio = true;
|
||||
|
||||
@@ -759,16 +749,8 @@ static int pxamci_probe(struct platform_device *pdev)
|
||||
if (ret) {
|
||||
if (host->pdata && host->pdata->exit)
|
||||
host->pdata->exit(dev, mmc);
|
||||
goto out;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
if (host->dma_chan_rx)
|
||||
dma_release_channel(host->dma_chan_rx);
|
||||
if (host->dma_chan_tx)
|
||||
dma_release_channel(host->dma_chan_tx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -791,8 +773,6 @@ static void pxamci_remove(struct platform_device *pdev)
|
||||
|
||||
dmaengine_terminate_all(host->dma_chan_rx);
|
||||
dmaengine_terminate_all(host->dma_chan_tx);
|
||||
dma_release_channel(host->dma_chan_rx);
|
||||
dma_release_channel(host->dma_chan_tx);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user