]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mtd: keep original flags for every struct mtd_info
authorRafał Miłecki <rafal@milecki.pl>
Tue, 20 Nov 2018 08:55:45 +0000 (09:55 +0100)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Sun, 2 Dec 2018 08:29:16 +0000 (09:29 +0100)
When allocating a new partition mtd subsystem runs internal tests in the
allocate_partition(). They may result in modifying specified flags (e.g.
dropping some /features/ like write access).

Those constraints don't have to be necessary true for subpartitions. It
may happen parent partition isn't block aligned (effectively disabling
write access) while subpartition may fit blocks nicely. In such case all
checks should be run again (starting with original flags value).

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
drivers/mtd/mtdcore.c
drivers/mtd/mtdpart.c
include/linux/mtd/mtd.h

index afb4b17fb670e9f4b3161219e9a0a0878ddebbe9..b6b93291aba9b13c89ceff0795403c8a6fd41126 100644 (file)
@@ -665,6 +665,8 @@ static void mtd_set_dev_defaults(struct mtd_info *mtd)
        } else {
                pr_debug("mtd device won't show a device symlink in sysfs\n");
        }
+
+       mtd->orig_flags = mtd->flags;
 }
 
 /**
index 99c460facd5e97702896aae893d4df258320c0f2..2b6e53af47da399587d56c8ba0c736e6c069e979 100644 (file)
@@ -346,7 +346,8 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent,
 
        /* set up the MTD object for this partition */
        slave->mtd.type = parent->type;
-       slave->mtd.flags = parent->flags & ~part->mask_flags;
+       slave->mtd.flags = parent->orig_flags & ~part->mask_flags;
+       slave->mtd.orig_flags = slave->mtd.flags;
        slave->mtd.size = part->size;
        slave->mtd.writesize = parent->writesize;
        slave->mtd.writebufsize = parent->writebufsize;
index 035d641e8847cea56cf39f34a92296feffefe5ae..ba8fa9072aca404314bf59ffded5acf7bf6b745d 100644 (file)
@@ -207,6 +207,7 @@ struct mtd_debug_info {
 struct mtd_info {
        u_char type;
        uint32_t flags;
+       uint32_t orig_flags; /* Flags as before running mtd checks */
        uint64_t size;   // Total size of the MTD
 
        /* "Major" erase size for the device. Naïve users may take this