[U-Boot] [PATCH v4 00/17] nand: remove direct acces to nand_info array

This is a preparation required for adding Nand DM support. This series introduces new API get_nand_dev_by_index() to avoid direct acces to nand_info array and updates u-boot to use it. As result, nand_info array is made static in the last patch.
Changes in v4: - rebased on top of git://git.denx.de/u-boot.git/master - added patch for arch/arm/cpu/armv8/fsl-layerscape/ppa.c - added "Reviewed-by" tags
Changes in v3: - preparation patches separated from original series. - fixed BeagleBoard-xM boot failure which has Nand enabled, but no Nand devices are presented on board physically. - all current direct users were converted to use get_nand_dev_by_index() and nand_info array was made static finally.
link on v3: - https://www.mail-archive.com/u-boot@lists.denx.de/msg238797.html link on v2: - https://www.mail-archive.com/u-boot@lists.denx.de/msg237747.html
Grygorii Strashko (17): common: env_nand: use get_nand_dev_by_index() dfu: dfu_nand: use get_nand_dev_by_index() cmd: bootm: use get_nand_dev_by_index() cmd: jffs2: use get_nand_dev_by_index() common: use get_nand_dev_by_index() fs: use get_nand_dev_by_index() cmd: nand: remove direct access to struct mtd_info->priv net: phy: cortina: use get_nand_dev_by_index() net: fm: use get_nand_dev_by_index() mtd: nand: drv: use get_nand_dev_by_index() cmd: mvebu: bubt: use get_nand_dev_by_index() board: atmel: use get_nand_dev_by_index() board: ronetix: use get_nand_dev_by_index() board: BuR: use get_nand_dev_by_index() board: toradex: use get_nand_dev_by_index() armv8: fsl-layerscape: use get_nand_dev_by_index() mtd: nand: make nand_info array static
Mugunthan V N (1): cmd: nand: abstract global variable usage for dm conversion
arch/arm/cpu/armv8/fsl-layerscape/ppa.c | 15 +++--- board/BuR/common/common.c | 3 +- board/atmel/at91sam9261ek/at91sam9261ek.c | 2 +- board/atmel/at91sam9263ek/at91sam9263ek.c | 2 +- board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 2 +- board/atmel/at91sam9n12ek/at91sam9n12ek.c | 2 +- board/atmel/at91sam9rlek/at91sam9rlek.c | 2 +- board/atmel/at91sam9x5ek/at91sam9x5ek.c | 2 +- board/atmel/sama5d3xek/sama5d3xek.c | 2 +- board/atmel/sama5d4_xplained/sama5d4_xplained.c | 2 +- board/atmel/sama5d4ek/sama5d4ek.c | 2 +- board/ronetix/pm9261/pm9261.c | 2 +- board/ronetix/pm9263/pm9263.c | 2 +- board/toradex/colibri_t20/colibri_t20.c | 2 +- board/toradex/common/tdx-cfg-block.c | 12 +++-- cmd/bootm.c | 2 +- cmd/jffs2.c | 7 +-- cmd/mvebu/bubt.c | 14 +++-- cmd/nand.c | 69 ++++++++++++++----------- common/env_nand.c | 33 +++++++----- common/fb_nand.c | 2 +- common/splash_source.c | 5 +- drivers/dfu/dfu_nand.c | 12 ++--- drivers/mtd/nand/fsmc_nand.c | 2 +- drivers/mtd/nand/nand.c | 23 ++++++--- drivers/mtd/nand/omap_gpmc.c | 7 +-- drivers/mtd/nand/zynq_nand.c | 2 +- drivers/net/fm/fm.c | 3 +- drivers/net/phy/cortina.c | 3 +- fs/jffs2/jffs2_1pass.c | 9 +++- fs/jffs2/jffs2_nand_1pass.c | 6 ++- fs/yaffs2/yaffs_uboot_glue.c | 8 ++- include/nand.h | 10 +++- 33 files changed, 162 insertions(+), 109 deletions(-)

From: Mugunthan V N mugunthanvnm@ti.com
nand_info is used all over the file so abstract it with get_nand_dev_by_index() which will help for DM conversion.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- cmd/nand.c | 69 +++++++++++++++++++++++++------------------- drivers/mtd/nand/nand.c | 21 ++++++++++---- drivers/mtd/nand/omap_gpmc.c | 7 ++--- include/nand.h | 9 ++++++ 4 files changed, 65 insertions(+), 41 deletions(-)
diff --git a/cmd/nand.c b/cmd/nand.c index c16ec77..f2b440e 100644 --- a/cmd/nand.c +++ b/cmd/nand.c @@ -115,20 +115,20 @@ free_dat:
static int set_dev(int dev) { - if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[dev]) { - puts("No such device\n"); - return -1; - } + struct mtd_info *mtd = get_nand_dev_by_index(dev); + + if (!mtd) + return -ENODEV;
if (nand_curr_device == dev) return 0;
- printf("Device %d: %s", dev, nand_info[dev]->name); + printf("Device %d: %s", dev, mtd->name); puts("... is now current device\n"); nand_curr_device = dev;
#ifdef CONFIG_SYS_NAND_SELECT_DEVICE - board_nand_select_device(nand_info[dev]->priv, dev); + board_nand_select_device(mtd->priv, dev); #endif
return 0; @@ -188,7 +188,7 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[]) { int ret; uint32_t oob_buf[ENV_OFFSET_SIZE/sizeof(uint32_t)]; - struct mtd_info *mtd = nand_info[0]; + struct mtd_info *mtd = get_nand_dev_by_index(0); char *cmd = argv[1];
if (CONFIG_SYS_MAX_NAND_DEVICE == 0 || !mtd) { @@ -213,9 +213,10 @@ int do_nand_env_oob(cmd_tbl_t *cmdtp, int argc, char *const argv[]) if (argc < 3) goto usage;
+ mtd = get_nand_dev_by_index(idx); /* We don't care about size, or maxsize. */ if (mtd_arg_off(argv[2], &idx, &addr, &maxsize, &maxsize, - MTD_DEV_TYPE_NAND, nand_info[idx]->size)) { + MTD_DEV_TYPE_NAND, mtd->size)) { puts("Offset or partition name expected\n"); return 1; } @@ -283,9 +284,14 @@ usage:
static void nand_print_and_set_info(int idx) { - struct mtd_info *mtd = nand_info[idx]; - struct nand_chip *chip = mtd_to_nand(mtd); + struct mtd_info *mtd; + struct nand_chip *chip; + + mtd = get_nand_dev_by_index(idx); + if (!mtd) + return;
+ chip = mtd_to_nand(mtd); printf("Device %d: ", idx); if (chip->numchips > 1) printf("%dx ", chip->numchips); @@ -348,7 +354,7 @@ static void adjust_size_for_badblocks(loff_t *size, loff_t offset, int dev) /* We grab the nand info object here fresh because this is usually * called after arg_off_size() which can change the value of dev. */ - struct mtd_info *mtd = nand_info[dev]; + struct mtd_info *mtd = get_nand_dev_by_index(dev); loff_t maxoffset = offset + *size; int badblocks = 0;
@@ -397,10 +403,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (strcmp(cmd, "info") == 0) {
putc('\n'); - for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { - if (nand_info[i]) - nand_print_and_set_info(i); - } + for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) + nand_print_and_set_info(i); return 0; }
@@ -432,12 +436,11 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * one before these commands can run, even if a partition specifier * for another device is to be used. */ - if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[dev]) { + mtd = get_nand_dev_by_index(dev); + if (!mtd) { puts("\nno devices available\n"); return 1; } - mtd = nand_info[dev];
if (strcmp(cmd, "bad") == 0) { printf("\nDevice %d bad blocks:\n", dev); @@ -496,13 +499,13 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* skip first two or three arguments, look for offset and size */ if (mtd_arg_off_size(argc - o, argv + o, &dev, &off, &size, &maxsize, MTD_DEV_TYPE_NAND, - nand_info[dev]->size) != 0) + mtd->size) != 0) return 1;
if (set_dev(dev)) return 1;
- mtd = nand_info[dev]; + mtd = get_nand_dev_by_index(dev);
memset(&opts, 0, sizeof(opts)); opts.offset = off; @@ -565,13 +568,13 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (mtd_arg_off(argv[3], &dev, &off, &size, &maxsize, MTD_DEV_TYPE_NAND, - nand_info[dev]->size)) + mtd->size)) return 1;
if (set_dev(dev)) return 1;
- mtd = nand_info[dev]; + mtd = get_nand_dev_by_index(dev);
if (argc > 4 && !str2long(argv[4], &pagecount)) { printf("'%s' is not a number\n", argv[4]); @@ -588,7 +591,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (mtd_arg_off_size(argc - 3, argv + 3, &dev, &off, &size, &maxsize, MTD_DEV_TYPE_NAND, - nand_info[dev]->size) != 0) + mtd->size) != 0) return 1;
if (set_dev(dev)) @@ -600,7 +603,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) rwsize = size; }
- mtd = nand_info[dev]; + mtd = get_nand_dev_by_index(dev);
if (!s || !strcmp(s, ".jffs2") || !strcmp(s, ".e") || !strcmp(s, ".i")) { @@ -760,13 +763,15 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (mtd_arg_off_size(argc - 2, argv + 2, &dev, &off, &size, &maxsize, MTD_DEV_TYPE_NAND, - nand_info[dev]->size) < 0) + mtd->size) < 0) return 1;
if (set_dev(dev)) return 1;
- if (!nand_unlock(nand_info[dev], off, size, allexcept)) { + mtd = get_nand_dev_by_index(dev); + + if (!nand_unlock(mtd, off, size, allexcept)) { puts("NAND flash successfully unlocked\n"); } else { puts("Error unlocking NAND flash, " @@ -929,6 +934,7 @@ static int do_nandboot(cmd_tbl_t *cmdtp, int flag, int argc, char *boot_device = NULL; int idx; ulong addr, offset = 0; + struct mtd_info *mtd; #if defined(CONFIG_CMD_MTDPARTS) struct mtd_device *dev; struct part_info *part; @@ -948,8 +954,10 @@ static int do_nandboot(cmd_tbl_t *cmdtp, int flag, int argc, addr = simple_strtoul(argv[1], NULL, 16); else addr = CONFIG_SYS_LOAD_ADDR; - return nand_load_image(cmdtp, nand_info[dev->id->num], - part->offset, addr, argv[0]); + + mtd = get_nand_dev_by_index(dev->id->num); + return nand_load_image(cmdtp, mtd, part->offset, + addr, argv[0]); } } #endif @@ -991,14 +999,15 @@ usage:
idx = simple_strtoul(boot_device, NULL, 16);
- if (idx < 0 || idx >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[idx]) { + mtd = get_nand_dev_by_index(idx); + if (!mtd) { printf("\n** Device %d not available\n", idx); bootstage_error(BOOTSTAGE_ID_NAND_AVAILABLE); return 1; } bootstage_mark(BOOTSTAGE_ID_NAND_AVAILABLE);
- return nand_load_image(cmdtp, nand_info[idx], offset, addr, argv[0]); + return nand_load_image(cmdtp, mtd, offset, addr, argv[0]); }
U_BOOT_CMD(nboot, 4, 1, do_nandboot, diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index 168bac6..fd9a3be 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -19,7 +19,6 @@ DECLARE_GLOBAL_DATA_PTR;
int nand_curr_device = -1;
- struct mtd_info *nand_info[CONFIG_SYS_MAX_NAND_DEVICE];
#ifndef CONFIG_SYS_NAND_SELF_INIT @@ -31,12 +30,21 @@ static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];
static unsigned long total_nand_size; /* in kiB */
+struct mtd_info *get_nand_dev_by_index(int dev) +{ + if (dev < 0 || dev >= CONFIG_SYS_MAX_NAND_DEVICE || !nand_info[dev] || + !nand_info[dev]->name) + return NULL; + + return nand_info[dev]; +} + int nand_mtd_to_devnum(struct mtd_info *mtd) { int i;
- for (i = 0; i < ARRAY_SIZE(nand_info); i++) { - if (mtd && nand_info[i] == mtd) + for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { + if (mtd && get_nand_dev_by_index(i) == mtd) return i; }
@@ -101,8 +109,9 @@ static void create_mtd_concat(void) int i;
for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) { - if (nand_info[i] != NULL) { - nand_info_list[nand_devices_found] = nand_info[i]; + struct mtd_info *mtd = get_nand_dev_by_index(i); + if (mtd != NULL) { + nand_info_list[nand_devices_found] = mtd; nand_devices_found++; } } @@ -161,7 +170,7 @@ void nand_init(void) /* * Select the chip in the board/cpu specific driver */ - board_nand_select_device(mtd_to_nand(nand_info[nand_curr_device]), + board_nand_select_device(mtd_to_nand(get_nand_dev_by_index(nand_curr_device)), nand_curr_device); #endif
diff --git a/drivers/mtd/nand/omap_gpmc.c b/drivers/mtd/nand/omap_gpmc.c index f4f0de3..b540bc3 100644 --- a/drivers/mtd/nand/omap_gpmc.c +++ b/drivers/mtd/nand/omap_gpmc.c @@ -894,17 +894,14 @@ static int omap_select_ecc_scheme(struct nand_chip *nand, int __maybe_unused omap_nand_switch_ecc(uint32_t hardware, uint32_t eccstrength) { struct nand_chip *nand; - struct mtd_info *mtd; + struct mtd_info *mtd = get_nand_dev_by_index(nand_curr_device); int err = 0;
- if (nand_curr_device < 0 || - nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device]) { + if (!mtd) { printf("nand: error: no NAND devices found\n"); return -ENODEV; }
- mtd = nand_info[nand_curr_device]; nand = mtd_to_nand(mtd); nand->options |= NAND_OWN_BUFFERS; nand->options &= ~NAND_SUBPAGE_READ; diff --git a/include/nand.h b/include/nand.h index bc5dd81..c8556e1 100644 --- a/include/nand.h +++ b/include/nand.h @@ -145,4 +145,13 @@ int spl_nand_erase_one(int block, int page); /* platform specific init functions */ void sunxi_nand_init(void);
+/* + * get_nand_dev_by_index - Get the nand info based in index. + * + * @dev - index to the nand device. + * + * returns pointer to the nand device info structure or NULL on failure. + */ +struct mtd_info *get_nand_dev_by_index(int dev); + #endif /* _NAND_H_ */

Hi,
On 26 June 2017 at 18:12, Grygorii Strashko grygorii.strashko@ti.com wrote:
From: Mugunthan V N mugunthanvnm@ti.com
nand_info is used all over the file so abstract it with get_nand_dev_by_index() which will help for DM conversion.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
cmd/nand.c | 69 +++++++++++++++++++++++++------------------- drivers/mtd/nand/nand.c | 21 ++++++++++---- drivers/mtd/nand/omap_gpmc.c | 7 ++--- include/nand.h | 9 ++++++ 4 files changed, 65 insertions(+), 41 deletions(-)
Is there a cover letter for this series please? I'm not sure what it does overall, or what your approach is.
Regards, Simon

On 07/06/2017 10:58 PM, Simon Glass wrote:
Hi,
On 26 June 2017 at 18:12, Grygorii Strashko grygorii.strashko@ti.com wrote:
From: Mugunthan V N mugunthanvnm@ti.com
nand_info is used all over the file so abstract it with get_nand_dev_by_index() which will help for DM conversion.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
cmd/nand.c | 69 +++++++++++++++++++++++++------------------- drivers/mtd/nand/nand.c | 21 ++++++++++---- drivers/mtd/nand/omap_gpmc.c | 7 ++--- include/nand.h | 9 ++++++ 4 files changed, 65 insertions(+), 41 deletions(-)
Is there a cover letter for this series please? I'm not sure what it does overall, or what your approach is.
It should be and you are in cc, here is the link for your reference: https://www.mail-archive.com/u-boot@lists.denx.de/msg254409.html

Hi,
On 7 July 2017 at 18:32, Grygorii Strashko grygorii.strashko@ti.com wrote:
On 07/06/2017 10:58 PM, Simon Glass wrote:
Hi,
On 26 June 2017 at 18:12, Grygorii Strashko grygorii.strashko@ti.com wrote:
From: Mugunthan V N mugunthanvnm@ti.com
nand_info is used all over the file so abstract it with get_nand_dev_by_index() which will help for DM conversion.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
cmd/nand.c | 69 +++++++++++++++++++++++++------------------- drivers/mtd/nand/nand.c | 21 ++++++++++---- drivers/mtd/nand/omap_gpmc.c | 7 ++--- include/nand.h | 9 ++++++ 4 files changed, 65 insertions(+), 41 deletions(-)
Is there a cover letter for this series please? I'm not sure what it does overall, or what your approach is.
It should be and you are in cc, here is the link for your reference: https://www.mail-archive.com/u-boot@lists.denx.de/msg254409.html
OK, thank you. In a future series do you plan to remove nand_info[] ?
Regards, Simon

On 07/08/2017 11:08 AM, Simon Glass wrote:
Hi,
On 7 July 2017 at 18:32, Grygorii Strashko grygorii.strashko@ti.com wrote:
On 07/06/2017 10:58 PM, Simon Glass wrote:
Hi,
On 26 June 2017 at 18:12, Grygorii Strashko grygorii.strashko@ti.com wrote:
From: Mugunthan V N mugunthanvnm@ti.com
nand_info is used all over the file so abstract it with get_nand_dev_by_index() which will help for DM conversion.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
cmd/nand.c | 69 +++++++++++++++++++++++++------------------- drivers/mtd/nand/nand.c | 21 ++++++++++---- drivers/mtd/nand/omap_gpmc.c | 7 ++--- include/nand.h | 9 ++++++ 4 files changed, 65 insertions(+), 41 deletions(-)
Is there a cover letter for this series please? I'm not sure what it does overall, or what your approach is.
It should be and you are in cc, here is the link for your reference: https://www.mail-archive.com/u-boot@lists.denx.de/msg254409.html
OK, thank you. In a future series do you plan to remove nand_info[] ?
Its usage expected to be limited to non-DM case only - after full conversation of all platforms to DM it can be removed.
Ref: - last: https://patchwork.ozlabs.org/patch/722282/ - old: https://patchwork.ozlabs.org/patch/604739/

On Mon, Jun 26, 2017 at 07:12:51PM -0500, Grygorii Strashko wrote:
From: Mugunthan V N mugunthanvnm@ti.com
nand_info is used all over the file so abstract it with get_nand_dev_by_index() which will help for DM conversion.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- common/env_nand.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/common/env_nand.c b/common/env_nand.c index 2e28171..133ecfb 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -130,17 +130,22 @@ static int writeenv(size_t offset, u_char *buf) size_t end = offset + CONFIG_ENV_RANGE; size_t amount_saved = 0; size_t blocksize, len; + struct mtd_info *mtd; u_char *char_ptr;
- blocksize = nand_info[0]->erasesize; + mtd = get_nand_dev_by_index(0); + if (!mtd) + return 1; + + blocksize = mtd->erasesize; len = min(blocksize, (size_t)CONFIG_ENV_SIZE);
while (amount_saved < CONFIG_ENV_SIZE && offset < end) { - if (nand_block_isbad(nand_info[0], offset)) { + if (nand_block_isbad(mtd, offset)) { offset += blocksize; } else { char_ptr = &buf[amount_saved]; - if (nand_write(nand_info[0], offset, &len, char_ptr)) + if (nand_write(mtd, offset, &len, char_ptr)) return 1;
offset += blocksize; @@ -161,13 +166,15 @@ struct env_location { static int erase_and_write_env(const struct env_location *location, u_char *env_new) { + struct mtd_info *mtd; int ret = 0;
- if (!nand_info[0]) + mtd = get_nand_dev_by_index(0); + if (!mtd) return 1;
printf("Erasing %s...\n", location->name); - if (nand_erase_opts(nand_info[0], &location->erase_opts)) + if (nand_erase_opts(mtd, &location->erase_opts)) return 1;
printf("Writing to %s... ", location->name); @@ -248,22 +255,24 @@ static int readenv(size_t offset, u_char *buf) size_t end = offset + CONFIG_ENV_RANGE; size_t amount_loaded = 0; size_t blocksize, len; + struct mtd_info *mtd; u_char *char_ptr;
- if (!nand_info[0]) + mtd = get_nand_dev_by_index(0); + if (!mtd) return 1;
- blocksize = nand_info[0]->erasesize; + blocksize = mtd->erasesize; len = min(blocksize, (size_t)CONFIG_ENV_SIZE);
while (amount_loaded < CONFIG_ENV_SIZE && offset < end) { - if (nand_block_isbad(nand_info[0], offset)) { + if (nand_block_isbad(mtd, offset)) { offset += blocksize; } else { char_ptr = &buf[amount_loaded]; - if (nand_read_skip_bad(nand_info[0], offset, + if (nand_read_skip_bad(mtd, offset, &len, NULL, - nand_info[0]->size, char_ptr)) + mtd->size, char_ptr)) return 1;
offset += blocksize; @@ -390,12 +399,12 @@ void env_relocate_spec(void) ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
#if defined(CONFIG_ENV_OFFSET_OOB) + struct mtd_info *mtd = get_nand_dev_by_index(0); /* * If unable to read environment offset from NAND OOB then fall through * to the normal environment reading code below */ - if (nand_info[0] && !get_nand_env_oob(nand_info[0], - &nand_env_oob_offset)) { + if (mtd && !get_nand_env_oob(mtd, &nand_env_oob_offset)) { printf("Found Environment offset in OOB..\n"); } else { set_default_env("!no env offset in OOB");

On Mon, Jun 26, 2017 at 07:12:52PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- drivers/dfu/dfu_nand.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c index 23f1571..97cd608 100644 --- a/drivers/dfu/dfu_nand.c +++ b/drivers/dfu/dfu_nand.c @@ -37,15 +37,15 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu, lim = dfu->data.nand.start + dfu->data.nand.size - start; count = *len;
+ mtd = get_nand_dev_by_index(nand_curr_device); + if (nand_curr_device < 0 || nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device]) { + !mtd) { printf("%s: invalid nand device\n", __func__); return -1; }
- mtd = nand_info[nand_curr_device]; - if (op == DFU_OP_READ) { ret = nand_read_skip_bad(mtd, start, &count, &actual, lim, buf); @@ -143,18 +143,16 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)
/* in case of ubi partition, erase rest of the partition */ if (dfu->data.nand.ubi) { - struct mtd_info *mtd; + struct mtd_info *mtd = get_nand_dev_by_index(nand_curr_device); nand_erase_options_t opts;
if (nand_curr_device < 0 || nand_curr_device >= CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device]) { + !mtd) { printf("%s: invalid nand device\n", __func__); return -1; }
- mtd = nand_info[nand_curr_device]; - memset(&opts, 0, sizeof(opts)); off = dfu->offset; if ((off & (mtd->erasesize - 1)) != 0) {

On Mon, Jun 26, 2017 at 07:12:53PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- cmd/bootm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/bootm.c b/cmd/bootm.c index 953a57d..daf15d9 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -465,7 +465,7 @@ static int do_imls_nand(void) printf("\n");
for (nand_dev = 0; nand_dev < CONFIG_SYS_MAX_NAND_DEVICE; nand_dev++) { - mtd = nand_info[nand_dev]; + mtd = get_nand_dev_by_index(nand_dev); if (!mtd->name || !mtd->size) continue;

On Mon, Jun 26, 2017 at 07:12:54PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- cmd/jffs2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/cmd/jffs2.c b/cmd/jffs2.c index 9be198e..dc94705 100644 --- a/cmd/jffs2.c +++ b/cmd/jffs2.c @@ -166,8 +166,9 @@ static int mtd_device_validate(u8 type, u8 num, u32 *size) #endif } else if (type == MTD_DEV_TYPE_NAND) { #if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND) - if (num < CONFIG_SYS_MAX_NAND_DEVICE) { - *size = nand_info[num]->size; + struct mtd_info *mtd = get_nand_dev_by_index(num); + if (mtd) { + *size = mtd->size; return 0; }
@@ -244,7 +245,7 @@ static inline u32 get_part_sector_size_nand(struct mtdids *id) #if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND) struct mtd_info *mtd;
- mtd = nand_info[id->num]; + mtd = get_nand_dev_by_index(id->num);
return mtd->erasesize; #else

On Mon, Jun 26, 2017 at 07:12:55PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- common/fb_nand.c | 2 +- common/splash_source.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/common/fb_nand.c b/common/fb_nand.c index c8c79e9..3d027d4 100644 --- a/common/fb_nand.c +++ b/common/fb_nand.c @@ -59,7 +59,7 @@ static int fb_nand_lookup(const char *partname, return -EINVAL; }
- *mtd = nand_info[dev->id->num]; + *mtd = get_nand_dev_by_index(dev->id->num);
return 0; } diff --git a/common/splash_source.c b/common/splash_source.c index d1647c8..476fd2f 100644 --- a/common/splash_source.c +++ b/common/splash_source.c @@ -47,9 +47,10 @@ static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size) #ifdef CONFIG_CMD_NAND static int splash_nand_read_raw(u32 bmp_load_addr, int offset, size_t read_size) { - return nand_read_skip_bad(nand_info[nand_curr_device], offset, + struct mtd_info *mtd = get_nand_dev_by_index(nand_curr_device); + return nand_read_skip_bad(mtd, offset, &read_size, NULL, - nand_info[nand_curr_device]->size, + mtd->size, (u_char *)bmp_load_addr); } #else

On Mon, Jun 26, 2017 at 07:12:56PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- fs/jffs2/jffs2_1pass.c | 9 +++++++-- fs/jffs2/jffs2_nand_1pass.c | 6 +++++- fs/yaffs2/yaffs_uboot_glue.c | 8 ++++++-- 3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index ed60c5b..4c6dfbf 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -175,10 +175,15 @@ static u32 nand_cache_off = (u32)-1; static int read_nand_cached(u32 off, u32 size, u_char *buf) { struct mtdids *id = current_part->dev->id; + struct mtd_info *mtd; u32 bytes_read = 0; size_t retlen; int cpy_bytes;
+ mtd = get_nand_dev_by_index(id->num); + if (!mtd) + return -1; + while (bytes_read < size) { if ((off + bytes_read < nand_cache_off) || (off + bytes_read >= nand_cache_off+NAND_CACHE_SIZE)) { @@ -195,8 +200,8 @@ static int read_nand_cached(u32 off, u32 size, u_char *buf) }
retlen = NAND_CACHE_SIZE; - if (nand_read(nand_info[id->num], nand_cache_off, - &retlen, nand_cache) != 0 || + if (nand_read(mtd, nand_cache_off, + &retlen, nand_cache) != 0 || retlen != NAND_CACHE_SIZE) { printf("read_nand_cached: error reading nand off %#x size %d bytes\n", nand_cache_off, NAND_CACHE_SIZE); diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c index d94c48f..1d63fc9 100644 --- a/fs/jffs2/jffs2_nand_1pass.c +++ b/fs/jffs2/jffs2_nand_1pass.c @@ -796,7 +796,11 @@ jffs2_1pass_build_lists(struct part_info * part) u32 counterN = 0;
struct mtdids *id = part->dev->id; - mtd = nand_info[id->num]; + mtd = get_nand_dev_by_index(id->num); + if (!mtd) { + error("\nno NAND devices available\n"); + return 0; + }
/* if we are building a list we need to refresh the cache. */ jffs_init_1pass_list(part); diff --git a/fs/yaffs2/yaffs_uboot_glue.c b/fs/yaffs2/yaffs_uboot_glue.c index f663081..bd66d31 100644 --- a/fs/yaffs2/yaffs_uboot_glue.c +++ b/fs/yaffs2/yaffs_uboot_glue.c @@ -166,11 +166,15 @@ void cmd_yaffs_devconfig(char *_mp, int flash_dev, char *mp = NULL; struct nand_chip *chip;
+ mtd = get_nand_dev_by_index(flash_dev); + if (!mtd) { + error("\nno NAND devices available\n"); + return; + } + dev = calloc(1, sizeof(*dev)); mp = strdup(_mp);
- mtd = nand_info[flash_dev]; - if (!dev || !mp) { /* Alloc error */ printf("Failed to allocate memory\n");

On Mon, Jun 26, 2017 at 07:12:57PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

Replace direct access to struct mtd_info->priv with proper accessor mtd_to_nand().
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- cmd/nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/nand.c b/cmd/nand.c index f2b440e..d9de978 100644 --- a/cmd/nand.c +++ b/cmd/nand.c @@ -128,7 +128,7 @@ static int set_dev(int dev) nand_curr_device = dev;
#ifdef CONFIG_SYS_NAND_SELECT_DEVICE - board_nand_select_device(mtd->priv, dev); + board_nand_select_device(mtd_to_nand(mtd), dev); #endif
return 0;

On Mon, Jun 26, 2017 at 07:12:58PM -0500, Grygorii Strashko wrote:
Replace direct access to struct mtd_info->priv with proper accessor mtd_to_nand().
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com Reviewed-by: Joe Hershberger joe.hershberger@ni.com --- drivers/net/phy/cortina.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/cortina.c b/drivers/net/phy/cortina.c index fd130d5..e0e9ed9 100644 --- a/drivers/net/phy/cortina.c +++ b/drivers/net/phy/cortina.c @@ -139,7 +139,8 @@ void cs4340_upload_firmware(struct phy_device *phydev) size_t fw_length = CONFIG_CORTINA_FW_LENGTH;
addr = malloc(CONFIG_CORTINA_FW_LENGTH); - ret = nand_read(nand_info[0], (loff_t)CONFIG_CORTINA_FW_ADDR, + ret = nand_read(get_nand_dev_by_index(0), + (loff_t)CONFIG_CORTINA_FW_ADDR, &fw_length, (u_char *)addr); if (ret == -EUCLEAN) { printf("NAND read of Cortina firmware at 0x%x failed %d\n",

On Mon, Jun 26, 2017 at 07:12:59PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com Reviewed-by: Joe Hershberger joe.hershberger@ni.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com Reviewed-by: Joe Hershberger joe.hershberger@ni.com --- drivers/net/fm/fm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index 89f0d6a..9fe34ad 100644 --- a/drivers/net/fm/fm.c +++ b/drivers/net/fm/fm.c @@ -357,7 +357,8 @@ int fm_init_common(int index, struct ccsr_fman *reg) size_t fw_length = CONFIG_SYS_QE_FMAN_FW_LENGTH; void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
- rc = nand_read(nand_info[0], (loff_t)CONFIG_SYS_FMAN_FW_ADDR, + rc = nand_read(get_nand_dev_by_index(0), + (loff_t)CONFIG_SYS_FMAN_FW_ADDR, &fw_length, (u_char *)addr); if (rc == -EUCLEAN) { printf("NAND read of FMAN firmware at offset 0x%x failed %d\n",

On Mon, Jun 26, 2017 at 07:13:00PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com Reviewed-by: Joe Hershberger joe.hershberger@ni.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- drivers/mtd/nand/fsmc_nand.c | 2 +- drivers/mtd/nand/zynq_nand.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index a1f2cba..d5d1056 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c @@ -409,7 +409,7 @@ int fsmc_nand_switch_ecc(uint32_t eccstrength) * Nomadik SoC is currently supporting this fsmc_nand_switch_ecc() * function, as it doesn't need to switch to a different ECC layout. */ - mtd = nand_info[nand_curr_device]; + mtd = get_nand_dev_by_index(nand_curr_device); nand = mtd_to_nand(mtd);
/* Setup the ecc configurations again */ diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c index cb3340d..948f059 100644 --- a/drivers/mtd/nand/zynq_nand.c +++ b/drivers/mtd/nand/zynq_nand.c @@ -1008,7 +1008,7 @@ static int zynq_nand_init(struct nand_chip *nand_chip, int devnum) }
xnand->nand_base = (void __iomem *)ZYNQ_NAND_BASEADDR; - mtd = (struct mtd_info *)&nand_info[0]; + mtd = get_nand_dev_by_index(0);
nand_chip->priv = xnand; mtd->priv = nand_chip;

On Mon, Jun 26, 2017 at 07:13:01PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- cmd/mvebu/bubt.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index 1e1f0af..ea46e7b 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -311,23 +311,21 @@ static int nand_burn_image(size_t image_size) { int ret; uint32_t block_size; - struct mtd_info *nand; - int dev = nand_curr_device; + struct mtd_info *mtd;
- if ((dev < 0) || (dev >= CONFIG_SYS_MAX_NAND_DEVICE) || - (!nand_info[dev]->name)) { + mtd = get_nand_dev_by_index(nand_curr_device); + if (!mtd) { puts("\nno devices available\n"); return -ENOMEDIUM; } - nand = nand_info[dev]; - block_size = nand->erasesize; + block_size = mtd->erasesize;
/* Align U-Boot size to currently used blocksize */ image_size = ((image_size + (block_size - 1)) & (~(block_size - 1)));
/* Erase the U-BOOT image space */ printf("Erasing 0x%x - 0x%x:...", 0, (int)image_size); - ret = nand_erase(nand, 0, image_size); + ret = nand_erase(mtd, 0, image_size); if (ret) { printf("Error!\n"); goto error; @@ -337,7 +335,7 @@ static int nand_burn_image(size_t image_size) /* Write the image to flash */ printf("Writing %d bytes from 0x%lx to offset 0 ... ", (int)image_size, get_load_addr()); - ret = nand_write(nand, 0, &image_size, (void *)get_load_addr()); + ret = nand_write(mtd, 0, &image_size, (void *)get_load_addr()); if (ret) printf("Error!\n"); else

On Mon, Jun 26, 2017 at 07:13:02PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- board/atmel/at91sam9261ek/at91sam9261ek.c | 2 +- board/atmel/at91sam9263ek/at91sam9263ek.c | 2 +- board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 2 +- board/atmel/at91sam9n12ek/at91sam9n12ek.c | 2 +- board/atmel/at91sam9rlek/at91sam9rlek.c | 2 +- board/atmel/at91sam9x5ek/at91sam9x5ek.c | 2 +- board/atmel/sama5d3xek/sama5d3xek.c | 2 +- board/atmel/sama5d4_xplained/sama5d4_xplained.c | 2 +- board/atmel/sama5d4ek/sama5d4ek.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c index b4acb74..1ba6063 100644 --- a/board/atmel/at91sam9261ek/at91sam9261ek.c +++ b/board/atmel/at91sam9261ek/at91sam9261ek.c @@ -213,7 +213,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size = 0; for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; lcd_printf (" %ld MB SDRAM, %ld MB NAND\n", dram_size >> 20, nand_size >> 20 ); diff --git a/board/atmel/at91sam9263ek/at91sam9263ek.c b/board/atmel/at91sam9263ek/at91sam9263ek.c index b37e9d3..9fa6893 100644 --- a/board/atmel/at91sam9263ek/at91sam9263ek.c +++ b/board/atmel/at91sam9263ek/at91sam9263ek.c @@ -160,7 +160,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size = 0; for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; #ifdef CONFIG_MTD_NOR_FLASH flash_size = 0; for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) diff --git a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c index 8e37759..903732b 100644 --- a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c +++ b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c @@ -236,7 +236,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size = 0; for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; lcd_printf (" %ld MB SDRAM, %ld MB NAND\n", dram_size >> 20, nand_size >> 20 ); diff --git a/board/atmel/at91sam9n12ek/at91sam9n12ek.c b/board/atmel/at91sam9n12ek/at91sam9n12ek.c index 1105428..fec9316 100644 --- a/board/atmel/at91sam9n12ek/at91sam9n12ek.c +++ b/board/atmel/at91sam9n12ek/at91sam9n12ek.c @@ -124,7 +124,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size = 0; for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; lcd_printf(" %ld MB SDRAM, %ld MB NAND\n", dram_size >> 20, nand_size >> 20); diff --git a/board/atmel/at91sam9rlek/at91sam9rlek.c b/board/atmel/at91sam9rlek/at91sam9rlek.c index 7966269..672b376 100644 --- a/board/atmel/at91sam9rlek/at91sam9rlek.c +++ b/board/atmel/at91sam9rlek/at91sam9rlek.c @@ -149,7 +149,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size = 0; for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; lcd_printf (" %ld MB SDRAM, %ld MB NAND\n", dram_size >> 20, nand_size >> 20 ); diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c index 1e4a4a2..2452e63 100644 --- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c +++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c @@ -175,7 +175,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size = 0; for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; lcd_printf(" %ld MB SDRAM, %ld MB NAND\n", dram_size >> 20, nand_size >> 20); diff --git a/board/atmel/sama5d3xek/sama5d3xek.c b/board/atmel/sama5d3xek/sama5d3xek.c index cae6e24..c1f2769 100644 --- a/board/atmel/sama5d3xek/sama5d3xek.c +++ b/board/atmel/sama5d3xek/sama5d3xek.c @@ -198,7 +198,7 @@ void lcd_show_board_info(void) nand_size = 0; #ifdef CONFIG_NAND_ATMEL for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; #endif lcd_printf("%ld MB SDRAM, %lld MB NAND\n", dram_size >> 20, nand_size >> 20); diff --git a/board/atmel/sama5d4_xplained/sama5d4_xplained.c b/board/atmel/sama5d4_xplained/sama5d4_xplained.c index 94ecab2..854afcb 100644 --- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c +++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.c @@ -157,7 +157,7 @@ void lcd_show_board_info(void) nand_size = 0; #ifdef CONFIG_NAND_ATMEL for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; #endif lcd_printf("%ld MB SDRAM, %ld MB NAND\n", dram_size >> 20, nand_size >> 20); diff --git a/board/atmel/sama5d4ek/sama5d4ek.c b/board/atmel/sama5d4ek/sama5d4ek.c index b2e7979..ba79746 100644 --- a/board/atmel/sama5d4ek/sama5d4ek.c +++ b/board/atmel/sama5d4ek/sama5d4ek.c @@ -153,7 +153,7 @@ void lcd_show_board_info(void) nand_size = 0; #ifdef CONFIG_NAND_ATMEL for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size; #endif lcd_printf("%ld MB SDRAM, %ld MB NAND\n", dram_size >> 20, nand_size >> 20);

On Mon, Jun 26, 2017 at 07:13:03PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- board/ronetix/pm9261/pm9261.c | 2 +- board/ronetix/pm9263/pm9263.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/board/ronetix/pm9261/pm9261.c b/board/ronetix/pm9261/pm9261.c index f60ddda..160f8f8 100644 --- a/board/ronetix/pm9261/pm9261.c +++ b/board/ronetix/pm9261/pm9261.c @@ -195,7 +195,7 @@ void lcd_show_board_info(void)
nand_size = 0; for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size;
flash_size = 0; for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) diff --git a/board/ronetix/pm9263/pm9263.c b/board/ronetix/pm9263/pm9263.c index 1469136..0c23bb6 100644 --- a/board/ronetix/pm9263/pm9263.c +++ b/board/ronetix/pm9263/pm9263.c @@ -294,7 +294,7 @@ void lcd_show_board_info(void)
nand_size = 0; for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) - nand_size += nand_info[i]->size; + nand_size += get_nand_dev_by_index(i)->size;
flash_size = 0; for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++)

On Mon, Jun 26, 2017 at 07:13:04PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com Reviewed-by: Hannes Schmelzer hannes.schmelzer@br-automation.com Reviewed-by: Simon Glass sjg@chromium.org --- board/BuR/common/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c index e8c6401..c3a56db 100644 --- a/board/BuR/common/common.c +++ b/board/BuR/common/common.c @@ -259,7 +259,8 @@ static int load_devicetree(void) } #ifdef CONFIG_NAND dtbsize = 0x20000; - rc = nand_read_skip_bad(nand_info[0], 0x40000, (size_t *)&dtbsize, + rc = nand_read_skip_bad(get_nand_dev_by_index(0), 0x40000, + (size_t *)&dtbsize, NULL, 0x20000, (u_char *)dtbaddr); #else char *dtbname = getenv("dtb");

On Mon, Jun 26, 2017 at 07:13:05PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com Reviewed-by: Hannes Schmelzer hannes.schmelzer@br-automation.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Reviewed-by: Marcel Ziswiler marcel.ziswiler@toradex.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- board/toradex/colibri_t20/colibri_t20.c | 2 +- board/toradex/common/tdx-cfg-block.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/board/toradex/colibri_t20/colibri_t20.c b/board/toradex/colibri_t20/colibri_t20.c index 7d574fb..71b8fd3 100644 --- a/board/toradex/colibri_t20/colibri_t20.c +++ b/board/toradex/colibri_t20/colibri_t20.c @@ -69,7 +69,7 @@ int checkboard(void) { printf("Model: Toradex Colibri T20 %dMB V%s\n", (gd->ram_size == 0x10000000) ? 256 : 512, - (nand_info[0]->erasesize >> 10 == 512) ? + (get_nand_dev_by_index(0)->erasesize >> 10 == 512) ? ((gd->ram_size == 0x10000000) ? "1.1B" : "1.1C") : "1.2A");
return 0; diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c index 68ec436..1bf8ca8 100644 --- a/board/toradex/common/tdx-cfg-block.c +++ b/board/toradex/common/tdx-cfg-block.c @@ -154,8 +154,10 @@ static int read_tdx_cfg_block_from_nand(unsigned char *config_block) size_t size = TDX_CFG_BLOCK_MAX_SIZE;
/* Read production parameter config block from NAND page */ - return nand_read_skip_bad(nand_info[0], CONFIG_TDX_CFG_BLOCK_OFFSET, - &size, NULL, TDX_CFG_BLOCK_MAX_SIZE, config_block); + return nand_read_skip_bad(get_nand_dev_by_index(0), + CONFIG_TDX_CFG_BLOCK_OFFSET, + &size, NULL, TDX_CFG_BLOCK_MAX_SIZE, + config_block); }
static int write_tdx_cfg_block_to_nand(unsigned char *config_block) @@ -163,7 +165,8 @@ static int write_tdx_cfg_block_to_nand(unsigned char *config_block) size_t size = TDX_CFG_BLOCK_MAX_SIZE;
/* Write production parameter config block to NAND page */ - return nand_write_skip_bad(nand_info[0], CONFIG_TDX_CFG_BLOCK_OFFSET, + return nand_write_skip_bad(get_nand_dev_by_index(0), + CONFIG_TDX_CFG_BLOCK_OFFSET, &size, NULL, TDX_CFG_BLOCK_MAX_SIZE, config_block, WITH_WR_VERIFY); } @@ -426,7 +429,8 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc, * empty (config block invalid...) */ printf("NAND erase block %d need to be erased before creating a Toradex config block\n", - CONFIG_TDX_CFG_BLOCK_OFFSET / nand_info[0]->erasesize); + CONFIG_TDX_CFG_BLOCK_OFFSET / + get_nand_dev_by_index(0)->erasesize); goto out; #elif defined(CONFIG_TDX_CFG_BLOCK_IS_IN_NOR) /*

On Mon, Jun 26, 2017 at 07:13:06PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Reviewed-by: Marcel Ziswiler marcel.ziswiler@toradex.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: York Sun york.sun@nxp.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- arch/arm/cpu/armv8/fsl-layerscape/ppa.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c index 35c612d..24ddb5d 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/ppa.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/ppa.c @@ -173,8 +173,9 @@ int ppa_init(void) debug("%s: PPA image load from NAND\n", __func__);
nand_init(); - ret = nand_read(nand_info[0], (loff_t)CONFIG_SYS_LS_PPA_FW_ADDR, - &fdt_header_len, (u_char *)&fit); + ret = nand_read(get_nand_dev_by_index(0), + (loff_t)CONFIG_SYS_LS_PPA_FW_ADDR, + &fdt_header_len, (u_char *)&fit); if (ret == -EUCLEAN) { printf("NAND read of PPA FIT header at offset 0x%x failed\n", CONFIG_SYS_LS_PPA_FW_ADDR); @@ -196,8 +197,9 @@ int ppa_init(void)
fw_length = CONFIG_LS_PPA_ESBC_HDR_SIZE;
- ret = nand_read(nand_info[0], (loff_t)CONFIG_SYS_LS_PPA_ESBC_ADDR, - &fw_length, (u_char *)ppa_hdr_ddr); + ret = nand_read(get_nand_dev_by_index(0), + (loff_t)CONFIG_SYS_LS_PPA_ESBC_ADDR, + &fw_length, (u_char *)ppa_hdr_ddr); if (ret == -EUCLEAN) { free(ppa_hdr_ddr); printf("NAND read of PPA firmware at offset 0x%x failed\n", @@ -221,8 +223,9 @@ int ppa_init(void) return -ENOMEM; }
- ret = nand_read(nand_info[0], (loff_t)CONFIG_SYS_LS_PPA_FW_ADDR, - &fw_length, (u_char *)ppa_fit_addr); + ret = nand_read(get_nand_dev_by_index(0), + (loff_t)CONFIG_SYS_LS_PPA_FW_ADDR, + &fw_length, (u_char *)ppa_fit_addr); if (ret == -EUCLEAN) { free(ppa_fit_addr); printf("NAND read of PPA firmware at offset 0x%x failed\n",

On Mon, Jun 26, 2017 at 07:13:07PM -0500, Grygorii Strashko wrote:
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly.
Cc: Albert Aribaud albert.u.boot@aribaud.net Cc: York Sun york.sun@nxp.com Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

Make make nand_info array static, since all direct users of nand_info array have been converted to use get_nand_dev_by_index() API.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com --- drivers/mtd/nand/nand.c | 2 +- include/nand.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c index fd9a3be..6aa909f 100644 --- a/drivers/mtd/nand/nand.c +++ b/drivers/mtd/nand/nand.c @@ -19,7 +19,7 @@ DECLARE_GLOBAL_DATA_PTR;
int nand_curr_device = -1;
-struct mtd_info *nand_info[CONFIG_SYS_MAX_NAND_DEVICE]; +static struct mtd_info *nand_info[CONFIG_SYS_MAX_NAND_DEVICE];
#ifndef CONFIG_SYS_NAND_SELF_INIT static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE]; diff --git a/include/nand.h b/include/nand.h index c8556e1..c1c1d8c 100644 --- a/include/nand.h +++ b/include/nand.h @@ -44,7 +44,6 @@ extern int board_nand_init(struct nand_chip *nand); #endif
extern int nand_curr_device; -extern struct mtd_info *nand_info[];
static inline int nand_read(struct mtd_info *info, loff_t ofs, size_t *len, u_char *buf)

On Mon, Jun 26, 2017 at 07:13:08PM -0500, Grygorii Strashko wrote:
Make make nand_info array static, since all direct users of nand_info array have been converted to use get_nand_dev_by_index() API.
Signed-off-by: Grygorii Strashko grygorii.strashko@ti.com
Applied to u-boot/master, thanks!

On Mon, Jun 26, 2017 at 07:12:50PM -0500, Grygorii Strashko wrote:
This is a preparation required for adding Nand DM support. This series introduces new API get_nand_dev_by_index() to avoid direct acces to nand_info array and updates u-boot to use it. As result, nand_info array is made static in the last patch.
Changes in v4:
- rebased on top of git://git.denx.de/u-boot.git/master
- added patch for arch/arm/cpu/armv8/fsl-layerscape/ppa.c
- added "Reviewed-by" tags
Can you push all of this into a travis-ci build and send back a link to it all passing? Thanks!

On Sunday 02 July 2017 06:11 PM, Tom Rini wrote:
On Mon, Jun 26, 2017 at 07:12:50PM -0500, Grygorii Strashko wrote:
This is a preparation required for adding Nand DM support. This series introduces new API get_nand_dev_by_index() to avoid direct acces to nand_info array and updates u-boot to use it. As result, nand_info array is made static in the last patch.
Changes in v4:
- rebased on top of git://git.denx.de/u-boot.git/master
- added patch for arch/arm/cpu/armv8/fsl-layerscape/ppa.c
- added "Reviewed-by" tags
Can you push all of this into a travis-ci build and send back a link to it all passing? Thanks!
Here is the travis-ci link. https://travis-ci.org/lokeshvutla/u-boot/builds/249477022. Everything build successfully except am33xx and xtensa. But these failures has nothing to do with these patches as it is failure while downloading toolchain:
The command "if [[ "${TOOLCHAIN}" == "" ]]; then wget http://releases.linaro.org/components/toolchain/binaries/6.3-2017.02/aarch64... && wget http://releases.linaro.org/components/toolchain/binaries/6.3-2017.02/arm-lin... && tar -C /tmp -xf gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu.tar.xz && tar -C /tmp -xf gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf.tar.xz; fi" failed and exited with 8 during .
Thanks and regards, Lokesh

On Mon, Jul 03, 2017 at 11:30:36AM +0530, Lokesh Vutla wrote:
On Sunday 02 July 2017 06:11 PM, Tom Rini wrote:
On Mon, Jun 26, 2017 at 07:12:50PM -0500, Grygorii Strashko wrote:
This is a preparation required for adding Nand DM support. This series introduces new API get_nand_dev_by_index() to avoid direct acces to nand_info array and updates u-boot to use it. As result, nand_info array is made static in the last patch.
Changes in v4:
- rebased on top of git://git.denx.de/u-boot.git/master
- added patch for arch/arm/cpu/armv8/fsl-layerscape/ppa.c
- added "Reviewed-by" tags
Can you push all of this into a travis-ci build and send back a link to it all passing? Thanks!
Here is the travis-ci link. https://travis-ci.org/lokeshvutla/u-boot/builds/249477022. Everything build successfully except am33xx and xtensa. But these failures has nothing to do with these patches as it is failure while downloading toolchain:
When that happens just hit the restart job button, btw.

On Monday 03 July 2017 04:47 PM, Tom Rini wrote:
On Mon, Jul 03, 2017 at 11:30:36AM +0530, Lokesh Vutla wrote:
On Sunday 02 July 2017 06:11 PM, Tom Rini wrote:
On Mon, Jun 26, 2017 at 07:12:50PM -0500, Grygorii Strashko wrote:
This is a preparation required for adding Nand DM support. This series introduces new API get_nand_dev_by_index() to avoid direct acces to nand_info array and updates u-boot to use it. As result, nand_info array is made static in the last patch.
Changes in v4:
- rebased on top of git://git.denx.de/u-boot.git/master
- added patch for arch/arm/cpu/armv8/fsl-layerscape/ppa.c
- added "Reviewed-by" tags
Can you push all of this into a travis-ci build and send back a link to it all passing? Thanks!
Here is the travis-ci link. https://travis-ci.org/lokeshvutla/u-boot/builds/249477022. Everything build successfully except am33xx and xtensa. But these failures has nothing to do with these patches as it is failure while downloading toolchain:
When that happens just hit the restart job button, btw.
After restarting the job, everything passes now. https://travis-ci.org/lokeshvutla/u-boot/builds/249477022
Thanks and regards, Lokesh
participants (4)
-
Grygorii Strashko
-
Lokesh Vutla
-
Simon Glass
-
Tom Rini