[PATCH 4/6] drivers: base: Simplify dev_request_mem_region_err_null()

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

 



Simplify dev_request_mem_region_err_null() by making use of
dev_request_mem_resource() to implement it.

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

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 4c1b6110a..c687afd75 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -396,32 +396,28 @@ void __iomem *dev_request_mem_region_by_name(struct device_d *dev, const char *n
 }
 EXPORT_SYMBOL(dev_request_mem_region_by_name);
 
-void __iomem *dev_request_mem_region_err_null(struct device_d *dev, int num)
+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 NULL;
-
-	res = request_iomem_region(dev_name(dev), res->start, res->end);
-	if (IS_ERR(res))
-		return NULL;
+		return ERR_CAST(res);
 
-	return IOMEM(res->start);
+	return request_iomem_region(dev_name(dev), res->start, res->end);
 }
-EXPORT_SYMBOL(dev_request_mem_region_err_null);
 
-struct resource *dev_request_mem_resource(struct device_d *dev, int num)
+void __iomem *dev_request_mem_region_err_null(struct device_d *dev, int num)
 {
 	struct resource *res;
 
-	res = dev_get_resource(dev, IORESOURCE_MEM, num);
+	res = dev_request_mem_resource(dev, num);
 	if (IS_ERR(res))
-		return ERR_CAST(res);
+		return NULL;
 
-	return request_iomem_region(dev_name(dev), res->start, res->end);
+	return IOMEM(res->start);
 }
+EXPORT_SYMBOL(dev_request_mem_region_err_null);
 
 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