All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia@diku.dk>
To: ben-linux@fluff.org
Cc: kernel-janitors@vger.kernel.org,
	Marek Vasut <marek.vasut@gmail.com>,
	Baruch Siach <baruch@tkos.co.il>, Dave Airlie <airlied@linux.ie>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_mem_region
Date: Sun, 13 Feb 2011 13:12:12 +0100	[thread overview]
Message-ID: <1297599132-7226-6-git-send-email-julia@diku.dk> (raw)
In-Reply-To: <1297599132-7226-1-git-send-email-julia@diku.dk>

Request_region should be used with release_region, not release_resource.

The result of request_mem_region is no longer stored.  Instead the field
ioarea is used to store a pointer to the resource structure that contains
the start address.  This is the information that is needed later in
nuc900_i2c_remove to release the region.  The field ioarea is also printed
in some debugging code.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,E;
@@
(
*x = request_region(...)
|
*x = request_mem_region(...)
)
... when != release_region(x)
    when != x = E
* release_resource(x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
Not compiled due to incompatible architecture.

 drivers/i2c/busses/i2c-nuc900.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nuc900.c b/drivers/i2c/busses/i2c-nuc900.c
index 7243426..97b16b7 100644
--- a/drivers/i2c/busses/i2c-nuc900.c
+++ b/drivers/i2c/busses/i2c-nuc900.c
@@ -568,15 +568,13 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	i2c->ioarea = request_mem_region(res->start, resource_size(res),
-					 pdev->name);
-
-	if (i2c->ioarea == NULL) {
+	if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
 		dev_err(&pdev->dev, "cannot request IO\n");
 		ret = -ENXIO;
 		goto err_clk;
 	}
 
+	i2c->ioarea = res;
 	i2c->regs = ioremap(res->start, resource_size(res));
 
 	if (i2c->regs == NULL) {
@@ -645,8 +643,7 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 	iounmap(i2c->regs);
 
  err_ioarea:
-	release_resource(i2c->ioarea);
-	kfree(i2c->ioarea);
+	release_mem_region(res->start, resource_size(res));
 
  err_clk:
 	clk_disable(i2c->clk);
@@ -665,6 +662,7 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 static int __devexit nuc900_i2c_remove(struct platform_device *pdev)
 {
 	struct nuc900_i2c *i2c = platform_get_drvdata(pdev);
+	struct resource *res = i2c->ioarea;
 
 	i2c_del_adapter(&i2c->adap);
 	free_irq(i2c->irq, i2c);
@@ -674,8 +672,7 @@ static int __devexit nuc900_i2c_remove(struct platform_device *pdev)
 
 	iounmap(i2c->regs);
 
-	release_resource(i2c->ioarea);
-	kfree(i2c->ioarea);
+	release_mem_region(res->start, resource_size(res));
 	kfree(i2c);
 
 	return 0;


WARNING: multiple messages have this Message-ID (diff)
From: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>
To: ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org
Cc: kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Marek Vasut <marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>,
	Dave Airlie <airlied-cv59FeDIM0c@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_mem_region
Date: Sun, 13 Feb 2011 13:12:12 +0100	[thread overview]
Message-ID: <1297599132-7226-6-git-send-email-julia@diku.dk> (raw)
In-Reply-To: <1297599132-7226-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>

Request_region should be used with release_region, not release_resource.

The result of request_mem_region is no longer stored.  Instead the field
ioarea is used to store a pointer to the resource structure that contains
the start address.  This is the information that is needed later in
nuc900_i2c_remove to release the region.  The field ioarea is also printed
in some debugging code.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,E;
@@
(
*x = request_region(...)
|
*x = request_mem_region(...)
)
... when != release_region(x)
    when != x = E
* release_resource(x);
// </smpl>

Signed-off-by: Julia Lawall <julia-dAYI7NvHqcQ@public.gmane.org>

---
Not compiled due to incompatible architecture.

 drivers/i2c/busses/i2c-nuc900.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nuc900.c b/drivers/i2c/busses/i2c-nuc900.c
index 7243426..97b16b7 100644
--- a/drivers/i2c/busses/i2c-nuc900.c
+++ b/drivers/i2c/busses/i2c-nuc900.c
@@ -568,15 +568,13 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	i2c->ioarea = request_mem_region(res->start, resource_size(res),
-					 pdev->name);
-
-	if (i2c->ioarea == NULL) {
+	if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
 		dev_err(&pdev->dev, "cannot request IO\n");
 		ret = -ENXIO;
 		goto err_clk;
 	}
 
+	i2c->ioarea = res;
 	i2c->regs = ioremap(res->start, resource_size(res));
 
 	if (i2c->regs == NULL) {
@@ -645,8 +643,7 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 	iounmap(i2c->regs);
 
  err_ioarea:
-	release_resource(i2c->ioarea);
-	kfree(i2c->ioarea);
+	release_mem_region(res->start, resource_size(res));
 
  err_clk:
 	clk_disable(i2c->clk);
@@ -665,6 +662,7 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 static int __devexit nuc900_i2c_remove(struct platform_device *pdev)
 {
 	struct nuc900_i2c *i2c = platform_get_drvdata(pdev);
+	struct resource *res = i2c->ioarea;
 
 	i2c_del_adapter(&i2c->adap);
 	free_irq(i2c->irq, i2c);
@@ -674,8 +672,7 @@ static int __devexit nuc900_i2c_remove(struct platform_device *pdev)
 
 	iounmap(i2c->regs);
 
-	release_resource(i2c->ioarea);
-	kfree(i2c->ioarea);
+	release_mem_region(res->start, resource_size(res));
 	kfree(i2c);
 
 	return 0;

WARNING: multiple messages have this Message-ID (diff)
From: Julia Lawall <julia@diku.dk>
To: ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org
Cc: kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Marek Vasut <marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>,
	Dave Airlie <airlied-cv59FeDIM0c@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_mem_
Date: Sun, 13 Feb 2011 11:51:29 +0000	[thread overview]
Message-ID: <1297599132-7226-6-git-send-email-julia@diku.dk> (raw)
In-Reply-To: <1297599132-7226-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>

Request_region should be used with release_region, not release_resource.

The result of request_mem_region is no longer stored.  Instead the field
ioarea is used to store a pointer to the resource structure that contains
the start address.  This is the information that is needed later in
nuc900_i2c_remove to release the region.  The field ioarea is also printed
in some debugging code.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,E;
@@
(
*x = request_region(...)
|
*x = request_mem_region(...)
)
... when != release_region(x)
    when != x = E
* release_resource(x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
Not compiled due to incompatible architecture.

 drivers/i2c/busses/i2c-nuc900.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-nuc900.c b/drivers/i2c/busses/i2c-nuc900.c
index 7243426..97b16b7 100644
--- a/drivers/i2c/busses/i2c-nuc900.c
+++ b/drivers/i2c/busses/i2c-nuc900.c
@@ -568,15 +568,13 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	i2c->ioarea = request_mem_region(res->start, resource_size(res),
-					 pdev->name);
-
-	if (i2c->ioarea = NULL) {
+	if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
 		dev_err(&pdev->dev, "cannot request IO\n");
 		ret = -ENXIO;
 		goto err_clk;
 	}
 
+	i2c->ioarea = res;
 	i2c->regs = ioremap(res->start, resource_size(res));
 
 	if (i2c->regs = NULL) {
@@ -645,8 +643,7 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 	iounmap(i2c->regs);
 
  err_ioarea:
-	release_resource(i2c->ioarea);
-	kfree(i2c->ioarea);
+	release_mem_region(res->start, resource_size(res));
 
  err_clk:
 	clk_disable(i2c->clk);
@@ -665,6 +662,7 @@ static int __devinit nuc900_i2c_probe(struct platform_device *pdev)
 static int __devexit nuc900_i2c_remove(struct platform_device *pdev)
 {
 	struct nuc900_i2c *i2c = platform_get_drvdata(pdev);
+	struct resource *res = i2c->ioarea;
 
 	i2c_del_adapter(&i2c->adap);
 	free_irq(i2c->irq, i2c);
@@ -674,8 +672,7 @@ static int __devexit nuc900_i2c_remove(struct platform_device *pdev)
 
 	iounmap(i2c->regs);
 
-	release_resource(i2c->ioarea);
-	kfree(i2c->ioarea);
+	release_mem_region(res->start, resource_size(res));
 	kfree(i2c);
 
 	return 0;


  parent reply	other threads:[~2011-02-13 11:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-13 11:50 [PATCH 0/5] Convert release_resource to release_region/release_mem_region Julia Lawall
2011-02-13 12:12 ` Julia Lawall
2011-02-13 11:50 ` [PATCH 1/5] drivers/i2c/busses/i2c-au1550.c: Convert release_resource to release_region/release_mem_ Julia Lawall
2011-02-13 12:12   ` [PATCH 1/5] drivers/i2c/busses/i2c-au1550.c: Convert release_resource to release_region/release_mem_region Julia Lawall
2011-02-13 11:51 ` [PATCH 3/5] drivers/char/pcmcia/ipwireless/main.c: Convert release_resource to release_region/releas Julia Lawall
2011-02-13 12:12   ` [PATCH 3/5] drivers/char/pcmcia/ipwireless/main.c: Convert release_resource to release_region/release_mem_region Julia Lawall
2011-02-16  7:21   ` Dominik Brodowski
2011-02-16  7:21     ` [PATCH 3/5] drivers/char/pcmcia/ipwireless/main.c: Convert Dominik Brodowski
2011-02-16  8:44     ` [PATCH 3/5] drivers/char/pcmcia/ipwireless/main.c: Convert release_resource to release_region/release_mem_region Jiri Kosina
2011-02-16  8:44       ` [PATCH 3/5] drivers/char/pcmcia/ipwireless/main.c: Convert Jiri Kosina
     [not found] ` <1297599132-7226-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
2011-02-13 11:51   ` Julia Lawall [this message]
2011-02-13 12:12     ` [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_mem_region Julia Lawall
2011-02-13 12:12     ` Julia Lawall
2011-02-14 16:56     ` Marek Vasut
2011-02-14 16:56       ` [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_ Marek Vasut
2011-02-14 16:56       ` [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_mem_region Marek Vasut
2011-02-14 17:04       ` Julia Lawall
2011-02-14 17:04         ` [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource Julia Lawall
2011-02-14 17:04         ` [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_mem_region Julia Lawall
2011-02-13 11:51 ` [PATCH 4/5] arch/x86/pci/direct.c: " Julia Lawall
2011-02-13 12:12   ` Julia Lawall
2011-04-08 19:50   ` Jesse Barnes
2011-04-08 19:50     ` [PATCH 4/5] arch/x86/pci/direct.c: Convert release_resource to Jesse Barnes
2011-02-13 11:51 ` [PATCH 2/5] drivers/char/hw_random/omap-rng.c: Convert release_resource to release_region/release_me Julia Lawall
2011-02-13 12:12   ` [PATCH 2/5] drivers/char/hw_random/omap-rng.c: Convert release_resource to release_region/release_mem_region Julia Lawall
2011-02-14 22:42   ` Matt Mackall
2011-02-14 22:42     ` [PATCH 2/5] drivers/char/hw_random/omap-rng.c: Convert Matt Mackall
2011-02-14 22:47     ` [PATCH 2/5] drivers/char/hw_random/omap-rng.c: Convert release_resource to release_region/release_mem_region Herbert Xu
2011-02-14 22:47       ` [PATCH 2/5] drivers/char/hw_random/omap-rng.c: Convert Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1297599132-7226-6-git-send-email-julia@diku.dk \
    --to=julia@diku.dk \
    --cc=airlied@linux.ie \
    --cc=baruch@tkos.co.il \
    --cc=ben-linux@fluff.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek.vasut@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.