aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-xilinx.c
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2013-07-09 12:05:16 -0400
committerMark Brown <broonie@linaro.org>2013-07-15 06:45:53 -0400
commit7b3b7432ae7848a269671921393148ff1aae3881 (patch)
tree87a37679c4905abced74ed9d4257fce0e1a65683 /drivers/spi/spi-xilinx.c
parentbe3acdff943f46c32e9b2f453f0033bbae01a804 (diff)
spi/xilinx: Simplify irq allocation
Use devm_request_irq() for irq allocation which simplify driver code. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/spi/spi-xilinx.c')
-rw-r--r--drivers/spi/spi-xilinx.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index 0b23408d357c..e5d3716da21a 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -344,7 +344,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
344 struct xilinx_spi *xspi; 344 struct xilinx_spi *xspi;
345 struct xspi_platform_data *pdata; 345 struct xspi_platform_data *pdata;
346 struct resource *res; 346 struct resource *res;
347 int ret, irq, num_cs = 0, bits_per_word = 8; 347 int ret, num_cs = 0, bits_per_word = 8;
348 struct spi_master *master; 348 struct spi_master *master;
349 u32 tmp; 349 u32 tmp;
350 u8 i; 350 u8 i;
@@ -364,10 +364,6 @@ static int xilinx_spi_probe(struct platform_device *pdev)
364 return -EINVAL; 364 return -EINVAL;
365 } 365 }
366 366
367 irq = platform_get_irq(pdev, 0);
368 if (irq < 0)
369 return -ENXIO;
370
371 master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi)); 367 master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi));
372 if (!master) 368 if (!master)
373 return -ENODEV; 369 return -ENODEV;
@@ -393,8 +389,6 @@ static int xilinx_spi_probe(struct platform_device *pdev)
393 master->num_chipselect = num_cs; 389 master->num_chipselect = num_cs;
394 master->dev.of_node = pdev->dev.of_node; 390 master->dev.of_node = pdev->dev.of_node;
395 391
396 xspi->irq = irq;
397
398 /* 392 /*
399 * Detect endianess on the IP via loop bit in CR. Detection 393 * Detect endianess on the IP via loop bit in CR. Detection
400 * must be done before reset is sent because incorrect reset 394 * must be done before reset is sent because incorrect reset
@@ -428,19 +422,25 @@ static int xilinx_spi_probe(struct platform_device *pdev)
428 goto put_master; 422 goto put_master;
429 } 423 }
430 424
431
432 /* SPI controller initializations */ 425 /* SPI controller initializations */
433 xspi_init_hw(xspi); 426 xspi_init_hw(xspi);
434 427
428 xspi->irq = platform_get_irq(pdev, 0);
429 if (xspi->irq < 0) {
430 ret = xspi->irq;
431 goto put_master;
432 }
433
435 /* Register for SPI Interrupt */ 434 /* Register for SPI Interrupt */
436 ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); 435 ret = devm_request_irq(&pdev->dev, xspi->irq, xilinx_spi_irq, 0,
436 dev_name(&pdev->dev), xspi);
437 if (ret) 437 if (ret)
438 goto put_master; 438 goto put_master;
439 439
440 ret = spi_bitbang_start(&xspi->bitbang); 440 ret = spi_bitbang_start(&xspi->bitbang);
441 if (ret) { 441 if (ret) {
442 dev_err(&pdev->dev, "spi_bitbang_start FAILED\n"); 442 dev_err(&pdev->dev, "spi_bitbang_start FAILED\n");
443 goto free_irq; 443 goto put_master;
444 } 444 }
445 445
446 dev_info(&pdev->dev, "at 0x%08llX mapped to 0x%p, irq=%d\n", 446 dev_info(&pdev->dev, "at 0x%08llX mapped to 0x%p, irq=%d\n",
@@ -454,8 +454,6 @@ static int xilinx_spi_probe(struct platform_device *pdev)
454 platform_set_drvdata(pdev, master); 454 platform_set_drvdata(pdev, master);
455 return 0; 455 return 0;
456 456
457free_irq:
458 free_irq(xspi->irq, xspi);
459put_master: 457put_master:
460 spi_master_put(master); 458 spi_master_put(master);
461 459
@@ -466,9 +464,14 @@ static int xilinx_spi_remove(struct platform_device *pdev)
466{ 464{
467 struct spi_master *master = platform_get_drvdata(pdev); 465 struct spi_master *master = platform_get_drvdata(pdev);
468 struct xilinx_spi *xspi = spi_master_get_devdata(master); 466 struct xilinx_spi *xspi = spi_master_get_devdata(master);
467 void __iomem *regs_base = xspi->regs;
469 468
470 spi_bitbang_stop(&xspi->bitbang); 469 spi_bitbang_stop(&xspi->bitbang);
471 free_irq(xspi->irq, xspi); 470
471 /* Disable all the interrupts just in case */
472 xspi->write_fn(0, regs_base + XIPIF_V123B_IIER_OFFSET);
473 /* Disable the global IPIF interrupt */
474 xspi->write_fn(0, regs_base + XIPIF_V123B_DGIER_OFFSET);
472 475
473 spi_master_put(xspi->bitbang.master); 476 spi_master_put(xspi->bitbang.master);
474 477