[PATCH] mtd: spi-nor: core: Set mtd->eraseregions for non-uniform erase map

Michael Walle michael at walle.cc
Fri Jan 12 04:01:06 PST 2024


>> +	struct mtd_erase_region_info *mtd_region;
>> +	u32 erase_size;
>> +	u8 erase_mask;
> 
> put the u8 last to avoid stack padding

I don't think that is a thing. Even if it were, it might clash
with the RCT.

I couldn't find anything about how automatic variables are placed
in memory. I'd say its not specified in the standard and the compiler
is free to do optimizations here or just keep the contents in
registers (?!).

Any stytle recommendations for spi-nor? I prefer RCT, but if we want
to say declaration order doesn't matter, I'm fine with that too.

>> +
>> +	for (i = 0; !spi_nor_region_is_last(&region[i]); i++)
>> +		;
>> +
>> +	n_regions = i + 1;
> 
> all this just to get the number of regions? how about saving the number
> of regions somewhere and use it everywhere?

This whole region thing should be rewritten to not store these magic
bits in the offset.

-michael



More information about the linux-mtd mailing list