aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-xilinx.c
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-07-01 15:33:01 -0400
committerMark Brown <broonie@linaro.org>2013-07-15 06:45:52 -0400
commitc40537d008ab1b4fe2f12641cca1462de10a95f7 (patch)
tree41e0bfabd3fa7d74d71a9ff2bb0a2e237d8b3c52 /drivers/spi/spi-xilinx.c
parentad81f0545ef01ea651886dddac4bef6cec930092 (diff)
spi/xilinx: Convert to devm_ioremap_resource()
Saves code and reduces the possibility of error. Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-xilinx.c')
-rw-r--r--drivers/spi/spi-xilinx.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index fb56fcfdf65e..ad48710b2859 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -362,14 +362,10 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
362 xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs; 362 xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs;
363 init_completion(&xspi->done); 363 init_completion(&xspi->done);
364 364
365 if (!request_mem_region(mem->start, resource_size(mem), 365 xspi->regs = devm_ioremap_resource(dev, mem);
366 XILINX_SPI_NAME)) 366 if (IS_ERR(xspi->regs)) {
367 ret = PTR_ERR(xspi->regs);
367 goto put_master; 368 goto put_master;
368
369 xspi->regs = ioremap(mem->start, resource_size(mem));
370 if (xspi->regs == NULL) {
371 dev_warn(dev, "ioremap failure\n");
372 goto map_failed;
373 } 369 }
374 370
375 master->bus_num = bus_num; 371 master->bus_num = bus_num;
@@ -408,7 +404,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
408 xspi->tx_fn = xspi_tx32; 404 xspi->tx_fn = xspi_tx32;
409 xspi->rx_fn = xspi_rx32; 405 xspi->rx_fn = xspi_rx32;
410 } else 406 } else
411 goto unmap_io; 407 goto put_master;
412 408
413 409
414 /* SPI controller initializations */ 410 /* SPI controller initializations */
@@ -417,7 +413,7 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
417 /* Register for SPI Interrupt */ 413 /* Register for SPI Interrupt */
418 ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); 414 ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi);
419 if (ret) 415 if (ret)
420 goto unmap_io; 416 goto put_master;
421 417
422 ret = spi_bitbang_start(&xspi->bitbang); 418 ret = spi_bitbang_start(&xspi->bitbang);
423 if (ret) { 419 if (ret) {
@@ -431,10 +427,6 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
431 427
432free_irq: 428free_irq:
433 free_irq(xspi->irq, xspi); 429 free_irq(xspi->irq, xspi);
434unmap_io:
435 iounmap(xspi->regs);
436map_failed:
437 release_mem_region(mem->start, resource_size(mem));
438put_master: 430put_master:
439 spi_master_put(master); 431 spi_master_put(master);
440 return NULL; 432 return NULL;
@@ -449,9 +441,7 @@ void xilinx_spi_deinit(struct spi_master *master)
449 441
450 spi_bitbang_stop(&xspi->bitbang); 442 spi_bitbang_stop(&xspi->bitbang);
451 free_irq(xspi->irq, xspi); 443 free_irq(xspi->irq, xspi);
452 iounmap(xspi->regs);
453 444
454 release_mem_region(xspi->mem.start, resource_size(&xspi->mem));
455 spi_master_put(xspi->bitbang.master); 445 spi_master_put(xspi->bitbang.master);
456} 446}
457EXPORT_SYMBOL(xilinx_spi_deinit); 447EXPORT_SYMBOL(xilinx_spi_deinit);