Skip to content

Commit d0cfd22

Browse files
mwalleambarus
authored andcommitted
mtd: spi-nor: default page_size to 256 bytes
The INFO() macro always set the page_size to 256 bytes. Make that an optional parameter. This default is a sane one for all older flashes, newer ones will set the page size by its SFDP tables anyway. Signed-off-by: Michael Walle <mwalle@kernel.org> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/r/20230807-mtd-flash-info-db-rework-v3-6-e60548861b10@kernel.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent 0554eff commit d0cfd22

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

drivers/mtd/spi-nor/core.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,11 +2018,6 @@ static const struct spi_nor_manufacturer *manufacturers[] = {
20182018
static const struct flash_info spi_nor_generic_flash = {
20192019
.name = "spi-nor-generic",
20202020
.n_banks = 1,
2021-
/*
2022-
* JESD216 rev A doesn't specify the page size, therefore we need a
2023-
* sane default.
2024-
*/
2025-
.page_size = 256,
20262021
.parse_sfdp = true,
20272022
};
20282023

@@ -3001,7 +2996,7 @@ static void spi_nor_init_default_params(struct spi_nor *nor)
30012996
params->writesize = 1;
30022997
params->size = info->size;
30032998
params->bank_size = params->size;
3004-
params->page_size = info->page_size;
2999+
params->page_size = info->page_size ?: SPI_NOR_DEFAULT_PAGE_SIZE;
30053000

30063001
if (!(info->flags & SPI_NOR_NO_FR)) {
30073002
/* Default to Fast Read for DT and non-DT platform devices. */

drivers/mtd/spi-nor/core.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
#include "sfdp.h"
1111

1212
#define SPI_NOR_MAX_ID_LEN 6
13+
/*
14+
* 256 bytes is a sane default for most older flashes. Newer flashes will
15+
* have the page size defined within their SFDP tables.
16+
*/
17+
#define SPI_NOR_DEFAULT_PAGE_SIZE 256
1318

1419
/* Standard SPI NOR flash operations. */
1520
#define SPI_NOR_READID_OP(naddr, ndummy, buf, len) \
@@ -447,7 +452,7 @@ struct spi_nor_fixups {
447452
* @sector_size: the size listed here is what works with SPINOR_OP_SE, which
448453
* isn't necessarily called a "sector" by the vendor.
449454
* @n_banks: the number of banks.
450-
* @page_size: the flash's page size.
455+
* @page_size: (optional) the flash's page size. Defaults to 256.
451456
* @addr_nbytes: number of address bytes to send.
452457
*
453458
* @parse_sfdp: true when flash supports SFDP tables. The false value has no
@@ -558,7 +563,6 @@ struct flash_info {
558563
#define SPI_NOR_GEOMETRY(_sector_size, _n_sectors, _n_banks) \
559564
.size = (_sector_size) * (_n_sectors), \
560565
.sector_size = (_sector_size), \
561-
.page_size = 256, \
562566
.n_banks = (_n_banks)
563567

564568
/* Used when the "_ext_id" is two bytes at most */

0 commit comments

Comments
 (0)