Xilinx: SPI: driver not releasing memory
Subsystems (2)
PATCH 1/1 Xilinx: SPI: driver not releasing memory
The driver was not releasing memory when it was removed or when there was a failure during probe. This fixes it.
---
This is an incremental patch to the patch (updated driver for device tree) that is in the next branch.
--- drivers/spi/xilinx_spi.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/spi/xilinx_spi.c +7 -2
@@ -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;
@@ -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;
@@ -397,6 +397,8 @@ free_irq: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;
@@ -406,6 +408,7 @@ 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);
@@ -413,6 +416,8 @@ static int __devexit xilinx_spi_remove(struct of_device *ofdev)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);
Signature · 5 lines
1.5.3.4 This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
Quoted 4 lines · John Linn
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 <[email protected]>
Looks good.
I'll pick this up into my -next branch and ask Ben to pull it in the next week or so.
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
David,
Are you okay with this patch and okay with it going in via Ben's powerpc tree? Ben wants to ensure that changes outside arch/powerpc/ are properly acked before going into his tree.
Thanks,
g.
On Sat, Feb 28, 2009 at 9:09 PM, Grant Likely <[email protected]> w= rote:
drivers/spi/xilinx_spi.c static int __init xilinx_spi_of_probe(struct of_devic=
Quoted 25 lines · John Linn
Quoted 4 lines
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 <[email protected]>Looks good.
Acked-by Grant Likely <[email protected]>I'll pick this up into my -next branch and ask Ben to pull it in the next week or so.
---
This is an incremental patch to the patch (updated driver for device tree) that is in the next branch.
---
=A0drivers/spi/xilinx_spi.c | =A0 =A09 +++++++-- =A01 files changed, 7 insertions(+), 2 deletions(-)drivers/spi/xilinx_spi.c +0
-0@@ -354,7 +354,7 @@ static int __init xilinx_spi_of_probe(struct of_devic=
e *ofdev,
Quoted 3 lines
drivers/spi/xilinx_spi.c +0
-0=A0 =A0 =A0 =A0if (xspi->regs =3D=3D NULL) { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rc =3D -ENOMEM;=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_warn(&ofdev->dev, "ioremap failure\n")=
;
drivers/spi/xilinx_spi.c static int __init xilinx_spi_of_probe(struct of_devic=
Quoted 6 lines
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto
put_master;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 gotorelease_mem;
=A0 =A0 =A0 =A0}
=A0 =A0 =A0 =A0xspi->irq =3Dr_irq->start;drivers/spi/xilinx_spi.c +0
-0@@ -365,7 +365,7 @@ static int __init xilinx_spi_of_probe(struct of_devic=
e *ofdev,
Quoted 1 line
=A0 =A0 =A0 =A0prop =3D of_get_property(ofdev->node, "xlnx,num-ss-bits", =
&len);
Quoted 2 lines
=A0 =A0 =A0 =A0if (!prop || len <
sizeof(*prop)) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bit=
s' property\n");
drivers/spi/xilinx_spi.c static int __devexit xilinx_spi_remove(struct of_devi=
Quoted 15 lines
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto
put_master;
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 gotounmap_io;
=A0 =A0 =A0 =A0}
=A0 =A0 =A0 =A0master->num_chipselect =3D *prop;drivers/spi/xilinx_spi.c +0
-0@@ -397,6 +397,8 @@ free_irq: =A0 =A0 =A0 =A0free_irq(xspi->irq, xspi);=A0unmap_io:
=A0 =A0 =A0 =A0iounmap(xspi->regs);
+release_mem:
+ =A0 =A0 =A0release_mem_region(r_mem->start, resource_size(r_mem)); =A0put_master:
=A0 =A0 =A0 =A0spi_master_put(master);
=A0 =A0 =A0 =A0return rc;drivers/spi/xilinx_spi.c +0
-0@@ -406,6 +408,7 @@ static int __devexit xilinx_spi_remove(struct of_devi=
ce *ofdev)
drivers/spi/xilinx_spi.c static int __devexit xilinx_spi_remove(struct of_devi=
Quoted 8 lines
drivers/spi/xilinx_spi.c +1
-0=A0{ =A0 =A0 =A0 =A0struct xilinx_spi *xspi; =A0 =A0 =A0 =A0struct spi_master *master; + =A0 =A0 =A0 struct resource r_mem; =A0 =A0 =A0 =A0master =3D platform_get_drvdata(ofdev); =A0 =A0 =A0 =A0xspi =3D spi_master_get_devdata(master);@@ -413,6 +416,8 @@ static int __devexit xilinx_spi_remove(struct of_devi=
ce *ofdev)
drivers/spi/xilinx_spi.c static int __devexit xilinx_spi_remove(struct of_devi= · line 420
Quoted 5 lines
drivers/spi/xilinx_spi.c +2
-0=A0 =A0 =A0 =A0spi_bitbang_stop(&xspi->bitbang); =A0 =A0 =A0 =A0free_irq(xspi->irq, xspi); =A0 =A0 =A0 =A0iounmap(xspi->regs); + =A0 =A0 =A0 if (!of_address_to_resource(ofdev->node, 0, &r_mem)) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 release_mem_region(r_mem.start, resource_si=
ze(&r_mem));
Quoted 9 lines
drivers/spi/xilinx_spi.c +0
-1=A0 =A0 =A0 =A0dev_set_drvdata (&ofdev->dev,0 ); =A0 =A0 =A0 =A0spi_master_put(xspi->bitbang.master); --1.5.3.4
This email and any attachments are intended for the sole use of the named=
recipient(s) and contain(s) confidential information that may be proprieta=
ry, privileged or copyrighted under applicable law. If you are not the inte= nded recipient, do not read, copy, or forward this email message or any att= achments. Delete this email message and any attachments immediately.
Quoted 3 lines
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
David Brownell
Acked-byQuoted 5 lines · Grant Likely
David,
Are you okay with this patch and okay with it going in via Ben's powerpc tree? Ben wants to ensure that changes outside
arch/powerpc/are properly acked before going into his tree.
Sure, no problem.
Quoted 13 lines
Thanks,
g.Quoted 9 lines · Grant Likely
Quoted 4 lines · John Linn
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 <[email protected]>Looks good.
Acked-by Grant Likely <[email protected]>
Quoted 75 lines
Quoted 67 lines
I'll pick this up into my -next branch and ask Ben to pull it in the next week or so.
---
This is an incremental patch to the patch (updated driver for device tree) that is in the next branch.
---
drivers/spi/xilinx_spi.c | 9 +++++++--1 files changed, 7 insertions(+), 2 deletions(-)drivers/spi/xilinx_spi.c +2
-2@@ -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;@@ -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;@@ -397,6 +397,8 @@ free_irq: 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;drivers/spi/xilinx_spi.c +3
-1@@ -406,6 +408,7 @@ 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);@@ -413,6 +416,8 @@ static int __devexit xilinx_spi_remove(struct of_device *ofdev) 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); --1.5.3.4
This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.