summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-02-18 11:01:59 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-02-23 08:15:57 +0100
commitfe7855bb4f2d82ac4559c46c586c2f29e9f123e2 (patch)
treee249f3d4120db310564433797666907b425c9fe3
parent8ee5479a28df0a3f3019419e46e9ee5c119a27bd (diff)
downloadbarebox-fe7855bb4f2d82ac4559c46c586c2f29e9f123e2.tar.gz
barebox-fe7855bb4f2d82ac4559c46c586c2f29e9f123e2.tar.xz
driver: Introduce dev_request_mem_resource
dev_request_mem_region returns a void * which shall be checked with IS_ERR(), but in some cases the valid pointer returned clashes with error values. This is especially the case on some Atmel SoCs. This introduces dev_request_mem_resource which returns a struct resource instead which in any case can be checked with IS_ERR(). It's the drivers responsibility then to get the IOMEM pointer from the resource. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/base/driver.c11
-rw-r--r--include/driver.h6
2 files changed, 15 insertions, 2 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index c529296fc6..5867fe45d0 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -404,7 +404,7 @@ void __iomem *dev_request_mem_region_err_null(struct device_d *dev, int num)
}
EXPORT_SYMBOL(dev_request_mem_region_err_null);
-void __iomem *dev_request_mem_region(struct device_d *dev, int num)
+struct resource *dev_request_mem_resource(struct device_d *dev, int num)
{
struct resource *res;
@@ -412,7 +412,14 @@ void __iomem *dev_request_mem_region(struct device_d *dev, int num)
if (IS_ERR(res))
return ERR_CAST(res);
- res = request_iomem_region(dev_name(dev), res->start, res->end);
+ return request_iomem_region(dev_name(dev), res->start, res->end);
+}
+
+void __iomem *dev_request_mem_region(struct device_d *dev, int num)
+{
+ struct resource *res;
+
+ res = dev_request_mem_resource(dev, num);
if (IS_ERR(res))
return ERR_CAST(res);
diff --git a/include/driver.h b/include/driver.h
index 31c673452f..5e2b88f315 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -203,10 +203,16 @@ void *dev_get_mem_region(struct device_d *dev, int num);
/*
* exlusively request register base 'num' for a device
+ * deprecated, use dev_request_mem_resource instead
*/
void __iomem *dev_request_mem_region(struct device_d *dev, int num);
/*
+ * exlusively request resource 'num' for a device
+ */
+struct resource *dev_request_mem_resource(struct device_d *dev, int num);
+
+/*
* exlusively request register base 'num' for a device
* will return NULL on error
* only used on platform like at91 where the Ressource address collision with