mtd: keep original flags for every struct mtd_info

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>
This commit is contained in:
Rafał Miłecki 2018-11-20 09:55:45 +01:00 committed by Boris Brezillon
parent 89f706dbd5
commit 1186af457c
3 changed files with 5 additions and 1 deletions

View File

@ -665,6 +665,8 @@ static void mtd_set_dev_defaults(struct mtd_info *mtd)
} else { } else {
pr_debug("mtd device won't show a device symlink in sysfs\n"); pr_debug("mtd device won't show a device symlink in sysfs\n");
} }
mtd->orig_flags = mtd->flags;
} }
/** /**

View File

@ -346,7 +346,8 @@ static struct mtd_part *allocate_partition(struct mtd_info *parent,
/* set up the MTD object for this partition */ /* set up the MTD object for this partition */
slave->mtd.type = parent->type; 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.size = part->size;
slave->mtd.writesize = parent->writesize; slave->mtd.writesize = parent->writesize;
slave->mtd.writebufsize = parent->writebufsize; slave->mtd.writebufsize = parent->writebufsize;

View File

@ -207,6 +207,7 @@ struct mtd_debug_info {
struct mtd_info { struct mtd_info {
u_char type; u_char type;
uint32_t flags; uint32_t flags;
uint32_t orig_flags; /* Flags as before running mtd checks */
uint64_t size; // Total size of the MTD uint64_t size; // Total size of the MTD
/* "Major" erase size for the device. Naïve users may take this /* "Major" erase size for the device. Naïve users may take this