Skip to content

Commit

Permalink
mtd: spi-nor: Fix mtd size for s3an flashes
Browse files Browse the repository at this point in the history
[ Upstream commit f656b41 ]

As it was before the blamed commit, s3an_nor_scan() was called
after mtd size was set with params->size, and it overwrote the mtd
size value with '8 * nor->page_size * nor->info->n_sectors' when
XSR_PAGESIZE was set. With the introduction of
s3an_post_sfdp_fixups(), we missed to update the mtd size for the
s3an flashes. Fix the mtd size by updating both nor->params->size,
(which will update the mtd_info size later on) and nor->mtd.size
(which is used in spi_nor_set_addr_width()).

Fixes: 641eddd ("mtd: spi-nor: Add s3an_post_sfdp_fixups()")
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20211207140254.87681-2-tudor.ambarus@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ambarus authored and gregkh committed Mar 8, 2022
1 parent 83ef635 commit 64b487b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mtd/spi-nor/xilinx.c
Expand Up @@ -66,7 +66,8 @@ static int xilinx_nor_setup(struct spi_nor *nor,
/* Flash in Power of 2 mode */
nor->page_size = (nor->page_size == 264) ? 256 : 512;
nor->mtd.writebufsize = nor->page_size;
nor->mtd.size = 8 * nor->page_size * nor->info->n_sectors;
nor->params->size = 8 * nor->page_size * nor->info->n_sectors;
nor->mtd.size = nor->params->size;
nor->mtd.erasesize = 8 * nor->page_size;
} else {
/* Flash in Default addressing mode */
Expand Down

0 comments on commit 64b487b

Please sign in to comment.