public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia@diku.dk>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: kernel-janitors@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Jesse Barnes <jbarnes@virtuousgeek.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] arch/x86/pci/direct.c: Convert release_resource to release_region/release_mem_region
Date: Sun, 13 Feb 2011 11:51:30 +0000	[thread overview]
Message-ID: <1297599132-7226-5-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 local variables region and region2 are dropped and the calls to
release_resource are replaced with calls to release_region, using the first
two arguments of the corresponding calls to request_region.

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>

---
Compiled, not tested.

 arch/x86/pci/direct.c |   17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/arch/x86/pci/direct.c b/arch/x86/pci/direct.c
index bd33620..e6fd847 100644
--- a/arch/x86/pci/direct.c
+++ b/arch/x86/pci/direct.c
@@ -280,12 +280,9 @@ void __init pci_direct_init(int type)
 
 int __init pci_direct_probe(void)
 {
-	struct resource *region, *region2;
-
 	if ((pci_probe & PCI_PROBE_CONF1) = 0)
 		goto type2;
-	region = request_region(0xCF8, 8, "PCI conf1");
-	if (!region)
+	if (!request_region(0xCF8, 8, "PCI conf1"))
 		goto type2;
 
 	if (pci_check_type1()) {
@@ -293,16 +290,14 @@ int __init pci_direct_probe(void)
 		port_cf9_safe = true;
 		return 1;
 	}
-	release_resource(region);
+	release_region(0xCF8, 8);
 
  type2:
 	if ((pci_probe & PCI_PROBE_CONF2) = 0)
 		return 0;
-	region = request_region(0xCF8, 4, "PCI conf2");
-	if (!region)
+	if (!request_region(0xCF8, 4, "PCI conf2"))
 		return 0;
-	region2 = request_region(0xC000, 0x1000, "PCI conf2");
-	if (!region2)
+	if (!request_region(0xC000, 0x1000, "PCI conf2"))
 		goto fail2;
 
 	if (pci_check_type2()) {
@@ -311,8 +306,8 @@ int __init pci_direct_probe(void)
 		return 2;
 	}
 
-	release_resource(region2);
+	release_region(0xC000, 0x1000);
  fail2:
-	release_resource(region);
+	release_region(0xCF8, 4);
 	return 0;
 }


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

Thread overview: 13+ 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 11:50 ` [PATCH 1/5] drivers/i2c/busses/i2c-au1550.c: Convert release_resource to release_region/release_mem_ 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-16  7:21   ` [PATCH 3/5] drivers/char/pcmcia/ipwireless/main.c: Convert Dominik Brodowski
2011-02-16  8:44     ` Jiri Kosina
     [not found] ` <1297599132-7226-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
2011-02-13 11:51   ` [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_mem_ Julia Lawall
     [not found]     ` <1297599132-7226-6-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
2011-02-14 16:56       ` [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource to release_region/release_ Marek Vasut
     [not found]         ` <201102141756.19068.marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-14 17:04           ` [PATCH 5/5] drivers/i2c/busses/i2c-nuc900.c: Convert release_resource Julia Lawall
2011-02-13 11:51 ` Julia Lawall [this message]
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-14 22:42   ` [PATCH 2/5] drivers/char/hw_random/omap-rng.c: Convert Matt Mackall
2011-02-14 22:47     ` 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-5-git-send-email-julia@diku.dk \
    --to=julia@diku.dk \
    --cc=hpa@zytor.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox