[PATCH v2] mtd: implement proper partition handling

Miquel Raynal miquel.raynal at bootlin.com
Thu Jan 9 10:13:04 PST 2020


Hi Richard,

Richard Weinberger <richard at nod.at> wrote on Thu, 9 Jan 2020 00:34:18
+0100 (CET):

> ----- Ursprüngliche Mail -----
> > Von: "Miquel Raynal" <miquel.raynal at bootlin.com>
> > An: "richard" <richard at nod.at>, "Vignesh Raghavendra" <vigneshr at ti.com>, "Tudor Ambarus" <Tudor.Ambarus at microchip.com>,
> > "linux-mtd" <linux-mtd at lists.infradead.org>
> > CC: "Boris Brezillon" <boris.brezillon at collabora.com>, "Thomas Petazzoni" <thomas.petazzoni at bootlin.com>, "Miquel
> > Raynal" <miquel.raynal at bootlin.com>
> > Gesendet: Montag, 30. Dezember 2019 12:19:48
> > Betreff: [PATCH v2] 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).  
> 
> What problem does this solve?
> ...beside of a nice diffstat which removes more than it adds. :-)

It is much easier to escalade to the top most "master" device when
there are multiple levels of partitioning, which was not cleanly
described IMHO. Also it is already used in the MLC-in-pseudo-SLC-mode
series :)

> 
> > 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 at bootlin.com>  
> 
> [...]
> 
> > +static inline struct mtd_info *mtd_get_master(struct mtd_info *mtd)
> > +{
> > +	while (mtd->parent)
> > +		mtd = mtd->parent;
> > +
> > +	return mtd;
> > +}  
> 
> So, parent == master?

top most parent (the one without parent) == master !

> 
> When I create a MTD ontop of UBI using gluebi, who will be parent/master?

I don't really understand the issue here?

Thanks,
Miquèl



More information about the linux-mtd mailing list