spi: davinci: Use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
a4ee96e488
commit
5b3bb5963f
1 changed files with 11 additions and 30 deletions
|
@ -853,7 +853,7 @@ static int davinci_spi_probe(struct platform_device *pdev)
|
||||||
struct spi_master *master;
|
struct spi_master *master;
|
||||||
struct davinci_spi *dspi;
|
struct davinci_spi *dspi;
|
||||||
struct davinci_spi_platform_data *pdata;
|
struct davinci_spi_platform_data *pdata;
|
||||||
struct resource *r, *mem;
|
struct resource *r;
|
||||||
resource_size_t dma_rx_chan = SPI_NO_RESOURCE;
|
resource_size_t dma_rx_chan = SPI_NO_RESOURCE;
|
||||||
resource_size_t dma_tx_chan = SPI_NO_RESOURCE;
|
resource_size_t dma_tx_chan = SPI_NO_RESOURCE;
|
||||||
int i = 0, ret = 0;
|
int i = 0, ret = 0;
|
||||||
|
@ -894,39 +894,33 @@ static int davinci_spi_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
dspi->pbase = r->start;
|
dspi->pbase = r->start;
|
||||||
|
|
||||||
mem = request_mem_region(r->start, resource_size(r), pdev->name);
|
dspi->base = devm_ioremap_resource(&pdev->dev, r);
|
||||||
if (mem == NULL) {
|
if (IS_ERR(dspi->base)) {
|
||||||
ret = -EBUSY;
|
ret = PTR_ERR(dspi->base);
|
||||||
goto free_master;
|
goto free_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
dspi->base = ioremap(r->start, resource_size(r));
|
|
||||||
if (dspi->base == NULL) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto release_region;
|
|
||||||
}
|
|
||||||
|
|
||||||
dspi->irq = platform_get_irq(pdev, 0);
|
dspi->irq = platform_get_irq(pdev, 0);
|
||||||
if (dspi->irq <= 0) {
|
if (dspi->irq <= 0) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto unmap_io;
|
goto free_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = request_threaded_irq(dspi->irq, davinci_spi_irq, dummy_thread_fn,
|
ret = devm_request_threaded_irq(&pdev->dev, dspi->irq, davinci_spi_irq,
|
||||||
0, dev_name(&pdev->dev), dspi);
|
dummy_thread_fn, 0, dev_name(&pdev->dev), dspi);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto unmap_io;
|
goto free_master;
|
||||||
|
|
||||||
dspi->bitbang.master = master;
|
dspi->bitbang.master = master;
|
||||||
if (dspi->bitbang.master == NULL) {
|
if (dspi->bitbang.master == NULL) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto irq_free;
|
goto free_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
dspi->clk = clk_get(&pdev->dev, NULL);
|
dspi->clk = devm_clk_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(dspi->clk)) {
|
if (IS_ERR(dspi->clk)) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto irq_free;
|
goto free_master;
|
||||||
}
|
}
|
||||||
clk_prepare_enable(dspi->clk);
|
clk_prepare_enable(dspi->clk);
|
||||||
|
|
||||||
|
@ -1015,13 +1009,6 @@ static int davinci_spi_probe(struct platform_device *pdev)
|
||||||
dma_release_channel(dspi->dma_tx);
|
dma_release_channel(dspi->dma_tx);
|
||||||
free_clk:
|
free_clk:
|
||||||
clk_disable_unprepare(dspi->clk);
|
clk_disable_unprepare(dspi->clk);
|
||||||
clk_put(dspi->clk);
|
|
||||||
irq_free:
|
|
||||||
free_irq(dspi->irq, dspi);
|
|
||||||
unmap_io:
|
|
||||||
iounmap(dspi->base);
|
|
||||||
release_region:
|
|
||||||
release_mem_region(dspi->pbase, resource_size(r));
|
|
||||||
free_master:
|
free_master:
|
||||||
spi_master_put(master);
|
spi_master_put(master);
|
||||||
err:
|
err:
|
||||||
|
@ -1041,7 +1028,6 @@ static int davinci_spi_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct davinci_spi *dspi;
|
struct davinci_spi *dspi;
|
||||||
struct spi_master *master;
|
struct spi_master *master;
|
||||||
struct resource *r;
|
|
||||||
|
|
||||||
master = platform_get_drvdata(pdev);
|
master = platform_get_drvdata(pdev);
|
||||||
dspi = spi_master_get_devdata(master);
|
dspi = spi_master_get_devdata(master);
|
||||||
|
@ -1049,11 +1035,6 @@ static int davinci_spi_remove(struct platform_device *pdev)
|
||||||
spi_bitbang_stop(&dspi->bitbang);
|
spi_bitbang_stop(&dspi->bitbang);
|
||||||
|
|
||||||
clk_disable_unprepare(dspi->clk);
|
clk_disable_unprepare(dspi->clk);
|
||||||
clk_put(dspi->clk);
|
|
||||||
free_irq(dspi->irq, dspi);
|
|
||||||
iounmap(dspi->base);
|
|
||||||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
||||||
release_mem_region(dspi->pbase, resource_size(r));
|
|
||||||
spi_master_put(master);
|
spi_master_put(master);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue