[PATCH 7/8] cdev: create iterator for cdev list

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

 



This creates an iterator to iterate over all availabe cdevs.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 fs/devfs-core.c  | 10 +++++-----
 fs/devfs.c       |  4 +---
 include/driver.h |  4 ++++
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index c9a8529737..2f2882dcc8 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -37,7 +37,7 @@ int devfs_partition_complete(struct string_list *sl, char *instr)
 
 	len = strlen(instr);
 
-	list_for_each_entry(cdev, &cdev_list, list) {
+	for_each_cdev(cdev) {
 		if (cdev->master &&
 		    !strncmp(instr, cdev->name, len)) {
 			string_list_add_asprintf(sl, "%s ", cdev->name);
@@ -62,7 +62,7 @@ struct cdev *lcdev_by_name(const char *filename)
 {
 	struct cdev *cdev;
 
-	list_for_each_entry(cdev, &cdev_list, list) {
+	for_each_cdev(cdev) {
 		if (!strcmp(cdev->name, filename))
 			return cdev;
 	}
@@ -84,7 +84,7 @@ struct cdev *cdev_by_device_node(struct device_node *node)
 {
 	struct cdev *cdev;
 
-	list_for_each_entry(cdev, &cdev_list, list) {
+	for_each_cdev(cdev) {
 		if (!cdev->device_node)
 			continue;
 		if (cdev->device_node == node)
@@ -100,7 +100,7 @@ struct cdev *cdev_by_partuuid(const char *partuuid)
 	if (!partuuid)
 		return NULL;
 
-	list_for_each_entry(cdev, &cdev_list, list) {
+	for_each_cdev(cdev) {
 		if (cdev->master && !strcasecmp(cdev->uuid, partuuid))
 			return cdev;
 	}
@@ -114,7 +114,7 @@ struct cdev *cdev_by_diskuuid(const char *diskuuid)
 	if (!diskuuid)
 		return NULL;
 
-	list_for_each_entry(cdev, &cdev_list, list) {
+	for_each_cdev(cdev) {
 		if (!cdev->master && !strcasecmp(cdev->uuid, diskuuid))
 			return cdev;
 	}
diff --git a/fs/devfs.c b/fs/devfs.c
index d205881765..deb244feea 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -35,8 +35,6 @@ struct devfs_inode {
 	struct cdev *cdev;
 };
 
-extern struct list_head cdev_list;
-
 static int devfs_read(struct device_d *_dev, FILE *f, void *buf, size_t size)
 {
 	struct cdev *cdev = f->priv;
@@ -179,7 +177,7 @@ static int devfs_iterate(struct file *file, struct dir_context *ctx)
 
 	dir_emit_dots(file, ctx);
 
-	list_for_each_entry(cdev, &cdev_list, list) {
+	for_each_cdev(cdev) {
 		dir_emit(ctx, cdev->name, strlen(cdev->name),
 				1 /* FIXME */, DT_REG);
 	}
diff --git a/include/driver.h b/include/driver.h
index b9b0b8497d..79d287ec31 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -510,6 +510,10 @@ int cdev_memmap(struct cdev*, void **map, int flags);
 int cdev_truncate(struct cdev*, size_t size);
 loff_t cdev_unallocated_space(struct cdev *cdev);
 
+extern struct list_head cdev_list;
+#define for_each_cdev(c) \
+	list_for_each_entry(cdev, &cdev_list, list)
+
 #define DEVFS_PARTITION_FIXED		(1U << 0)
 #define DEVFS_PARTITION_READONLY	(1U << 1)
 #define DEVFS_IS_CHARACTER_DEV		(1U << 3)
-- 
2.30.2


_______________________________________________
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