From dbcd47c17bc8e968ab97602de9cd44397b0c118c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 30 Mar 2017 15:28:08 +0200 Subject: cdev: Collect partitions on list We currently do not have a way to iterate over all partitions of a cdev. Change this. Signed-off-by: Sascha Hauer --- fs/devfs-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'fs') diff --git a/fs/devfs-core.c b/fs/devfs-core.c index 75ed3b0e66..89ddb6a398 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -277,6 +277,7 @@ int devfs_create(struct cdev *new) return -EEXIST; INIT_LIST_HEAD(&new->links); + INIT_LIST_HEAD(&new->partitions); list_add_tail(&new->list, &cdev_list); if (new->dev) { @@ -326,6 +327,9 @@ int devfs_remove(struct cdev *cdev) list_for_each_entry_safe(c, tmp, &cdev->links, link_entry) devfs_remove(c); + if (cdev->flags & DEVFS_IS_PARTITION) + list_del(&cdev->partition_entry); + if (cdev->link) free(cdev); @@ -374,6 +378,8 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev, partinfo->flags, partinfo->name); if (IS_ERR(mtd)) return (void *)mtd; + + list_add_tail(&mtd->cdev.partition_entry, &cdev->partitions); return &mtd->cdev; } @@ -390,6 +396,8 @@ static struct cdev *__devfs_add_partition(struct cdev *cdev, new->dev = cdev->dev; new->flags = partinfo->flags | DEVFS_IS_PARTITION; + list_add_tail(&new->partition_entry, &cdev->partitions); + devfs_create(new); return new; -- cgit v1.2.3