[PATCH 08/18] [RFC] base: Introduce dev_request_mem_resource

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

 



Introduce dev_request_mem_resource as a version of
dev_request_mem_region that returns the corresponding 'struct resource'
and thus allows to perform proper resource deallocation. This is useful
for drivers that can experience deferred probling and need to be able to
be probed twice.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 drivers/base/driver.c | 12 ++++++++++++
 include/driver.h      |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index a3ca057..9e55061 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -385,6 +385,18 @@ void __iomem *dev_request_mem_region_by_name(struct device_d *dev, const char *n
 }
 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);
+}
+EXPORT_SYMBOL(dev_request_mem_resource);
+
 void __iomem *dev_request_mem_region(struct device_d *dev, int num)
 {
 	struct resource *res;
diff --git a/include/driver.h b/include/driver.h
index 08adaf9..2e67223 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -206,6 +206,8 @@ void *dev_get_mem_region(struct device_d *dev, int num);
  */
 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 device_d *device_alloc(const char *devname, int id);
 
 int device_add_resources(struct device_d *dev, const struct resource *res, int num);
-- 
2.5.0


_______________________________________________
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