Merge tag 'folio-5.18d' of git://git.infradead.org/users/willy/pagecache
[linux-2.6-microblaze.git] / drivers / mtd / ubi / build.c
index a7e3eb9..a32050f 100644 (file)
@@ -351,9 +351,6 @@ static ssize_t dev_attribute_show(struct device *dev,
         * we still can use 'ubi->ubi_num'.
         */
        ubi = container_of(dev, struct ubi_device, dev);
-       ubi = ubi_get_device(ubi->ubi_num);
-       if (!ubi)
-               return -ENODEV;
 
        if (attr == &dev_eraseblock_size)
                ret = sprintf(buf, "%d\n", ubi->leb_size);
@@ -382,7 +379,6 @@ static ssize_t dev_attribute_show(struct device *dev,
        else
                ret = -EINVAL;
 
-       ubi_put_device(ubi);
        return ret;
 }
 
@@ -979,9 +975,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
                        goto out_detach;
        }
 
-       /* Make device "available" before it becomes accessible via sysfs */
-       ubi_devices[ubi_num] = ubi;
-
        err = uif_init(ubi);
        if (err)
                goto out_detach;
@@ -1026,6 +1019,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
        wake_up_process(ubi->bgt_thread);
        spin_unlock(&ubi->wl_lock);
 
+       ubi_devices[ubi_num] = ubi;
        ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL);
        return ubi_num;
 
@@ -1034,7 +1028,6 @@ out_debugfs:
 out_uif:
        uif_close(ubi);
 out_detach:
-       ubi_devices[ubi_num] = NULL;
        ubi_wl_close(ubi);
        ubi_free_all_volumes(ubi);
        vfree(ubi->vtbl);