Skip to content

Commit e255a79

Browse files
mwalleambarus
authored andcommitted
mtd: spi-nor: default .n_banks to 1
If .n_banks is not set in the flash_info database, the default value should be 1. This way, we don't have to always set the .n_banks parameter in flash_info. 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-8-e60548861b10@kernel.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent 9983e6d commit e255a79

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

drivers/mtd/spi-nor/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,6 @@ static const struct spi_nor_manufacturer *manufacturers[] = {
20172017

20182018
static const struct flash_info spi_nor_generic_flash = {
20192019
.name = "spi-nor-generic",
2020-
.n_banks = 1,
20212020
.parse_sfdp = true,
20222021
};
20232022

@@ -2997,7 +2996,7 @@ static void spi_nor_init_default_params(struct spi_nor *nor)
29972996
params->size = info->size;
29982997
params->bank_size = params->size;
29992998
params->page_size = info->page_size ?: SPI_NOR_DEFAULT_PAGE_SIZE;
3000-
params->n_banks = info->n_banks;
2999+
params->n_banks = info->n_banks ?: SPI_NOR_DEFAULT_N_BANKS;
30013000

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

drivers/mtd/spi-nor/core.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* have the page size defined within their SFDP tables.
1616
*/
1717
#define SPI_NOR_DEFAULT_PAGE_SIZE 256
18+
#define SPI_NOR_DEFAULT_N_BANKS 1
1819

1920
/* Standard SPI NOR flash operations. */
2021
#define SPI_NOR_READID_OP(naddr, ndummy, buf, len) \
@@ -453,7 +454,7 @@ struct spi_nor_fixups {
453454
* @size: the size of the flash in bytes.
454455
* @sector_size: the size listed here is what works with SPINOR_OP_SE, which
455456
* isn't necessarily called a "sector" by the vendor.
456-
* @n_banks: the number of banks.
457+
* @n_banks: (optional) the number of banks. Defaults to 1.
457458
* @page_size: (optional) the flash's page size. Defaults to 256.
458459
* @addr_nbytes: number of address bytes to send.
459460
*
@@ -570,21 +571,20 @@ struct flash_info {
570571
/* Used when the "_ext_id" is two bytes at most */
571572
#define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors) \
572573
SPI_NOR_ID((_jedec_id), (_ext_id)), \
573-
SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), 1),
574+
SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), 0),
574575

575576
#define INFOB(_jedec_id, _ext_id, _sector_size, _n_sectors, _n_banks) \
576577
SPI_NOR_ID((_jedec_id), (_ext_id)), \
577578
SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), (_n_banks)),
578579

579580
#define INFO6(_jedec_id, _ext_id, _sector_size, _n_sectors) \
580581
SPI_NOR_ID6((_jedec_id), (_ext_id)), \
581-
SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), 1),
582+
SPI_NOR_GEOMETRY((_sector_size), (_n_sectors), 0),
582583

583584
#define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_nbytes) \
584585
.size = (_sector_size) * (_n_sectors), \
585586
.sector_size = (_sector_size), \
586587
.page_size = (_page_size), \
587-
.n_banks = 1, \
588588
.addr_nbytes = (_addr_nbytes), \
589589
.flags = SPI_NOR_NO_ERASE | SPI_NOR_NO_FR, \
590590

drivers/mtd/spi-nor/xilinx.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
.size = 8 * (_page_size) * (_n_sectors), \
2727
.sector_size = (8 * (_page_size)), \
2828
.page_size = (_page_size), \
29-
.n_banks = 1, \
3029
.flags = SPI_NOR_NO_FR
3130

3231
/* Xilinx S3AN share MFR with Atmel SPI NOR */

0 commit comments

Comments
 (0)