From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 5/5] implement resource management for platform devices
Date: Mon, 5 Dec 2011 09:56:01 +0100 [thread overview]
Message-ID: <1323075361-27455-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1323075361-27455-1-git-send-email-s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/base/driver.c | 29 +++++++++++++++++++++++++++--
include/driver.h | 6 +-----
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 0b80103..0132e7d 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -214,7 +214,7 @@ int register_driver(struct driver_d *drv)
}
EXPORT_SYMBOL(register_driver);
-void __iomem *dev_get_mem_region(struct device_d *dev, int num)
+static struct resource *dev_get_resource(struct device_d *dev, int num)
{
int i, n = 0;
@@ -222,15 +222,40 @@ void __iomem *dev_get_mem_region(struct device_d *dev, int num)
struct resource *res = &dev->resource[i];
if (resource_type(res) == IORESOURCE_MEM) {
if (n == num)
- return (void __force __iomem *)res->start;
+ return res;
n++;
}
}
return NULL;
}
+
+void __iomem *dev_get_mem_region(struct device_d *dev, int num)
+{
+ struct resource *res;
+
+ res = dev_get_resource(dev, num);
+ if (!res)
+ return res;
+
+ return (void __force __iomem *)res->start;
+}
EXPORT_SYMBOL(dev_get_mem_region);
+void __iomem *dev_request_mem_region(struct device_d *dev, int num)
+{
+ struct resource *res;
+
+ res = dev_get_resource(dev, num);
+ if (!res)
+ return NULL;
+
+ res = request_iomem_region(dev_name(dev), res->start, res->size);
+
+ return (void __force __iomem *)res->start;
+}
+EXPORT_SYMBOL(dev_request_mem_region);
+
int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot)
{
printf("%s: currently broken\n", __func__);
diff --git a/include/driver.h b/include/driver.h
index fe9d37a..bbe7248 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -190,11 +190,7 @@ void __iomem *dev_get_mem_region(struct device_d *dev, int num);
/*
* exlusively request register base 'num' for a device
*/
-static inline void __iomem *dev_request_mem_region(struct device_d *dev, int num)
-{
- /* no resource tracking yet */
- return dev_get_mem_region(dev, num);
-}
+void __iomem *dev_request_mem_region(struct device_d *dev, int num);
/*
* register a generic device
--
1.7.7.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2011-12-05 8:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-05 8:55 [PATCH] resources Sascha Hauer
2011-12-05 8:55 ` [PATCH 1/5] fix malloc space sizes Sascha Hauer
2011-12-05 8:55 ` [PATCH 2/5] add resource management functions Sascha Hauer
2011-12-05 8:55 ` [PATCH 3/5] add iomem command to show iomem usage Sascha Hauer
2011-12-05 8:56 ` [PATCH 4/5] register sdram as resources Sascha Hauer
2011-12-05 8:56 ` Sascha Hauer [this message]
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=1323075361-27455-6-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.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