public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array
@ 2017-02-10 20:22 Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 01/17] cmd: nand: abstract global variable usage for dm conversion Grygorii Strashko
                   ` (16 more replies)
  0 siblings, 17 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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 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 v2 [1]:
- https://www.mail-archive.com/u-boot at lists.denx.de/msg237747.html

Grygorii Strashko (16):
  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()
  mtd: nand: make nand_info array static

Mugunthan V N (1):
  cmd: nand: abstract global variable usage for dm conversion

 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 +++-
 32 files changed, 153 insertions(+), 103 deletions(-)

-- 
2.10.1.dirty

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 01/17] cmd: nand: abstract global variable usage for dm conversion
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 02/17] common: env_nand: use get_nand_dev_by_index() Grygorii Strashko
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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 0551241..9d14fda 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++;
 		}
 	}
@@ -148,7 +157,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 b6eb223..6c785a0 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -145,3 +145,12 @@ 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);
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 02/17] common: env_nand: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 01/17] cmd: nand: abstract global variable usage for dm conversion Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 03/17] dfu: dfu_nand: " Grygorii Strashko
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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");
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 03/17] dfu: dfu_nand: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 01/17] cmd: nand: abstract global variable usage for dm conversion Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 02/17] common: env_nand: use get_nand_dev_by_index() Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 04/17] cmd: bootm: " Grygorii Strashko
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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) {
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 04/17] cmd: bootm: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (2 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 03/17] dfu: dfu_nand: " Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 05/17] cmd: jffs2: " Grygorii Strashko
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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;
 
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 05/17] cmd: jffs2: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (3 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 04/17] cmd: bootm: " Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 06/17] common: " Grygorii Strashko
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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 f00d53a..162c8fe 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
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 06/17] common: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (4 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 05/17] cmd: jffs2: " Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 07/17] fs: " Grygorii Strashko
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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 a5eeb3f..7c9b7b5 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
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 07/17] fs: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (5 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 06/17] common: " Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 08/17] cmd: nand: remove direct access to struct mtd_info->priv Grygorii Strashko
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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 25aa6d1..347424e 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");
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 08/17] cmd: nand: remove direct access to struct mtd_info->priv
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (6 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 07/17] fs: " Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 09/17] net: phy: cortina: use get_nand_dev_by_index() Grygorii Strashko
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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;
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 09/17] net: phy: cortina: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (7 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 08/17] cmd: nand: remove direct access to struct mtd_info->priv Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:52   ` Joe Hershberger
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 10/17] net: fm: " Grygorii Strashko
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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/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",
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 10/17] net: fm: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (8 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 09/17] net: phy: cortina: use get_nand_dev_by_index() Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:54   ` Joe Hershberger
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 11/17] mtd: nand: drv: " Grygorii Strashko
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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/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",
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 11/17] mtd: nand: drv: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (9 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 10/17] net: fm: " Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 12/17] cmd: mvebu: bubt: " Grygorii Strashko
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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;
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 12/17] cmd: mvebu: bubt: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (10 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 11/17] mtd: nand: drv: " Grygorii Strashko
@ 2017-02-10 20:22 ` Grygorii Strashko
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 13/17] board: atmel: " Grygorii Strashko
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:22 UTC (permalink / raw)
  To: u-boot

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 b752927..bb9b7ed 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -309,24 +309,22 @@ static int is_spi_active(void)
 #ifdef CONFIG_CMD_NAND
 static int nand_burn_image(size_t image_size)
 {
+	struct mtd_info *mtd;
 	int ret, block_size;
-	nand_info_t *nand;
-	int dev = nand_curr_device;
 
-	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;
@@ -336,7 +334,7 @@ static int nand_burn_image(size_t image_size)
 	/* Write the image to flash */
 	printf("Writing image:...");
 	printf("&image_size = 0x%p\n", (void *)&image_size);
-	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
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 13/17] board: atmel: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (11 preceding siblings ...)
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 12/17] cmd: mvebu: bubt: " Grygorii Strashko
@ 2017-02-10 20:23 ` Grygorii Strashko
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 14/17] board: ronetix: " Grygorii Strashko
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:23 UTC (permalink / raw)
  To: u-boot

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: Stelian Pop <stelian@popies.net>
Cc: Bo Shen <voice.shen@atmel.com>
Cc: Josh Wu <josh.wu@atmel.com>
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 6398bcb..4e443d9 100644
--- a/board/atmel/at91sam9261ek/at91sam9261ek.c
+++ b/board/atmel/at91sam9261ek/at91sam9261ek.c
@@ -212,7 +212,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 04e5812..b0e075a 100644
--- a/board/atmel/at91sam9263ek/at91sam9263ek.c
+++ b/board/atmel/at91sam9263ek/at91sam9263ek.c
@@ -191,7 +191,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;
 #ifndef CONFIG_SYS_NO_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 6871916..0f1484b 100644
--- a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
+++ b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
@@ -272,7 +272,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 fc4f50d..682a983 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 994f246..334e5e3 100644
--- a/board/atmel/at91sam9rlek/at91sam9rlek.c
+++ b/board/atmel/at91sam9rlek/at91sam9rlek.c
@@ -151,7 +151,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 b0d440d..c697bc9 100644
--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
@@ -196,7 +196,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 fa90270..9dd5241 100644
--- a/board/atmel/sama5d3xek/sama5d3xek.c
+++ b/board/atmel/sama5d3xek/sama5d3xek.c
@@ -207,7 +207,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 23ec274..afbe374 100644
--- a/board/atmel/sama5d4_xplained/sama5d4_xplained.c
+++ b/board/atmel/sama5d4_xplained/sama5d4_xplained.c
@@ -191,7 +191,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 72bad23..a0902fb 100644
--- a/board/atmel/sama5d4ek/sama5d4ek.c
+++ b/board/atmel/sama5d4ek/sama5d4ek.c
@@ -187,7 +187,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);
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 14/17] board: ronetix: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (12 preceding siblings ...)
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 13/17] board: atmel: " Grygorii Strashko
@ 2017-02-10 20:23 ` Grygorii Strashko
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 15/17] board: BuR: " Grygorii Strashko
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:23 UTC (permalink / raw)
  To: u-boot

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: Ilko Iliev <iliev@ronetix.at>
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 e2cb94e..2d3c0a8 100644
--- a/board/ronetix/pm9261/pm9261.c
+++ b/board/ronetix/pm9261/pm9261.c
@@ -194,7 +194,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 e9f9b67..49c74ad 100644
--- a/board/ronetix/pm9263/pm9263.c
+++ b/board/ronetix/pm9263/pm9263.c
@@ -293,7 +293,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++)
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 15/17] board: BuR: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (13 preceding siblings ...)
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 14/17] board: ronetix: " Grygorii Strashko
@ 2017-02-10 20:23 ` Grygorii Strashko
  2017-02-21 11:53   ` Hannes Schmelzer
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 16/17] board: toradex: " Grygorii Strashko
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 17/17] mtd: nand: make nand_info array static Grygorii Strashko
  16 siblings, 1 reply; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:23 UTC (permalink / raw)
  To: u-boot

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: Hannes Schmelzer <oe5hpm@oevsv.at>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 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 e947e54..cd084d9 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");
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 16/17] board: toradex: use get_nand_dev_by_index()
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (14 preceding siblings ...)
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 15/17] board: BuR: " Grygorii Strashko
@ 2017-02-10 20:23 ` Grygorii Strashko
  2017-02-11  1:20   ` Marcel Ziswiler
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 17/17] mtd: nand: make nand_info array static Grygorii Strashko
  16 siblings, 1 reply; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:23 UTC (permalink / raw)
  To: u-boot

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: Lucas Stach <dev@lynxeye.de>
Cc: 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 0014ce8..7722b92 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -153,8 +153,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)
@@ -162,7 +164,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);
 }
@@ -425,7 +428,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)
 		/*
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 17/17] mtd: nand: make nand_info array static
  2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
                   ` (15 preceding siblings ...)
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 16/17] board: toradex: " Grygorii Strashko
@ 2017-02-10 20:23 ` Grygorii Strashko
  16 siblings, 0 replies; 23+ messages in thread
From: Grygorii Strashko @ 2017-02-10 20:23 UTC (permalink / raw)
  To: u-boot

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 9d14fda..e567d61 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 6c785a0..3b9d3c6 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -43,7 +43,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)
-- 
2.10.1.dirty

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 09/17] net: phy: cortina: use get_nand_dev_by_index()
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 09/17] net: phy: cortina: use get_nand_dev_by_index() Grygorii Strashko
@ 2017-02-10 20:52   ` Joe Hershberger
  0 siblings, 0 replies; 23+ messages in thread
From: Joe Hershberger @ 2017-02-10 20:52 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 10, 2017 at 2:22 PM, Grygorii Strashko
<grygorii.strashko@ti.com> 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>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 10/17] net: fm: use get_nand_dev_by_index()
  2017-02-10 20:22 ` [U-Boot] [PATCH v3 10/17] net: fm: " Grygorii Strashko
@ 2017-02-10 20:54   ` Joe Hershberger
  0 siblings, 0 replies; 23+ messages in thread
From: Joe Hershberger @ 2017-02-10 20:54 UTC (permalink / raw)
  To: u-boot

On Fri, Feb 10, 2017 at 2:22 PM, Grygorii Strashko
<grygorii.strashko@ti.com> 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>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 16/17] board: toradex: use get_nand_dev_by_index()
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 16/17] board: toradex: " Grygorii Strashko
@ 2017-02-11  1:20   ` Marcel Ziswiler
  0 siblings, 0 replies; 23+ messages in thread
From: Marcel Ziswiler @ 2017-02-11  1:20 UTC (permalink / raw)
  To: u-boot

On Fri, 2017-02-10 at 14:23 -0600, 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: Lucas Stach <dev@lynxeye.de>
> Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

Looks reasonable to me.

Reviewed-by:?Marcel Ziswiler <marcel.ziswiler@toradex.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 0014ce8..7722b92 100644
> --- a/board/toradex/common/tdx-cfg-block.c
> +++ b/board/toradex/common/tdx-cfg-block.c
> @@ -153,8 +153,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)
> @@ -162,7 +164,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);
> ?}
> @@ -425,7 +428,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)
> ?		/*

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 15/17] board: BuR: use get_nand_dev_by_index()
  2017-02-10 20:23 ` [U-Boot] [PATCH v3 15/17] board: BuR: " Grygorii Strashko
@ 2017-02-21 11:53   ` Hannes Schmelzer
  2017-02-22  4:00     ` Simon Glass
  0 siblings, 1 reply; 23+ messages in thread
From: Hannes Schmelzer @ 2017-02-21 11:53 UTC (permalink / raw)
  To: u-boot

> 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: Hannes Schmelzer <oe5hpm@oevsv.at>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> ---
>  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 e947e54..cd084d9 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");
> -- 
> 2.10.1.dirty
Reviewed-by:  Hannes Schmelzer <hannes.schmelzer@br-automation.com>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [U-Boot] [PATCH v3 15/17] board: BuR: use get_nand_dev_by_index()
  2017-02-21 11:53   ` Hannes Schmelzer
@ 2017-02-22  4:00     ` Simon Glass
  0 siblings, 0 replies; 23+ messages in thread
From: Simon Glass @ 2017-02-22  4:00 UTC (permalink / raw)
  To: u-boot

On 21 February 2017 at 04:53, Hannes Schmelzer
<Hannes.Schmelzer@br-automation.com> 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: Hannes Schmelzer <oe5hpm@oevsv.at>
>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
>> ---
>>  board/BuR/common/common.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-02-22  4:00 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-10 20:22 [U-Boot] [PATCH v3 00/17] nand: remove direct acces to nand_info array Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 01/17] cmd: nand: abstract global variable usage for dm conversion Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 02/17] common: env_nand: use get_nand_dev_by_index() Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 03/17] dfu: dfu_nand: " Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 04/17] cmd: bootm: " Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 05/17] cmd: jffs2: " Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 06/17] common: " Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 07/17] fs: " Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 08/17] cmd: nand: remove direct access to struct mtd_info->priv Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 09/17] net: phy: cortina: use get_nand_dev_by_index() Grygorii Strashko
2017-02-10 20:52   ` Joe Hershberger
2017-02-10 20:22 ` [U-Boot] [PATCH v3 10/17] net: fm: " Grygorii Strashko
2017-02-10 20:54   ` Joe Hershberger
2017-02-10 20:22 ` [U-Boot] [PATCH v3 11/17] mtd: nand: drv: " Grygorii Strashko
2017-02-10 20:22 ` [U-Boot] [PATCH v3 12/17] cmd: mvebu: bubt: " Grygorii Strashko
2017-02-10 20:23 ` [U-Boot] [PATCH v3 13/17] board: atmel: " Grygorii Strashko
2017-02-10 20:23 ` [U-Boot] [PATCH v3 14/17] board: ronetix: " Grygorii Strashko
2017-02-10 20:23 ` [U-Boot] [PATCH v3 15/17] board: BuR: " Grygorii Strashko
2017-02-21 11:53   ` Hannes Schmelzer
2017-02-22  4:00     ` Simon Glass
2017-02-10 20:23 ` [U-Boot] [PATCH v3 16/17] board: toradex: " Grygorii Strashko
2017-02-11  1:20   ` Marcel Ziswiler
2017-02-10 20:23 ` [U-Boot] [PATCH v3 17/17] mtd: nand: make nand_info array static Grygorii Strashko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox