Re: [PATCH v1 2/5] mtd: cfi: introduce CFI_FLASH_BANKS
On Tue, Jan 04, 2022 at 02:23:58PM +0100, Patrick Delaunay wrote: > Replace CONFIG_SYS_MAX_FLASH_BANKS by CFI_FLASH_BANKS to prepare > Kconfig migration and avoid to redefine CONFIG_SYS_MAX_FLASH_BANKS > in cfi_flash.h. > > After this patch CONFIG_SYS_MAX_FLASH_BANKS should be never used in > the cfi code: use CFI_MAX_FLASH_BANKS for struct size or CFI_FLASH_BANKS > for number of CFI banks which can be dynamic. > > This patch modify all the files which include mtd/cfi_flash.h. > > Signed-off-by: Patrick Delaunay > Reviewed-by: Stefan Roese Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH v1 2/5] mtd: cfi: introduce CFI_FLASH_BANKS
On 1/4/22 14:23, Patrick Delaunay wrote: Replace CONFIG_SYS_MAX_FLASH_BANKS by CFI_FLASH_BANKS to prepare Kconfig migration and avoid to redefine CONFIG_SYS_MAX_FLASH_BANKS in cfi_flash.h. After this patch CONFIG_SYS_MAX_FLASH_BANKS should be never used in the cfi code: use CFI_MAX_FLASH_BANKS for struct size or CFI_FLASH_BANKS for number of CFI banks which can be dynamic. This patch modify all the files which include mtd/cfi_flash.h. Signed-off-by: Patrick Delaunay Reviewed-by: Stefan Roese Thanks, Stefan --- Changes in v1: - update drivers/mtd/spi/spi-nor-core.c for cfi_mtd_nb needed after RFC rebase cmd/bootm.c| 2 +- cmd/flash.c| 34 +- common/flash.c | 2 +- common/update.c| 4 ++-- drivers/mtd/cfi_flash.c| 4 ++-- drivers/mtd/cfi_mtd.c | 4 ++-- drivers/mtd/spi/spi-nor-core.c | 5 ++--- include/mtd/cfi_flash.h| 9 ++--- 8 files changed, 33 insertions(+), 31 deletions(-) diff --git a/cmd/bootm.c b/cmd/bootm.c index b82a872a86..e8b7066888 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -338,7 +338,7 @@ static int do_imls_nor(void) void *hdr; for (i = 0, info = _info[0]; - i < CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) { + i < CFI_FLASH_BANKS; ++i, ++info) { if (info->flash_id == FLASH_UNKNOWN) goto next_bank; diff --git a/cmd/flash.c b/cmd/flash.c index 594e2caa59..db4bb2529c 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -60,7 +60,7 @@ abbrev_spec(char *str, flash_info_t **pinfo, int *psf, int *psl) bank = dectoul(str, ); if (ep == str || *ep != '\0' || - bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) + bank < 1 || bank > CFI_FLASH_BANKS) return -1; fp = _info[bank - 1]; @@ -104,7 +104,7 @@ int flash_sect_roundb(ulong *addr) /* find the end addr of the sector where the *addr is */ found = 0; - for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS && !found; ++bank) { + for (bank = 0; bank < CFI_FLASH_BANKS && !found; ++bank) { info = _info[bank]; for (i = 0; i < info->sector_count && !found; ++i) { /* get the end address of the sector */ @@ -201,13 +201,13 @@ flash_fill_sect_ranges(ulong addr_first, ulong addr_last, *s_count = 0; - for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { + for (bank = 0; bank < CFI_FLASH_BANKS; ++bank) { s_first[bank] = -1; /* first sector to erase*/ s_last[bank] = -1; /* last sector to erase*/ } for (bank = 0, info = _info[0]; -(bank < CONFIG_SYS_MAX_FLASH_BANKS) && (addr_first <= addr_last); +(bank < CFI_FLASH_BANKS) && (addr_first <= addr_last); ++bank, ++info) { ulong b_end; int sect; @@ -278,7 +278,7 @@ static int do_flinfo(struct cmd_tbl *cmdtp, int flag, int argc, #ifdef CONFIG_MTD_NOR_FLASH if (argc == 1) {/* print info for all FLASH banks */ - for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { + for (bank = 0; bank < CFI_FLASH_BANKS; ++bank) { printf("\nBank # %ld: ", bank + 1); flash_print_info(_info[bank]); @@ -287,9 +287,9 @@ static int do_flinfo(struct cmd_tbl *cmdtp, int flag, int argc, } bank = hextoul(argv[1], NULL); - if (bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) { + if (bank < 1 || bank > CFI_FLASH_BANKS) { printf("Only FLASH Banks # 1 ... # %d supported\n", - CONFIG_SYS_MAX_FLASH_BANKS); + CFI_FLASH_BANKS); return 1; } printf("\nBank # %ld: ", bank); @@ -316,7 +316,7 @@ static int do_flerase(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; if (strcmp(argv[1], "all") == 0) { - for (bank = 1; bank <= CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { + for (bank = 1; bank <= CFI_FLASH_BANKS; ++bank) { printf("Erase Flash Bank # %ld ", bank); info = _info[bank - 1]; rcode = flash_erase(info, 0, info->sector_count - 1); @@ -366,9 +366,9 @@ static int do_flerase(struct cmd_tbl *cmdtp, int flag, int argc, if (strcmp(argv[1], "bank") == 0) { bank = hextoul(argv[2], NULL); - if (bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) { + if (bank < 1 || bank > CFI_FLASH_BANKS) { printf("Only FLASH Banks # 1 ... # %d supported\n", - CONFIG_SYS_MAX_FLASH_BANKS); + CFI_FLASH_BANKS); return 1; } printf("Erase Flash Bank
[PATCH v1 2/5] mtd: cfi: introduce CFI_FLASH_BANKS
Replace CONFIG_SYS_MAX_FLASH_BANKS by CFI_FLASH_BANKS to prepare Kconfig migration and avoid to redefine CONFIG_SYS_MAX_FLASH_BANKS in cfi_flash.h. After this patch CONFIG_SYS_MAX_FLASH_BANKS should be never used in the cfi code: use CFI_MAX_FLASH_BANKS for struct size or CFI_FLASH_BANKS for number of CFI banks which can be dynamic. This patch modify all the files which include mtd/cfi_flash.h. Signed-off-by: Patrick Delaunay --- Changes in v1: - update drivers/mtd/spi/spi-nor-core.c for cfi_mtd_nb needed after RFC rebase cmd/bootm.c| 2 +- cmd/flash.c| 34 +- common/flash.c | 2 +- common/update.c| 4 ++-- drivers/mtd/cfi_flash.c| 4 ++-- drivers/mtd/cfi_mtd.c | 4 ++-- drivers/mtd/spi/spi-nor-core.c | 5 ++--- include/mtd/cfi_flash.h| 9 ++--- 8 files changed, 33 insertions(+), 31 deletions(-) diff --git a/cmd/bootm.c b/cmd/bootm.c index b82a872a86..e8b7066888 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -338,7 +338,7 @@ static int do_imls_nor(void) void *hdr; for (i = 0, info = _info[0]; - i < CONFIG_SYS_MAX_FLASH_BANKS; ++i, ++info) { + i < CFI_FLASH_BANKS; ++i, ++info) { if (info->flash_id == FLASH_UNKNOWN) goto next_bank; diff --git a/cmd/flash.c b/cmd/flash.c index 594e2caa59..db4bb2529c 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -60,7 +60,7 @@ abbrev_spec(char *str, flash_info_t **pinfo, int *psf, int *psl) bank = dectoul(str, ); if (ep == str || *ep != '\0' || - bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) + bank < 1 || bank > CFI_FLASH_BANKS) return -1; fp = _info[bank - 1]; @@ -104,7 +104,7 @@ int flash_sect_roundb(ulong *addr) /* find the end addr of the sector where the *addr is */ found = 0; - for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS && !found; ++bank) { + for (bank = 0; bank < CFI_FLASH_BANKS && !found; ++bank) { info = _info[bank]; for (i = 0; i < info->sector_count && !found; ++i) { /* get the end address of the sector */ @@ -201,13 +201,13 @@ flash_fill_sect_ranges(ulong addr_first, ulong addr_last, *s_count = 0; - for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { + for (bank = 0; bank < CFI_FLASH_BANKS; ++bank) { s_first[bank] = -1; /* first sector to erase*/ s_last[bank] = -1; /* last sector to erase*/ } for (bank = 0, info = _info[0]; -(bank < CONFIG_SYS_MAX_FLASH_BANKS) && (addr_first <= addr_last); +(bank < CFI_FLASH_BANKS) && (addr_first <= addr_last); ++bank, ++info) { ulong b_end; int sect; @@ -278,7 +278,7 @@ static int do_flinfo(struct cmd_tbl *cmdtp, int flag, int argc, #ifdef CONFIG_MTD_NOR_FLASH if (argc == 1) {/* print info for all FLASH banks */ - for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { + for (bank = 0; bank < CFI_FLASH_BANKS; ++bank) { printf("\nBank # %ld: ", bank + 1); flash_print_info(_info[bank]); @@ -287,9 +287,9 @@ static int do_flinfo(struct cmd_tbl *cmdtp, int flag, int argc, } bank = hextoul(argv[1], NULL); - if (bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) { + if (bank < 1 || bank > CFI_FLASH_BANKS) { printf("Only FLASH Banks # 1 ... # %d supported\n", - CONFIG_SYS_MAX_FLASH_BANKS); + CFI_FLASH_BANKS); return 1; } printf("\nBank # %ld: ", bank); @@ -316,7 +316,7 @@ static int do_flerase(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; if (strcmp(argv[1], "all") == 0) { - for (bank = 1; bank <= CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { + for (bank = 1; bank <= CFI_FLASH_BANKS; ++bank) { printf("Erase Flash Bank # %ld ", bank); info = _info[bank - 1]; rcode = flash_erase(info, 0, info->sector_count - 1); @@ -366,9 +366,9 @@ static int do_flerase(struct cmd_tbl *cmdtp, int flag, int argc, if (strcmp(argv[1], "bank") == 0) { bank = hextoul(argv[2], NULL); - if (bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) { + if (bank < 1 || bank > CFI_FLASH_BANKS) { printf("Only FLASH Banks # 1 ... # %d supported\n", - CONFIG_SYS_MAX_FLASH_BANKS); + CFI_FLASH_BANKS); return 1; } printf("Erase Flash Bank # %ld ", bank); @@ -397,7 +397,7 @@ int