mtd: ubi: block: wire-up device parent
authorDaniel Golle <daniel@makrotopia.org>
Thu, 22 Dec 2022 19:33:31 +0000 (19:33 +0000)
committerRichard Weinberger <richard@nod.at>
Mon, 13 Feb 2023 21:24:10 +0000 (22:24 +0100)
ubiblock devices were previously only identifyable by their name, but
not connected to their parent UBI volume device e.g. in sysfs.
Properly parent ubiblock device as descendant of a UBI volume device
to reflect device model hierachy.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/block.c
drivers/mtd/ubi/kapi.c
include/linux/mtd/ubi.h

index f5d036203fe7f496e16db099cec258bb80f50586..6a9eb2c860b5a9b299b74836825715ecf45d6791 100644 (file)
@@ -419,7 +419,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
        list_add_tail(&dev->list, &ubiblock_devices);
 
        /* Must be the last step: anyone can call file ops from now on */
-       ret = add_disk(dev->gd);
+       ret = device_add_disk(vi->dev, dev->gd, NULL);
        if (ret)
                goto out_remove_minor;
 
index 0fce99ff29b583639723676b24341231f731952a..5db653eacbd451ba6efc08e4ce96c192159fef44 100644 (file)
@@ -79,6 +79,7 @@ void ubi_do_get_volume_info(struct ubi_device *ubi, struct ubi_volume *vol,
        vi->name_len = vol->name_len;
        vi->name = vol->name;
        vi->cdev = vol->cdev.dev;
+       vi->dev = &vol->dev;
 }
 
 /**
index 7d48ea368c5e57c5361da337d01896c20fe5e06e..a529347fd75b2a065f618d45771b27a7bd163f80 100644 (file)
@@ -110,6 +110,7 @@ struct ubi_volume_info {
        int name_len;
        const char *name;
        dev_t cdev;
+       struct device *dev;
 };
 
 /**