Skip to content

Commit 908bf46

Browse files
committed
mtd: spi-nor: fix setting of SNOR_LAST_REGION bit
SNOR_LAST_REGION bit was incorrectly set in SNOR_ERASE_FLAGS_OFFSET, causing the iteration over regions to fail. Remove SNOR_ERASE_FLAGS_OFFSET entirely, since it's used just for initializing the region's offset in uniform case and do the init by hand. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
1 parent f74b79f commit 908bf46

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,8 +2413,9 @@ static inline void
24132413
spi_nor_init_uniform_erase_map(struct spi_nor_erase_map *map,
24142414
u8 erase_mask, u64 flash_size)
24152415
{
2416-
map->uniform_region.offset = SNOR_ERASE_FLAGS_OFFSET(erase_mask, 1, 0,
2417-
0);
2416+
/* Offset 0 with erase_mask and SNOR_LAST_REGION bit set */
2417+
map->uniform_region.offset = (erase_mask & SNOR_ERASE_TYPE_MASK) |
2418+
SNOR_LAST_REGION;
24182419
map->uniform_region.size = flash_size;
24192420
map->regions = &map->uniform_region;
24202421
map->uniform_erase_type = erase_mask;

include/linux/mtd/spi-nor.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,6 @@ struct spi_nor_erase_region {
296296
#define SNOR_ERASE_FLAGS_MAX 6
297297
#define SNOR_ERASE_FLAGS_MASK GENMASK_ULL(SNOR_ERASE_FLAGS_MAX - 1, 0)
298298

299-
#define SNOR_ERASE_FLAGS_OFFSET(_cmd_mask, _last_region, _overlaid_region, \
300-
_offset) \
301-
((((u64)(_offset)) & ~SNOR_ERASE_FLAGS_MASK) | \
302-
(((u64)(_cmd_mask)) & SNOR_ERASE_TYPE_MASK) | \
303-
(((u64)(_last_region)) & SNOR_LAST_REGION) | \
304-
(((u64)(_overlaid_region)) & SNOR_OVERLAID_REGION))
305-
306299
/**
307300
* struct spi_nor_erase_map - Structure to describe the SPI NOR erase map
308301
* @regions: array of erase regions. The regions are consecutive in

0 commit comments

Comments
 (0)