diff mbox

[U-Boot,v4,12/18] cmd: mvebu: bubt: use get_nand_dev_by_index()

Message ID 20170627001308.23513-13-grygorii.strashko@ti.com
State Accepted
Commit 7021c7e6f2fcc1d024ed2f64c2974e243f129d87
Delegated to: Tom Rini
Headers show

Commit Message

Grygorii Strashko June 27, 2017, 12:13 a.m. UTC
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(-)

Comments

Tom Rini July 12, 2017, 12:15 p.m. UTC | #1
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!
diff mbox

Patch

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