From: Viresh Kumar <viresh.kumar@st.com>
To: linus.walleij@linaro.org
Cc: devicetree-discuss@ozlabs.org, arnd@arndb.de,
swarren@wwwdotorg.org, spear-devel@list.st.com,
Grant Likely <grant.likely@secretlab.ca>,
viresh.linux@gmail.com, olof@lixom.net,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH V4 1/5] of: Implement managed of_iomap()
Date: Mon, 16 Apr 2012 09:43:57 +0530 [thread overview]
Message-ID: <6a0872f9d8959bc9d66d179e4911d6f09a219b42.1334548272.git.viresh.kumar@st.com> (raw)
In-Reply-To: <cover.1334548272.git.viresh.kumar@st.com>
This simplifies cleanup paths of user code by providing managed version of
of_iomap().
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
---
Documentation/driver-model/devres.txt | 1 +
drivers/of/address.c | 22 ++++++++++++++++++++++
include/linux/of_address.h | 5 +++++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 2a596a4..74f0f92 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -266,6 +266,7 @@ IOMAP
devm_ioremap()
devm_ioremap_nocache()
devm_iounmap()
+ devm_of_iomap()
devm_request_and_ioremap() : checks resource, requests region, ioremaps
pcim_iomap()
pcim_iounmap()
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 66d96f1..f58eb4c 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -619,3 +619,25 @@ void __iomem *of_iomap(struct device_node *np, int index)
return ioremap(res.start, resource_size(&res));
}
EXPORT_SYMBOL(of_iomap);
+
+/**
+ * devm_of_iomap - Maps the managed memory mapped IO for a given device
+ * @dev: the device whose io range will be mapped
+ * @index: index of the io range
+ *
+ * Returns a pointer to the mapped memory
+ */
+void __iomem *devm_of_iomap(struct device *dev, int index)
+{
+ struct device_node *np = dev->of_node;
+ struct resource res;
+
+ if (!np)
+ return NULL;
+
+ if (of_address_to_resource(np, index, &res))
+ return NULL;
+
+ return devm_ioremap(dev, res.start, resource_size(&res));
+}
+EXPORT_SYMBOL(devm_of_iomap);
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 01b925a..5ba9ea8 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -13,6 +13,7 @@ extern struct device_node *of_find_matching_node_by_address(
const struct of_device_id *matches,
u64 base_address);
extern void __iomem *of_iomap(struct device_node *device, int index);
+extern void __iomem *devm_of_iomap(struct device *dev, int index);
/* Extract an address from a device, returns the region size and
* the address space flags too. The PCI version uses a BAR number
@@ -43,6 +44,10 @@ static inline void __iomem *of_iomap(struct device_node *device, int index)
{
return NULL;
}
+static inline void __iomem *devm_of_iomap(struct device *dev, int index)
+{
+ return NULL;
+}
static inline const u32 *of_get_address(struct device_node *dev, int index,
u64 *size, unsigned int *flags)
{
--
1.7.9
next prev parent reply other threads:[~2012-04-16 4:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-16 4:13 [PATCH V4 0/5] pinctrl: Add SPEAr pinctrl support Viresh Kumar
2012-04-16 4:13 ` Viresh Kumar [this message]
2012-04-16 9:27 ` [PATCH V4 1/5] of: Implement managed of_iomap() Linus Walleij
2012-04-16 14:42 ` Arnd Bergmann
[not found] ` <201204161442.38725.arnd-r2nGTMty4D4@public.gmane.org>
2012-04-16 15:06 ` Grant Likely
2012-04-16 15:12 ` viresh kumar
[not found] ` <CAOh2x=n0NfovyfCpcdoMo2a7yLtb=imm1U+R-1L-2ihZ52FUhw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-16 15:19 ` Grant Likely
[not found] ` <CACxGe6tZhdvoJ60N8g5-P4UHWxB=699_bA2omEQa77u1hEEPrg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-16 16:21 ` viresh kumar
2012-04-16 17:06 ` Grant Likely
[not found] ` <CACxGe6t9+M5jQKkRduup7_wk4SKYu1SuTz7wzf0MEvo0poojRw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-16 17:10 ` viresh kumar
2012-04-16 17:33 ` Sergei Shtylyov
2012-04-16 4:13 ` [PATCH V4 2/5] SPEAr: Remove existing padmux support for SPEAr Viresh Kumar
2012-04-16 4:13 ` [PATCH V4 3/5] pinctrl: Add SPEAr pinctrl drivers Viresh Kumar
[not found] ` <f9cc539f87a9c73546fe6671d55d86838886adce.1334548272.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
2012-04-17 8:32 ` Viresh Kumar
[not found] ` <4F8D2A88.6060309-qxv4g6HH51o@public.gmane.org>
2012-04-18 11:24 ` Linus Walleij
2012-04-16 4:14 ` [PATCH V4 5/5] SPEAr3xx: Add pinctrl support for boards Viresh Kumar
[not found] ` <cover.1334548272.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
2012-04-16 9:29 ` [PATCH V4 0/5] pinctrl: Add SPEAr pinctrl support Linus Walleij
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=6a0872f9d8959bc9d66d179e4911d6f09a219b42.1334548272.git.viresh.kumar@st.com \
--to=viresh.kumar@st.com \
--cc=arnd@arndb.de \
--cc=devicetree-discuss@ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=olof@lixom.net \
--cc=spear-devel@list.st.com \
--cc=swarren@wwwdotorg.org \
--cc=viresh.linux@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 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).