[PATCH 4/8] pcmcia: pxa2xx: convert memory allocation to devm_* API

2015-03-26 Thread Russell King
Convert the pxa2xx socket driver memory allocation to use devm_kzalloc()
to simplify the cleanup path.

Signed-off-by: Russell King 
---
 drivers/pcmcia/pxa2xx_base.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 197c77a64ce0..dfcf07828605 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -302,7 +302,8 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device 
*dev)
 
pxa2xx_drv_pcmcia_ops(ops);
 
-   sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
+   sinfo = devm_kzalloc(&pdev->dev, SKT_DEV_INFO_SIZE(ops->nr),
+GFP_KERNEL);
if (!sinfo)
return -ENOMEM;
 
@@ -330,7 +331,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device 
*dev)
 err1:
while (--i >= 0)
soc_pcmcia_remove_one(&sinfo->skt[i]);
-   kfree(sinfo);
+
 err0:
return ret;
 }
@@ -340,12 +341,9 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device 
*dev)
struct skt_dev_info *sinfo = platform_get_drvdata(dev);
int i;
 
-   platform_set_drvdata(dev, NULL);
-
for (i = 0; i < sinfo->nskt; i++)
soc_pcmcia_remove_one(&sinfo->skt[i]);
 
-   kfree(sinfo);
return 0;
 }
 
-- 
1.8.3.1


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


[PATCH 4/8] pcmcia: pxa2xx: convert memory allocation to devm_* API

2015-07-15 Thread Russell King
Convert the pxa2xx socket driver memory allocation to use devm_kzalloc()
to simplify the cleanup path.

Signed-off-by: Russell King 
---
 drivers/pcmcia/pxa2xx_base.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 197c77a64ce0..0f42d55e7c7f 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -302,7 +302,8 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device 
*dev)
 
pxa2xx_drv_pcmcia_ops(ops);
 
-   sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
+   sinfo = devm_kzalloc(&dev->dev, SKT_DEV_INFO_SIZE(ops->nr),
+GFP_KERNEL);
if (!sinfo)
return -ENOMEM;
 
@@ -330,7 +331,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device 
*dev)
 err1:
while (--i >= 0)
soc_pcmcia_remove_one(&sinfo->skt[i]);
-   kfree(sinfo);
+
 err0:
return ret;
 }
@@ -340,12 +341,9 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device 
*dev)
struct skt_dev_info *sinfo = platform_get_drvdata(dev);
int i;
 
-   platform_set_drvdata(dev, NULL);
-
for (i = 0; i < sinfo->nskt; i++)
soc_pcmcia_remove_one(&sinfo->skt[i]);
 
-   kfree(sinfo);
return 0;
 }
 
-- 
2.1.0


___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 4/8] pcmcia: pxa2xx: convert memory allocation to devm_* API

2015-03-28 Thread Robert Jarzmik
Russell King  writes:

> Convert the pxa2xx socket driver memory allocation to use devm_kzalloc()
> to simplify the cleanup path.
>
> Signed-off-by: Russell King 
> ---
>  drivers/pcmcia/pxa2xx_base.c | 8 +++-
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
> index 197c77a64ce0..dfcf07828605 100644
> --- a/drivers/pcmcia/pxa2xx_base.c
> +++ b/drivers/pcmcia/pxa2xx_base.c
> @@ -302,7 +302,8 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device 
> *dev)
>  
>   pxa2xx_drv_pcmcia_ops(ops);
>  
> - sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
> + sinfo = devm_kzalloc(&pdev->dev, SKT_DEV_INFO_SIZE(ops->nr),
There is a typo here : &pdev->dev should be &dev->dev.

Now given that fix, you can add my :
Tested-by: Robert Jarzmik 

This test of mine is rather cheap :
 - it relies on 4.0-rc4
 - I don't have any PCMCIA card to insert in the lubbock, hence the "cheap"
 - I judge that pcmcia is working because :
   - cat /proc/iomem gives:
 1000-10001fff : sa
   1400-15ff : 0400
   1800-19ff : 0800
   1a00-1bff : 0a00
 1a00-1bff : sa-ps2
   1c00-1dff : 0c00
 1c00-1dff : sa-ps2
   10001600-100017ff : irq
   10001800-100019ff : 1800
 10001800-100019ff : sa-pcmcia
- I don't see any error message in kernel log

As a side note mainly to myself, the pcmcia is broken on pxa2xx architectures
and panics the kernel at boot time because :
 - in drivers/pcmcia/sa_lubbock.c I see :
   pcmcia_lubbock_init()
 pxa2xx_configure_sockets(&sadev->dev);
   here it is expected that platform_data contains the pcmcia ops, but it's
   NULL, and the dereferencing in pxa2xx_configure_sockets() of ops->first
   panics.

Cheers.

-- 
Robert

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 4/8] pcmcia: pxa2xx: convert memory allocation to devm_* API

2015-03-28 Thread Russell King - ARM Linux
On Sat, Mar 28, 2015 at 10:38:24PM +0100, Robert Jarzmik wrote:
> Russell King  writes:
> 
> > Convert the pxa2xx socket driver memory allocation to use devm_kzalloc()
> > to simplify the cleanup path.
> >
> > Signed-off-by: Russell King 
> > ---
> >  drivers/pcmcia/pxa2xx_base.c | 8 +++-
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
> > index 197c77a64ce0..dfcf07828605 100644
> > --- a/drivers/pcmcia/pxa2xx_base.c
> > +++ b/drivers/pcmcia/pxa2xx_base.c
> > @@ -302,7 +302,8 @@ static int pxa2xx_drv_pcmcia_probe(struct 
> > platform_device *dev)
> >  
> > pxa2xx_drv_pcmcia_ops(ops);
> >  
> > -   sinfo = kzalloc(SKT_DEV_INFO_SIZE(ops->nr), GFP_KERNEL);
> > +   sinfo = devm_kzalloc(&pdev->dev, SKT_DEV_INFO_SIZE(ops->nr),
> There is a typo here : &pdev->dev should be &dev->dev.
> 
> Now given that fix, you can add my :
> Tested-by: Robert Jarzmik 
> 
> This test of mine is rather cheap :
>  - it relies on 4.0-rc4
>  - I don't have any PCMCIA card to insert in the lubbock, hence the "cheap"
>  - I judge that pcmcia is working because :
>- cat /proc/iomem gives:
>  1000-10001fff : sa
>1400-15ff : 0400
>1800-19ff : 0800
>1a00-1bff : 0a00
>  1a00-1bff : sa-ps2
>1c00-1dff : 0c00
>  1c00-1dff : sa-ps2
>10001600-100017ff : irq
>10001800-100019ff : 1800
>  10001800-100019ff : sa-pcmcia
> - I don't see any error message in kernel log
> 
> As a side note mainly to myself, the pcmcia is broken on pxa2xx architectures
> and panics the kernel at boot time because :
>  - in drivers/pcmcia/sa_lubbock.c I see :
>pcmcia_lubbock_init()
>  pxa2xx_configure_sockets(&sadev->dev);
>here it is expected that platform_data contains the pcmcia ops, but 
> it's
>NULL, and the dereferencing in pxa2xx_configure_sockets() of ops->first
>panics.

I guess it's broken as a result of 5b703683b6cc3cb97bbe6b1b14898b273eb59279
which added that call without really understanding the call path.  I
don't see any solution other than partially reverting that commit.
As can be seen from the commit message, this was done blindly with no
testing - so it's no surprise that it broke.

-- 
FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up
according to speedtest.net.

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia


Re: [PATCH 4/8] pcmcia: pxa2xx: convert memory allocation to devm_* API

2015-07-16 Thread Robert Jarzmik
Russell King  writes:

> Convert the pxa2xx socket driver memory allocation to use devm_kzalloc()
> to simplify the cleanup path.
>
> Signed-off-by: Russell King 
Reviewed-by: Robert Jarzmik 

Cheers.

--
Robert

___
Linux PCMCIA reimplementation list
http://lists.infradead.org/mailman/listinfo/linux-pcmcia