Skip to content

Commit

Permalink
powerpc/virtex/spi: Xilinx SPI driver not releasing memory
Browse files Browse the repository at this point in the history
The driver was not releasing memory when it was removed or
when there was a failure during probe. This fixes it.

Signed-off-by: John Linn <john.linn@xilinx.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
  • Loading branch information
John Linn authored and Grant Likely committed Mar 11, 2009
1 parent e7eec2f commit 1df879e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/spi/xilinx_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static int __init xilinx_spi_of_probe(struct of_device *ofdev,
if (xspi->regs == NULL) {
rc = -ENOMEM;
dev_warn(&ofdev->dev, "ioremap failure\n");
goto put_master;
goto release_mem;
}
xspi->irq = r_irq->start;

Expand All @@ -365,7 +365,7 @@ static int __init xilinx_spi_of_probe(struct of_device *ofdev,
prop = of_get_property(ofdev->node, "xlnx,num-ss-bits", &len);
if (!prop || len < sizeof(*prop)) {
dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
goto put_master;
goto unmap_io;
}
master->num_chipselect = *prop;

Expand Down Expand Up @@ -397,6 +397,8 @@ static int __init xilinx_spi_of_probe(struct of_device *ofdev,
free_irq(xspi->irq, xspi);
unmap_io:
iounmap(xspi->regs);
release_mem:
release_mem_region(r_mem->start, resource_size(r_mem));
put_master:
spi_master_put(master);
return rc;
Expand All @@ -406,13 +408,16 @@ static int __devexit xilinx_spi_remove(struct of_device *ofdev)
{
struct xilinx_spi *xspi;
struct spi_master *master;
struct resource r_mem;

master = platform_get_drvdata(ofdev);
xspi = spi_master_get_devdata(master);

spi_bitbang_stop(&xspi->bitbang);
free_irq(xspi->irq, xspi);
iounmap(xspi->regs);
if (!of_address_to_resource(ofdev->node, 0, &r_mem))
release_mem_region(r_mem.start, resource_size(&r_mem));
dev_set_drvdata(&ofdev->dev, 0);
spi_master_put(xspi->bitbang.master);

Expand Down

0 comments on commit 1df879e

Please sign in to comment.