Commit 7b3b7432 authored by Michal Simek's avatar Michal Simek Committed by Mark Brown

spi/xilinx: Simplify irq allocation

Use devm_request_irq() for irq allocation which
simplify driver code.
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent be3acdff
...@@ -344,7 +344,7 @@ static int xilinx_spi_probe(struct platform_device *pdev) ...@@ -344,7 +344,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
struct xilinx_spi *xspi; struct xilinx_spi *xspi;
struct xspi_platform_data *pdata; struct xspi_platform_data *pdata;
struct resource *res; struct resource *res;
int ret, irq, num_cs = 0, bits_per_word = 8; int ret, num_cs = 0, bits_per_word = 8;
struct spi_master *master; struct spi_master *master;
u32 tmp; u32 tmp;
u8 i; u8 i;
...@@ -364,10 +364,6 @@ static int xilinx_spi_probe(struct platform_device *pdev) ...@@ -364,10 +364,6 @@ static int xilinx_spi_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return -ENXIO;
master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi)); master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi));
if (!master) if (!master)
return -ENODEV; return -ENODEV;
...@@ -393,8 +389,6 @@ static int xilinx_spi_probe(struct platform_device *pdev) ...@@ -393,8 +389,6 @@ static int xilinx_spi_probe(struct platform_device *pdev)
master->num_chipselect = num_cs; master->num_chipselect = num_cs;
master->dev.of_node = pdev->dev.of_node; master->dev.of_node = pdev->dev.of_node;
xspi->irq = irq;
/* /*
* Detect endianess on the IP via loop bit in CR. Detection * Detect endianess on the IP via loop bit in CR. Detection
* must be done before reset is sent because incorrect reset * must be done before reset is sent because incorrect reset
...@@ -428,19 +422,25 @@ static int xilinx_spi_probe(struct platform_device *pdev) ...@@ -428,19 +422,25 @@ static int xilinx_spi_probe(struct platform_device *pdev)
goto put_master; goto put_master;
} }
/* SPI controller initializations */ /* SPI controller initializations */
xspi_init_hw(xspi); xspi_init_hw(xspi);
xspi->irq = platform_get_irq(pdev, 0);
if (xspi->irq < 0) {
ret = xspi->irq;
goto put_master;
}
/* Register for SPI Interrupt */ /* Register for SPI Interrupt */
ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); ret = devm_request_irq(&pdev->dev, xspi->irq, xilinx_spi_irq, 0,
dev_name(&pdev->dev), xspi);
if (ret) if (ret)
goto put_master; goto put_master;
ret = spi_bitbang_start(&xspi->bitbang); ret = spi_bitbang_start(&xspi->bitbang);
if (ret) { if (ret) {
dev_err(&pdev->dev, "spi_bitbang_start FAILED\n"); dev_err(&pdev->dev, "spi_bitbang_start FAILED\n");
goto free_irq; goto put_master;
} }
dev_info(&pdev->dev, "at 0x%08llX mapped to 0x%p, irq=%d\n", 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,8 +454,6 @@ static int xilinx_spi_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, master); platform_set_drvdata(pdev, master);
return 0; return 0;
free_irq:
free_irq(xspi->irq, xspi);
put_master: put_master:
spi_master_put(master); spi_master_put(master);
...@@ -466,9 +464,14 @@ static int xilinx_spi_remove(struct platform_device *pdev) ...@@ -466,9 +464,14 @@ static int xilinx_spi_remove(struct platform_device *pdev)
{ {
struct spi_master *master = platform_get_drvdata(pdev); struct spi_master *master = platform_get_drvdata(pdev);
struct xilinx_spi *xspi = spi_master_get_devdata(master); struct xilinx_spi *xspi = spi_master_get_devdata(master);
void __iomem *regs_base = xspi->regs;
spi_bitbang_stop(&xspi->bitbang); spi_bitbang_stop(&xspi->bitbang);
free_irq(xspi->irq, xspi);
/* Disable all the interrupts just in case */
xspi->write_fn(0, regs_base + XIPIF_V123B_IIER_OFFSET);
/* Disable the global IPIF interrupt */
xspi->write_fn(0, regs_base + XIPIF_V123B_DGIER_OFFSET);
spi_master_put(xspi->bitbang.master); spi_master_put(xspi->bitbang.master);
......
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