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

Michael Walle michael at walle.cc
Mon Feb 12 04:37:13 PST 2024


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 = region - 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.

-michael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20240212/d6cd1f13/attachment.sig>


More information about the linux-mtd mailing list