diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2011-07-19 08:34:33 +0200 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-07-18 20:20:04 +0800 |
commit | d5b96bdca994ab00de350fe698a7daa09292ab29 (patch) | |
tree | 37f75b483d202827e4036578fbb75918a9f86348 /lib | |
parent | 56fe623bfeb0dade618f9f93a4b9c125694e4c81 (diff) | |
download | barebox-d5b96bdca994ab00de350fe698a7daa09292ab29.tar.gz barebox-d5b96bdca994ab00de350fe698a7daa09292ab29.tar.xz |
device: Add a dev_request_mem_region function
We might want to add real resource tracking later. Also
The first resource may not be a IORESOURCE_MEM at all.
For these reasons introduce a wrapper function for
driver so that they do not have to fiddle with resources
directly.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/driver.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/driver.c b/lib/driver.c index 95e42d5ffd..b5166c82ef 100644 --- a/lib/driver.c +++ b/lib/driver.c @@ -233,6 +233,23 @@ int register_driver(struct driver_d *drv) } EXPORT_SYMBOL(register_driver); +void __iomem *dev_get_mem_region(struct device_d *dev, int num) +{ + int i, n = 0; + + for (i = 0; i < dev->num_resources; i++) { + struct resource *res = &dev->resource[i]; + if (resource_type(res) == IORESOURCE_MEM) { + if (n == num) + return (void __force __iomem *)res->start; + n++; + } + } + + return NULL; +} +EXPORT_SYMBOL(dev_get_mem_region); + int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot) { printf("%s: currently broken\n", __func__); |