From: Julia Lawall <julia@diku.dk>
To: ben-linux@fluff.org
Cc: kernel-janitors@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] drivers/i2c/busses/i2c-au1550.c: Convert release_resource to release_region/release_mem_region
Date: Sun, 13 Feb 2011 13:12:08 +0100 [thread overview]
Message-ID: <1297599132-7226-2-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
i2c_au1550_remove to release the region. The field ioarea is not used for
anything else.
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-au1550.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index 532828b..2ec78d7 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -389,13 +389,12 @@ i2c_au1550_probe(struct platform_device *pdev)
goto out;
}
- priv->ioarea = request_mem_region(r->start, resource_size(r),
- pdev->name);
- if (!priv->ioarea) {
+ if (!request_mem_region(r->start, resource_size(r), pdev->name)) {
ret = -EBUSY;
goto out_mem;
}
+ priv->ioarea = r;
priv->psc_base = CKSEG1ADDR(r->start);
priv->xfer_timeout = 200;
priv->ack_timeout = 200;
@@ -418,8 +417,7 @@ i2c_au1550_probe(struct platform_device *pdev)
i2c_au1550_disable(priv);
- release_resource(priv->ioarea);
- kfree(priv->ioarea);
+ release_mem_region(r->start, resource_size(r));
out_mem:
kfree(priv);
out:
@@ -430,12 +428,12 @@ static int __devexit
i2c_au1550_remove(struct platform_device *pdev)
{
struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
+ struct resource *r = priv->ioarea;
platform_set_drvdata(pdev, NULL);
i2c_del_adapter(&priv->adap);
i2c_au1550_disable(priv);
- release_resource(priv->ioarea);
- kfree(priv->ioarea);
+ release_mem_region(r->start, resource_size(r));
kfree(priv);
return 0;
}
next parent reply other threads:[~2011-02-13 12:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1297599132-7226-1-git-send-email-julia@diku.dk>
2011-02-13 12:12 ` Julia Lawall [this message]
[not found] ` <1297599132-7226-1-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
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
[not found] ` <1297599132-7226-6-git-send-email-julia-dAYI7NvHqcQ@public.gmane.org>
2011-02-14 16:56 ` Marek Vasut
[not found] ` <201102141756.19068.marek.vasut-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-14 17:04 ` Julia Lawall
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-2-git-send-email-julia@diku.dk \
--to=julia@diku.dk \
--cc=ben-linux@fluff.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).