[PATCH 6/6] drivers: base: Share code for getting and then requesting a region

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 drivers/base/driver.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 476f844be..687e36e1b 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -355,6 +355,19 @@ dev_get_resource_by_name_or_id(struct device_d *dev, unsigned long type,
 	return ERR_PTR(-ENOENT);
 }
 
+static struct resource *
+dev_request_resource_by_name_or_id(struct device_d *dev, unsigned long type,
+				   const char *name, int num)
+{
+	struct resource *res;
+
+	res = dev_get_resource_by_name_or_id(dev, type, name, num);
+	if (IS_ERR(res))
+		return ERR_CAST(res);
+
+	return request_iomem_region(dev_name(dev), res->start, res->end);
+}
+
 struct resource *dev_get_resource(struct device_d *dev, unsigned long type,
 				  int num)
 {
@@ -384,11 +397,8 @@ void __iomem *dev_request_mem_region_by_name(struct device_d *dev, const char *n
 {
 	struct resource *res;
 
-	res = dev_get_resource_by_name(dev, IORESOURCE_MEM, name);
-	if (IS_ERR(res))
-		return ERR_CAST(res);
-
-	res = request_iomem_region(dev_name(dev), res->start, res->end);
+	res = dev_request_resource_by_name_or_id(dev, IORESOURCE_MEM,
+						 name, -1);
 	if (IS_ERR(res))
 		return ERR_CAST(res);
 
@@ -398,13 +408,8 @@ EXPORT_SYMBOL(dev_request_mem_region_by_name);
 
 struct resource *dev_request_mem_resource(struct device_d *dev, int num)
 {
-	struct resource *res;
-
-	res = dev_get_resource(dev, IORESOURCE_MEM, num);
-	if (IS_ERR(res))
-		return ERR_CAST(res);
-
-	return request_iomem_region(dev_name(dev), res->start, res->end);
+	return dev_request_resource_by_name_or_id(dev, IORESOURCE_MEM,
+						  NULL, num);
 }
 
 static void __iomem *__dev_request_mem_region(struct device_d *dev, int num,
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux