[PATCH 2/5] mem: add multiple resource support

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Fri Nov 12 13:18:55 EST 2010


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 commands/mem.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/commands/mem.c b/commands/mem.c
index 05956ab..d35c8c0 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -589,18 +589,23 @@ static struct file_operations memops = {
 
 static int mem_probe(struct device_d *dev)
 {
-	struct resource *res = &dev->resource[0];
+	int i;
+	struct resource *res;
 	struct cdev *cdev;
 
-	cdev = xzalloc(sizeof (*cdev));
-	dev->priv = cdev;
+	for (i = 0; i < dev->num_resources; i++) {
+		res = &dev->resource[i];
 
-	cdev->name = (char*)res->name;
-	cdev->size = res->size;
-	cdev->ops = &memops;
-	cdev->dev = dev;
+		cdev = xzalloc(sizeof (*cdev));
+		dev->priv = cdev;
 
-	devfs_create(cdev);
+		cdev->name = (char*)res->name;
+		cdev->size = res->size;
+		cdev->ops = &memops;
+		cdev->dev = dev;
+
+		devfs_create(cdev);
+	}
 
 	return 0;
 }
-- 
1.7.1




More information about the barebox mailing list