[PATCH v3 1/2] mtd: spi-nor: core: rework erase map and erase region structures

Takahiro Kuwano tkuw584924 at gmail.com
Fri Feb 16 00:38:10 PST 2024


On 2/12/2024 9:37 PM, Michael Walle wrote:
> Hi,
> 
> On Tue Feb 6, 2024 at 5:37 AM CET,  wrote:
>> -spi_nor_region_next(struct spi_nor_erase_region *region)
>> +spi_nor_region_next(const struct spi_nor_erase_map *map,
>> +		    struct spi_nor_erase_region *region)
>>  {
>> -	if (spi_nor_region_is_last(region))
>> +	unsigned int region_idx =egion - map->regions;
> 
> I really don't like this pointer arithmetic. Also it implicitly
> assumes that region is part of the array map->regions.
> 
> Can we drop spi_nor_region_next() altogether and let the outer loop
> just use an index into map->regions? We have n_regions now, so that
> should be possible.
> 
I hesitated to rework spi_nor_init_erase_cmd_list() that may degrade
readability, but I will try now.

Thanks,
Takahiro



More information about the linux-mtd mailing list