Skip to content

Commit 9983e6d

Browse files
mwalleambarus
authored andcommitted
mtd: spi-nor: store .n_banks in struct spi_nor_flash_parameter
First, fixups might want to replace the n_banks parameter, thus we need it in the (writable) parameter struct. Secondly, this way we can have a default in the core and just skip setting the n_banks in the flash_info database. Most of the flashes doesn't have more than one bank. 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-7-e60548861b10@kernel.org Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
1 parent d0cfd22 commit 9983e6d

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/mtd/spi-nor/core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,7 +2862,7 @@ static void spi_nor_init_flags(struct spi_nor *nor)
28622862
if (flags & NO_CHIP_ERASE)
28632863
nor->flags |= SNOR_F_NO_OP_CHIP_ERASE;
28642864

2865-
if (flags & SPI_NOR_RWW && nor->info->n_banks > 1 &&
2865+
if (flags & SPI_NOR_RWW && nor->params->n_banks > 1 &&
28662866
!nor->controller_ops)
28672867
nor->flags |= SNOR_F_RWW;
28682868
}
@@ -2926,8 +2926,8 @@ static int spi_nor_late_init_params(struct spi_nor *nor)
29262926
if (nor->flags & SNOR_F_HAS_LOCK && !nor->params->locking_ops)
29272927
spi_nor_init_default_locking_ops(nor);
29282928

2929-
if (nor->info->n_banks > 1)
2930-
params->bank_size = div64_u64(params->size, nor->info->n_banks);
2929+
if (params->n_banks > 1)
2930+
params->bank_size = div64_u64(params->size, params->n_banks);
29312931

29322932
return 0;
29332933
}
@@ -2997,6 +2997,7 @@ static void spi_nor_init_default_params(struct spi_nor *nor)
29972997
params->size = info->size;
29982998
params->bank_size = params->size;
29992999
params->page_size = info->page_size ?: SPI_NOR_DEFAULT_PAGE_SIZE;
3000+
params->n_banks = info->n_banks;
30003001

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

drivers/mtd/spi-nor/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ struct spi_nor_otp {
358358
* in octal DTR mode.
359359
* @rdsr_addr_nbytes: dummy address bytes needed for Read Status Register
360360
* command in octal DTR mode.
361+
* @n_banks: number of banks.
361362
* @n_dice: number of dice in the flash memory.
362363
* @vreg_offset: volatile register offset for each die.
363364
* @hwcaps: describes the read and page program hardware
@@ -394,6 +395,7 @@ struct spi_nor_flash_parameter {
394395
u8 addr_mode_nbytes;
395396
u8 rdsr_dummy;
396397
u8 rdsr_addr_nbytes;
398+
u8 n_banks;
397399
u8 n_dice;
398400
u32 *vreg_offset;
399401

0 commit comments

Comments
 (0)