linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi/omap: cleanup probe/remove routines
@ 2012-04-29 14:00 Hannu Heikkinen
  0 siblings, 0 replies; 4+ messages in thread
From: Hannu Heikkinen @ 2012-04-29 14:00 UTC (permalink / raw)
  To: linux-kernel, spi-devel-general; +Cc: grant.likely, tony

Cleanup probe and remove routines, use devm_* functions for
managing resources.

Also, in under free_master label, change use of kfree() into
spi_master_put().

CC: tony@atomide.com
CC: grant.likely@secretlab.ca
Signed-off-by: Hannu Heikkinen <hannuxx@iki.fi>
---
 drivers/spi/spi-omap2-mcspi.c |   27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bb9274c..392efce 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1166,17 +1166,12 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
 	r->start += regs_offset;
 	r->end += regs_offset;
 	mcspi->phys = r->start;
-	if (!request_mem_region(r->start, resource_size(r),
-				dev_name(&pdev->dev))) {
-		status = -EBUSY;
-		goto free_master;
-	}
 
-	mcspi->base = ioremap(r->start, resource_size(r));
+	mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
 	if (!mcspi->base) {
-		dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
-		status = -ENOMEM;
-		goto release_region;
+		dev_dbg(&pdev->dev, "can't request mem and ioremap MCSPI\n");
+		status =  -ENOMEM;
+		goto free_master;
 	}
 
 	mcspi->dev = &pdev->dev;
@@ -1191,7 +1186,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
 			GFP_KERNEL);
 
 	if (mcspi->dma_channels == NULL)
-		goto unmap_io;
+		goto free_master;
 
 	for (i = 0; i < master->num_chipselect; i++) {
 		char dma_ch_name[14];
@@ -1241,12 +1236,8 @@ disable_pm:
 	pm_runtime_disable(&pdev->dev);
 dma_chnl_free:
 	kfree(mcspi->dma_channels);
-unmap_io:
-	iounmap(mcspi->base);
-release_region:
-	release_mem_region(r->start, resource_size(r));
 free_master:
-	kfree(master);
+	spi_master_put(master);
 	platform_set_drvdata(pdev, NULL);
 	return status;
 }
@@ -1256,8 +1247,6 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
 	struct spi_master	*master;
 	struct omap2_mcspi	*mcspi;
 	struct omap2_mcspi_dma	*dma_channels;
-	struct resource		*r;
-	void __iomem *base;
 
 	master = dev_get_drvdata(&pdev->dev);
 	mcspi = spi_master_get_devdata(master);
@@ -1265,12 +1254,8 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
 
 	omap2_mcspi_disable_clocks(mcspi);
 	pm_runtime_disable(&pdev->dev);
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(r->start, resource_size(r));
 
-	base = mcspi->base;
 	spi_unregister_master(master);
-	iounmap(base);
 	kfree(dma_channels);
 	destroy_workqueue(mcspi->wq);
 	platform_set_drvdata(pdev, NULL);
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] spi/omap: cleanup probe/remove routines
@ 2012-05-09 12:43 Hannu Heikkinen
       [not found] ` <1336567438-6715-1-git-send-email-hannuxx-X3B1VOXEql0@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Hannu Heikkinen @ 2012-05-09 12:43 UTC (permalink / raw)
  To: linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ

Cleanup probe and remove routines, use devm_* functions for
managing resources.

Also, in under free_master label, change use of kfree() into
spi_master_put().

CC: grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org
CC: tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org
Signed-off-by: Hannu Heikkinen <hannuxx-X3B1VOXEql0@public.gmane.org>
---
 drivers/spi/spi-omap2-mcspi.c |   27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index bb9274c..392efce 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1166,17 +1166,12 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
 	r->start += regs_offset;
 	r->end += regs_offset;
 	mcspi->phys = r->start;
-	if (!request_mem_region(r->start, resource_size(r),
-				dev_name(&pdev->dev))) {
-		status = -EBUSY;
-		goto free_master;
-	}
 
-	mcspi->base = ioremap(r->start, resource_size(r));
+	mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
 	if (!mcspi->base) {
-		dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
-		status = -ENOMEM;
-		goto release_region;
+		dev_dbg(&pdev->dev, "can't request mem and ioremap MCSPI\n");
+		status =  -ENOMEM;
+		goto free_master;
 	}
 
 	mcspi->dev = &pdev->dev;
@@ -1191,7 +1186,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
 			GFP_KERNEL);
 
 	if (mcspi->dma_channels == NULL)
-		goto unmap_io;
+		goto free_master;
 
 	for (i = 0; i < master->num_chipselect; i++) {
 		char dma_ch_name[14];
@@ -1241,12 +1236,8 @@ disable_pm:
 	pm_runtime_disable(&pdev->dev);
 dma_chnl_free:
 	kfree(mcspi->dma_channels);
-unmap_io:
-	iounmap(mcspi->base);
-release_region:
-	release_mem_region(r->start, resource_size(r));
 free_master:
-	kfree(master);
+	spi_master_put(master);
 	platform_set_drvdata(pdev, NULL);
 	return status;
 }
@@ -1256,8 +1247,6 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
 	struct spi_master	*master;
 	struct omap2_mcspi	*mcspi;
 	struct omap2_mcspi_dma	*dma_channels;
-	struct resource		*r;
-	void __iomem *base;
 
 	master = dev_get_drvdata(&pdev->dev);
 	mcspi = spi_master_get_devdata(master);
@@ -1265,12 +1254,8 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
 
 	omap2_mcspi_disable_clocks(mcspi);
 	pm_runtime_disable(&pdev->dev);
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(r->start, resource_size(r));
 
-	base = mcspi->base;
 	spi_unregister_master(master);
-	iounmap(base);
 	kfree(dma_channels);
 	destroy_workqueue(mcspi->wq);
 	platform_set_drvdata(pdev, NULL);
-- 
1.7.10


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi/omap: cleanup probe/remove routines
       [not found] ` <1336567438-6715-1-git-send-email-hannuxx-X3B1VOXEql0@public.gmane.org>
@ 2012-05-10  0:37   ` Grant Likely
  2012-05-12 13:12     ` Hannu Heikkinen
  0 siblings, 1 reply; 4+ messages in thread
From: Grant Likely @ 2012-05-10  0:37 UTC (permalink / raw)
  To: Hannu Heikkinen, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Kevin Hilman
  Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ

On Wed,  9 May 2012 15:43:58 +0300, Hannu Heikkinen <hannuxx-X3B1VOXEql0@public.gmane.org> wrote:
> Cleanup probe and remove routines, use devm_* functions for
> managing resources.
> 
> Also, in under free_master label, change use of kfree() into
> spi_master_put().

Patch does not apply to my current spi/next branch[1].

[1]git://git.secretlab.ca/git/linux-2.6 spi/next

While I'm thinking about it; Kevin, how do you want me handling OMAP
spi patches.  Do you want to pick them up, test them and send me a git
branch to pull like with gpio?  Or can I just pick them up?

g.

> 
> CC: grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org
> CC: tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org
> Signed-off-by: Hannu Heikkinen <hannuxx-X3B1VOXEql0@public.gmane.org>
> ---
>  drivers/spi/spi-omap2-mcspi.c |   27 ++++++---------------------
>  1 file changed, 6 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index bb9274c..392efce 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -1166,17 +1166,12 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
>  	r->start += regs_offset;
>  	r->end += regs_offset;
>  	mcspi->phys = r->start;
> -	if (!request_mem_region(r->start, resource_size(r),
> -				dev_name(&pdev->dev))) {
> -		status = -EBUSY;
> -		goto free_master;
> -	}
>  
> -	mcspi->base = ioremap(r->start, resource_size(r));
> +	mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
>  	if (!mcspi->base) {
> -		dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
> -		status = -ENOMEM;
> -		goto release_region;
> +		dev_dbg(&pdev->dev, "can't request mem and ioremap MCSPI\n");
> +		status =  -ENOMEM;
> +		goto free_master;
>  	}
>  
>  	mcspi->dev = &pdev->dev;
> @@ -1191,7 +1186,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
>  			GFP_KERNEL);
>  
>  	if (mcspi->dma_channels == NULL)
> -		goto unmap_io;
> +		goto free_master;
>  
>  	for (i = 0; i < master->num_chipselect; i++) {
>  		char dma_ch_name[14];
> @@ -1241,12 +1236,8 @@ disable_pm:
>  	pm_runtime_disable(&pdev->dev);
>  dma_chnl_free:
>  	kfree(mcspi->dma_channels);
> -unmap_io:
> -	iounmap(mcspi->base);
> -release_region:
> -	release_mem_region(r->start, resource_size(r));
>  free_master:
> -	kfree(master);
> +	spi_master_put(master);
>  	platform_set_drvdata(pdev, NULL);
>  	return status;
>  }
> @@ -1256,8 +1247,6 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
>  	struct spi_master	*master;
>  	struct omap2_mcspi	*mcspi;
>  	struct omap2_mcspi_dma	*dma_channels;
> -	struct resource		*r;
> -	void __iomem *base;
>  
>  	master = dev_get_drvdata(&pdev->dev);
>  	mcspi = spi_master_get_devdata(master);
> @@ -1265,12 +1254,8 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
>  
>  	omap2_mcspi_disable_clocks(mcspi);
>  	pm_runtime_disable(&pdev->dev);
> -	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	release_mem_region(r->start, resource_size(r));
>  
> -	base = mcspi->base;
>  	spi_unregister_master(master);
> -	iounmap(base);
>  	kfree(dma_channels);
>  	destroy_workqueue(mcspi->wq);
>  	platform_set_drvdata(pdev, NULL);
> -- 
> 1.7.10
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi/omap: cleanup probe/remove routines
  2012-05-10  0:37   ` Grant Likely
@ 2012-05-12 13:12     ` Hannu Heikkinen
  0 siblings, 0 replies; 4+ messages in thread
From: Hannu Heikkinen @ 2012-05-12 13:12 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-omap, linux-kernel, spi-devel-general, Kevin Hilman, tony

On 09/05/12 18:37 -0600, Grant Likely wrote:
> On Wed,  9 May 2012 15:43:58 +0300, Hannu Heikkinen <hannuxx@iki.fi> wrote:
> > Cleanup probe and remove routines, use devm_* functions for
> > managing resources.
> > 
> > Also, in under free_master label, change use of kfree() into
> > spi_master_put().
> 
> Patch does not apply to my current spi/next branch[1].
> 
> [1]git://git.secretlab.ca/git/linux-2.6 spi/next
> 
> While I'm thinking about it; Kevin, how do you want me handling OMAP
> spi patches.  Do you want to pick them up, test them and send me a git
> branch to pull like with gpio?  Or can I just pick them up?
> 
> g.

hi, I forgot this spi/next brach. devm funcs already applied
(commit 1a77b127ae147f5827043a9896d7f4cb248b402e - Shubhrajyoti).

Please ignore below patch, I'll check if there's something devm related
to do left.

br,
Hannu

> 
> > 
> > CC: grant.likely@secretlab.ca
> > CC: tony@atomide.com
> > Signed-off-by: Hannu Heikkinen <hannuxx@iki.fi>
> > ---
> >  drivers/spi/spi-omap2-mcspi.c |   27 ++++++---------------------
> >  1 file changed, 6 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> > index bb9274c..392efce 100644
> > --- a/drivers/spi/spi-omap2-mcspi.c
> > +++ b/drivers/spi/spi-omap2-mcspi.c
> > @@ -1166,17 +1166,12 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> >  	r->start += regs_offset;
> >  	r->end += regs_offset;
> >  	mcspi->phys = r->start;
> > -	if (!request_mem_region(r->start, resource_size(r),
> > -				dev_name(&pdev->dev))) {
> > -		status = -EBUSY;
> > -		goto free_master;
> > -	}
> >  
> > -	mcspi->base = ioremap(r->start, resource_size(r));
> > +	mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
> >  	if (!mcspi->base) {
> > -		dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
> > -		status = -ENOMEM;
> > -		goto release_region;
> > +		dev_dbg(&pdev->dev, "can't request mem and ioremap MCSPI\n");
> > +		status =  -ENOMEM;
> > +		goto free_master;
> >  	}
> >  
> >  	mcspi->dev = &pdev->dev;
> > @@ -1191,7 +1186,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev)
> >  			GFP_KERNEL);
> >  
> >  	if (mcspi->dma_channels == NULL)
> > -		goto unmap_io;
> > +		goto free_master;
> >  
> >  	for (i = 0; i < master->num_chipselect; i++) {
> >  		char dma_ch_name[14];
> > @@ -1241,12 +1236,8 @@ disable_pm:
> >  	pm_runtime_disable(&pdev->dev);
> >  dma_chnl_free:
> >  	kfree(mcspi->dma_channels);
> > -unmap_io:
> > -	iounmap(mcspi->base);
> > -release_region:
> > -	release_mem_region(r->start, resource_size(r));
> >  free_master:
> > -	kfree(master);
> > +	spi_master_put(master);
> >  	platform_set_drvdata(pdev, NULL);
> >  	return status;
> >  }
> > @@ -1256,8 +1247,6 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
> >  	struct spi_master	*master;
> >  	struct omap2_mcspi	*mcspi;
> >  	struct omap2_mcspi_dma	*dma_channels;
> > -	struct resource		*r;
> > -	void __iomem *base;
> >  
> >  	master = dev_get_drvdata(&pdev->dev);
> >  	mcspi = spi_master_get_devdata(master);
> > @@ -1265,12 +1254,8 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
> >  
> >  	omap2_mcspi_disable_clocks(mcspi);
> >  	pm_runtime_disable(&pdev->dev);
> > -	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -	release_mem_region(r->start, resource_size(r));
> >  
> > -	base = mcspi->base;
> >  	spi_unregister_master(master);
> > -	iounmap(base);
> >  	kfree(dma_channels);
> >  	destroy_workqueue(mcspi->wq);
> >  	platform_set_drvdata(pdev, NULL);
> > -- 
> > 1.7.10
> > 
> 
> -- 
> Grant Likely, B.Sc, P.Eng.
> Secret Lab Technologies, Ltd.

-- 
-------------------------------------
Hannu Heikkinen
hannuxx@iki.fi
PGP Key fingerprint FB04 2612 05B5 1CBD 9428  9E4D 2407 2F8C 52C0 A173
-------------------------------------


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-12 13:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 12:43 [PATCH] spi/omap: cleanup probe/remove routines Hannu Heikkinen
     [not found] ` <1336567438-6715-1-git-send-email-hannuxx-X3B1VOXEql0@public.gmane.org>
2012-05-10  0:37   ` Grant Likely
2012-05-12 13:12     ` Hannu Heikkinen
  -- strict thread matches above, loose matches on Subject: below --
2012-04-29 14:00 Hannu Heikkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).