From patchwork Fri Feb 10 20:22:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 726707 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3vKmcy6Jnyz9s82 for ; Sat, 11 Feb 2017 07:24:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 15B114B6B3; Fri, 10 Feb 2017 21:24:03 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E9ZykL4cIFak; Fri, 10 Feb 2017 21:24:02 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ABEFF4BA29; Fri, 10 Feb 2017 21:23:35 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1DE8B4B01B for ; Fri, 10 Feb 2017 21:23:22 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pyVCaW4ztaHt for ; Fri, 10 Feb 2017 21:23:22 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by theia.denx.de (Postfix) with ESMTPS id A8F364AB34 for ; Fri, 10 Feb 2017 21:23:21 +0100 (CET) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v1AKN7wo026690; Fri, 10 Feb 2017 14:23:07 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v1AKN7GZ023162; Fri, 10 Feb 2017 14:23:07 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Fri, 10 Feb 2017 14:23:06 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v1AKN6wa026962; Fri, 10 Feb 2017 14:23:06 -0600 Received: from localhost (uda0226610.am.dhcp.ti.com [128.247.83.96]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id v1AKN6313540; Fri, 10 Feb 2017 14:23:06 -0600 (CST) From: Grygorii Strashko To: Lokesh Vutla , Lukasz Majewski , Tom Rini , Scott Wood , Joe Hershberger , Simon Glass Date: Fri, 10 Feb 2017 14:22:54 -0600 Message-ID: <20170210202304.20652-8-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.10.1.dirty In-Reply-To: <20170210202304.20652-1-grygorii.strashko@ti.com> References: <20170210202304.20652-1-grygorii.strashko@ti.com> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 07/17] fs: use get_nand_dev_by_index() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "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 --- 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");