alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA/davinci: Use the resource_size , __devinit and __devexit.
@ 2010-05-28  5:26 Wan ZongShun
       [not found] ` <4BFF541F.2080209-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Wan ZongShun @ 2010-05-28  5:26 UTC (permalink / raw)
  To: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	alsa-devel, Mark Brown

Dear all,

Use the resource_size function instead of manually calculating the
resource size.  This reduces the chance of introducing off-by-one
errors.

In addition, to use __devinit and __devexit is good too.

Signed-off-by:Wan ZongShun<mcuos.com-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

>From 6e492675606a92bcf9e1719c37219dfc5d11e6ca Mon Sep 17 00:00:00 2001
From: zswan <zswan@zswan-marvell.(none)>
Date: Fri, 28 May 2010 13:18:40 +0800
Subject: [PATCH 5/5] fix davinci resource size

---
 sound/soc/davinci/davinci-i2s.c   |   12 ++++++------
 sound/soc/davinci/davinci-mcasp.c |   12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index adadcd3..763ba73 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -521,7 +521,7 @@ struct snd_soc_dai davinci_i2s_dai = {
 };
 EXPORT_SYMBOL_GPL(davinci_i2s_dai);

-static int davinci_i2s_probe(struct platform_device *pdev)
+static int __devinit davinci_i2s_probe(struct platform_device *pdev)
 {
 	struct snd_platform_data *pdata = pdev->dev.platform_data;
 	struct davinci_mcbsp_dev *dev;
@@ -534,7 +534,7 @@ static int davinci_i2s_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}

-	ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1,
+	ioarea = request_mem_region(mem->start, resource_size(mem),
 				    pdev->name);
 	if (!ioarea) {
 		dev_err(&pdev->dev, "McBSP region already claimed\n");
@@ -597,12 +597,12 @@ static int davinci_i2s_probe(struct platform_device *pdev)
 err_free_mem:
 	kfree(dev);
 err_release_region:
-	release_mem_region(mem->start, (mem->end - mem->start) + 1);
+	release_mem_region(mem->start, resource_size(mem));

 	return ret;
 }

-static int davinci_i2s_remove(struct platform_device *pdev)
+static int __devexit davinci_i2s_remove(struct platform_device *pdev)
 {
 	struct davinci_mcbsp_dev *dev = davinci_i2s_dai.private_data;
 	struct resource *mem;
@@ -613,14 +613,14 @@ static int davinci_i2s_remove(struct platform_device *pdev)
 	dev->clk = NULL;
 	kfree(dev);
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(mem->start, (mem->end - mem->start) + 1);
+	release_mem_region(mem->start, resource_size(mem));

 	return 0;
 }

 static struct platform_driver davinci_mcbsp_driver = {
 	.probe		= davinci_i2s_probe,
-	.remove		= davinci_i2s_remove,
+	.remove		= __devexit_p(davinci_i2s_remove),
 	.driver		= {
 		.name	= "davinci-asp",
 		.owner	= THIS_MODULE,
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 79f0f4a..bd328d6 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -844,7 +844,7 @@ struct snd_soc_dai davinci_mcasp_dai[] = {
 };
 EXPORT_SYMBOL_GPL(davinci_mcasp_dai);

-static int davinci_mcasp_probe(struct platform_device *pdev)
+static int __devinit davinci_mcasp_probe(struct platform_device *pdev)
 {
 	struct davinci_pcm_dma_params *dma_data;
 	struct resource *mem, *ioarea, *res;
@@ -864,7 +864,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
 	}

 	ioarea = request_mem_region(mem->start,
-			(mem->end - mem->start) + 1, pdev->name);
+			resource_size(mem), pdev->name);
 	if (!ioarea) {
 		dev_err(&pdev->dev, "Audio region already claimed\n");
 		ret = -EBUSY;
@@ -928,14 +928,14 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
 	return 0;

 err_release_region:
-	release_mem_region(mem->start, (mem->end - mem->start) + 1);
+	release_mem_region(mem->start, resource_size(mem));
 err_release_data:
 	kfree(dev);

 	return ret;
 }

-static int davinci_mcasp_remove(struct platform_device *pdev)
+static int __devexit davinci_mcasp_remove(struct platform_device *pdev)
 {
 	struct snd_platform_data *pdata = pdev->dev.platform_data;
 	struct davinci_audio_dev *dev;
@@ -948,7 +948,7 @@ static int davinci_mcasp_remove(struct platform_device *pdev)
 	dev->clk = NULL;

 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	release_mem_region(mem->start, (mem->end - mem->start) + 1);
+	release_mem_region(mem->start, resource_size(mem));

 	kfree(dev);

@@ -957,7 +957,7 @@ static int davinci_mcasp_remove(struct platform_device *pdev)

 static struct platform_driver davinci_mcasp_driver = {
 	.probe		= davinci_mcasp_probe,
-	.remove		= davinci_mcasp_remove,
+	.remove		= __devexit_p(davinci_mcasp_remove),
 	.driver		= {
 		.name	= "davinci-mcasp",
 		.owner	= THIS_MODULE,
-- 
1.6.3.3

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

* Re: [PATCH] ALSA/davinci: Use the resource_size , __devinit and __devexit.
       [not found] ` <4BFF541F.2080209-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2010-05-28 13:33   ` Sergei Shtylyov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2010-05-28 13:33 UTC (permalink / raw)
  To: Wan ZongShun
  Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	Mark Brown, alsa-devel

Hello.

Wan ZongShun wrote:

> Dear all,

> Use the resource_size function instead of manually calculating the
> resource size.  This reduces the chance of introducing off-by-one
> errors.

> In addition, to use __devinit and __devexit is good too.

    "Good" isn't a good justification I think.
    Also, this just asks to be put into two patches instead of one as 
the patch does two completely different things.

> Signed-off-by:Wan ZongShun<mcuos.com-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

WBR, Sergei

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

end of thread, other threads:[~2010-05-28 13:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-28  5:26 [PATCH] ALSA/davinci: Use the resource_size , __devinit and __devexit Wan ZongShun
     [not found] ` <4BFF541F.2080209-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-05-28 13:33   ` Sergei Shtylyov

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).