From patchwork Tue Jun 27 00:12:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 780925 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wxRRW5wsYz9s72 for ; Tue, 27 Jun 2017 10:21:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="hXN+Nqg3"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id 8CCFFC21D5F; Tue, 27 Jun 2017 00:19:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0C698C21D70; Tue, 27 Jun 2017 00:19:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 87804C21C5E; Tue, 27 Jun 2017 00:14:46 +0000 (UTC) Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by lists.denx.de (Postfix) with ESMTPS id 874F1C21C2A for ; Tue, 27 Jun 2017 00:14:42 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v5R0DFd3023001; Mon, 26 Jun 2017 19:13:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1498522395; bh=HLgjNt9h72iFRzFw6oHSPkrSjF2p5mc5zFkHOnWq4Yk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=hXN+Nqg3xHMIzkv7V7YyJH1GRul2liWYD1YF/R1ZenzgoZImSYk99xyj1oHpgPsM1 INh+vntVAO6tFK7zaT1dkytVGLAjLq1AUcIa2rWRcrWyMcWs7i0F1h56Py1watNCOX gPEvTR5jFxgAb8yi61bxg+wcnvSXHewKU5nKrfR0= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v5R0DAT9024903; Mon, 26 Jun 2017 19:13:10 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Mon, 26 Jun 2017 19:13:09 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v5R0D954010841; Mon, 26 Jun 2017 19:13:09 -0500 Received: from localhost (uda0226610.dhcp.ti.com [128.247.59.147]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id v5R0D9328770; Mon, 26 Jun 2017 19:13:09 -0500 (CDT) From: Grygorii Strashko To: Lokesh Vutla , Tom Rini , Scott Wood , Simon Glass Date: Mon, 26 Jun 2017 19:12:53 -0500 Message-ID: <20170627001308.23513-4-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170627001308.23513-1-grygorii.strashko@ti.com> References: <20170627001308.23513-1-grygorii.strashko@ti.com> MIME-Version: 1.0 Cc: Stelian Pop , u-boot@lists.denx.de, Bo Shen , Franklin S Cooper Jr Subject: [U-Boot] [PATCH v4 03/18] dfu: dfu_nand: use get_nand_dev_by_index() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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 --- 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) {