From: Barry Song <Barry.Song@csr.com>
To: Greg Kroah-Hartman <gregkh@suse.de>, <linux-kernel@vger.kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
workgroup.linux@csr.com, Grant Likely <grant.likely@secretlab.ca>,
linux-mtd@lists.infradead.org,
Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
Barry Song <Baohua.Song@csr.com>,
David Woodhouse <dwmw2@infradead.org>,
Erik Gilling <konkers@google.com>
Subject: [PATCH 1/3] platform: add common resource requesting and mapping helper
Date: Tue, 31 Jan 2012 18:00:00 +0800 [thread overview]
Message-ID: <1328004002-24646-2-git-send-email-Barry.Song@csr.com> (raw)
In-Reply-To: <1328004002-24646-1-git-send-email-Barry.Song@csr.com>
From: Barry Song <Baohua.Song@csr.com>
this patch helps to move the common pattern from
"
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
ret = -ENODEV;
goto err;
}
base = devm_request_and_ioremap(&dev->dev, mem_res);
if (!base) {
ret = -ENODEV;
goto err;
}
"
to
"
base = platform_devm_request_and_ioremap(pdev, 0);
if (!base) {
ret = -ENODEV;
goto err;
}
"
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Erik Gilling <konkers@google.com>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: David Woodhouse <dwmw2@infradead.org>
---
drivers/base/platform.c | 19 +++++++++++++++++++
include/linux/platform_device.h | 1 +
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index f0c605e..39ca0ab 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -72,6 +72,25 @@ struct resource *platform_get_resource(struct platform_device *dev,
EXPORT_SYMBOL_GPL(platform_get_resource);
/**
+ * platform_devm_request_and_ioremap() - get resource, check, request region,
+ * and ioremap resource
+ * @dev: platform device
+ * @num: IOMEM resource index
+ */
+void __iomem *platform_devm_request_and_ioremap(struct platform_device *dev,
+ unsigned int num)
+{
+ struct resource *res;
+
+ res = platform_get_resource(dev, IORESOURCE_MEM, num);
+ if (!res)
+ return NULL;
+
+ return devm_request_and_ioremap(&dev->dev, res);
+}
+EXPORT_SYMBOL_GPL(platform_devm_request_and_ioremap);
+
+/**
* platform_get_irq - get an IRQ for a device
* @dev: platform device
* @num: IRQ number index
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 60e9994..768c0d7 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -44,6 +44,7 @@ extern struct device platform_bus;
extern void arch_setup_pdev_archdata(struct platform_device *);
extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int);
+extern void __iomem *platform_devm_request_and_ioremap(struct platform_device *, unsigned int);
extern int platform_get_irq(struct platform_device *, unsigned int);
extern struct resource *platform_get_resource_byname(struct platform_device *, unsigned int, const char *);
extern int platform_get_irq_byname(struct platform_device *, const char *);
--
1.7.1
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
next prev parent reply other threads:[~2012-01-31 10:01 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-31 9:59 [PATCH 0/3] platform: add platform_devm_request_and_ioremap() common API Barry Song
2012-01-31 10:00 ` Barry Song [this message]
2012-01-31 10:17 ` [PATCH 1/3] platform: add common resource requesting and mapping helper Wolfram Sang
2012-01-31 11:04 ` Barry Song
2012-01-31 11:33 ` Wolfram Sang
2012-01-31 12:09 ` Barry Song
2012-01-31 20:34 ` Grant Likely
2012-01-31 21:15 ` Wolfram Sang
2012-01-31 21:51 ` Grant Likely
2012-02-01 2:11 ` Barry Song
2012-02-01 10:03 ` Wolfram Sang
2012-02-01 10:20 ` Barry Song
2012-02-01 12:56 ` Mark Brown
2012-02-02 0:10 ` Grant Likely
2012-01-31 20:35 ` Grant Likely
2012-01-31 21:20 ` Linus Walleij
2012-01-31 21:52 ` Grant Likely
2012-02-01 2:22 ` Barry Song
2012-01-31 10:00 ` [PATCH 2/3] GPIO: TEGRA: move to use platform_devm_request_and_ioremap() helper Barry Song
2012-01-31 16:55 ` Stephen Warren
2012-01-31 20:37 ` Grant Likely
2012-01-31 10:00 ` [PATCH 3/3] MTD: NAND: txx9ndfmc: " Barry Song
2012-01-31 11:14 ` [PATCH 0/3] platform: add platform_devm_request_and_ioremap() common API Artem Bityutskiy
2012-01-31 12:57 ` Barry Song
2012-01-31 13:16 ` Artem Bityutskiy
2012-01-31 13:23 ` Artem Bityutskiy
2012-01-31 13:27 ` Wolfram Sang
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=1328004002-24646-2-git-send-email-Barry.Song@csr.com \
--to=barry.song@csr.com \
--cc=Baohua.Song@csr.com \
--cc=anemo@mba.ocn.ne.jp \
--cc=dwmw2@infradead.org \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@suse.de \
--cc=konkers@google.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=workgroup.linux@csr.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox