Commit c40537d0 authored by Mark Brown's avatar Mark Brown

spi/xilinx: Convert to devm_ioremap_resource()

Saves code and reduces the possibility of error.
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent ad81f054
...@@ -362,14 +362,10 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, ...@@ -362,14 +362,10 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs; xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs;
init_completion(&xspi->done); init_completion(&xspi->done);
if (!request_mem_region(mem->start, resource_size(mem), xspi->regs = devm_ioremap_resource(dev, mem);
XILINX_SPI_NAME)) if (IS_ERR(xspi->regs)) {
ret = PTR_ERR(xspi->regs);
goto put_master; goto put_master;
xspi->regs = ioremap(mem->start, resource_size(mem));
if (xspi->regs == NULL) {
dev_warn(dev, "ioremap failure\n");
goto map_failed;
} }
master->bus_num = bus_num; master->bus_num = bus_num;
...@@ -408,7 +404,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, ...@@ -408,7 +404,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
xspi->tx_fn = xspi_tx32; xspi->tx_fn = xspi_tx32;
xspi->rx_fn = xspi_rx32; xspi->rx_fn = xspi_rx32;
} else } else
goto unmap_io; goto put_master;
/* SPI controller initializations */ /* SPI controller initializations */
...@@ -417,7 +413,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, ...@@ -417,7 +413,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
/* Register for SPI Interrupt */ /* Register for SPI Interrupt */
ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi);
if (ret) if (ret)
goto unmap_io; goto put_master;
ret = spi_bitbang_start(&xspi->bitbang); ret = spi_bitbang_start(&xspi->bitbang);
if (ret) { if (ret) {
...@@ -431,10 +427,6 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem, ...@@ -431,10 +427,6 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
free_irq: free_irq:
free_irq(xspi->irq, xspi); free_irq(xspi->irq, xspi);
unmap_io:
iounmap(xspi->regs);
map_failed:
release_mem_region(mem->start, resource_size(mem));
put_master: put_master:
spi_master_put(master); spi_master_put(master);
return NULL; return NULL;
...@@ -449,9 +441,7 @@ void xilinx_spi_deinit(struct spi_master *master) ...@@ -449,9 +441,7 @@ void xilinx_spi_deinit(struct spi_master *master)
spi_bitbang_stop(&xspi->bitbang); spi_bitbang_stop(&xspi->bitbang);
free_irq(xspi->irq, xspi); free_irq(xspi->irq, xspi);
iounmap(xspi->regs);
release_mem_region(xspi->mem.start, resource_size(&xspi->mem));
spi_master_put(xspi->bitbang.master); spi_master_put(xspi->bitbang.master);
} }
EXPORT_SYMBOL(xilinx_spi_deinit); EXPORT_SYMBOL(xilinx_spi_deinit);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment