mtd: implement proper partition handling
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 14 Jan 2020 09:09:52 +0000 (10:09 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 11 Mar 2020 13:49:30 +0000 (14:49 +0100)
commit46b5889cc2c54bac7d7e727a44d28a298df23cef
treef3baa809955aa2f4769e3f95e51be986db9a34ee
parent98d54f81e36ba3bf92172791eba5ca5bd813989b
mtd: implement proper partition handling

Instead of collecting partitions in a flat list, create a hierarchy
within the mtd_info structure: use a partitions list to keep track of
the partitions of an MTD device (which might be itself a partition of
another MTD device), a pointer to the parent device (NULL when the MTD
device is the root one, not a partition).

By also saving directly in mtd_info the offset of the partition, we
can get rid of the mtd_part structure.

While at it, be consistent in the naming of the mtd_info structures to
ease the understanding of the new hierarchy: these structures are
usually called 'mtd', unless there are multiple instances of the same
structure. In this case, there is usually a parent/child bound so we
will call them 'parent' and 'child'.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20200114090952.11232-1-miquel.raynal@bootlin.com
drivers/mtd/mtdchar.c
drivers/mtd/mtdcore.c
drivers/mtd/mtdpart.c
include/linux/mtd/mtd.h
include/linux/mtd/partitions.h