From patchwork Thu Jun 29 17:08:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Louis Thekekara X-Patchwork-Id: 782384 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wz5jw68V9z9s3T for ; Fri, 30 Jun 2017 03:09:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BUtqgRFc"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=IZ7B7zHrOGoANmR7uWRD6ILjweqeqOfCSGwCxIIfxng=; b=BUtqgRFctVmU1i UxWx1qyhzQxitZFdRXd/fhu0Uqxe6S0cfqlQxPVFC5Izbme3mxY3PpxM8g/JruWngdGM6azMzfDIr QzOjbUmR6T7Qgqe7LUgoROA6bW2di+19VuX6OYZauXqUMpetUSFDbq4rKe12rjiO4mkSWAdkMW2bz hX76ZDkcDPWb9wsRwuGs/B0a0+gd8ue7jCscn+ADo18+gk60P2oVp5eWUB1UXrH3+hHdFxtCh3w4F rNxK7kzf37oDcWK8ZPUeLUn5oWlrzvFqvuhEgTUohjg49CWDfknvHbmEzMvPagGoMV2jLC5GJxz/p CP0YAVUxL8w0UfkT/zaw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQcwK-00010e-61; Thu, 29 Jun 2017 17:09:12 +0000 Received: from mail.aswsp.com ([193.34.35.150]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQcwH-0000vx-4u for linux-mtd@lists.infradead.org; Thu, 29 Jun 2017 17:09:11 +0000 Received: from pal2016l002.Parrot.Biz (46.218.109.88) by smtp.aswsp.com (193.34.32.148) with Microsoft SMTP Server (TLS) id 14.2.342.3; Thu, 29 Jun 2017 19:09:36 +0200 From: Jean-Louis Thekekara To: Subject: [PATCH] mtd: nand: remove hard-coded NAND ids length Date: Thu, 29 Jun 2017 19:08:30 +0200 Message-ID: <20170629170830.8084-1-jeanlouis.thekekara@parrot.com> X-Mailer: git-send-email 2.13.2 MIME-Version: 1.0 X-Originating-IP: [46.218.109.88] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170629_100909_386228_294BAA4A X-CRM114-Status: GOOD ( 11.26 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [193.34.35.150 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This commit removes hard-coded '8' used for looping into struct nand_chip.id.data array. NAND_MAX_ID_LEN has been introduced by Artem Bityutskiy in 53552d22bfe1f for defining ids length in nand_flash_ids[] list. This commit unifies ids length in nand base driver. Signed-off-by: Jean-Louis Thekekara --- drivers/mtd/nand/nand_base.c | 4 ++-- include/linux/mtd/nand.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 85edac9b2bb5..66db2ced87ad 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -4056,7 +4056,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); /* Read entire ID string */ - for (i = 0; i < 8; i++) + for (i = 0; i < ARRAY_SIZE(chip->id.data); i++) id_data[i] = chip->read_byte(mtd); if (id_data[0] != maf_id || id_data[1] != dev_id) { @@ -4065,7 +4065,7 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) return -ENODEV; } - chip->id.len = nand_id_len(id_data, 8); + chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data)); /* Try to identify manufacturer */ manufacturer = nand_get_manufacturer(maf_id); diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index dc8fbc033442..c3c1a32a5ade 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -449,14 +449,16 @@ struct nand_jedec_params { __le16 crc; } __packed; +/* The maximum expected count of bytes in the NAND ID sequence */ +#define NAND_MAX_ID_LEN 8 + /** * struct nand_id - NAND id structure - * @data: buffer containing the id bytes. Currently 8 bytes large, but can - * be extended if required. + * @data: buffer containing the id bytes. * @len: ID length. */ struct nand_id { - u8 data[8]; + u8 data[NAND_MAX_ID_LEN]; int len; }; @@ -1028,8 +1030,6 @@ static inline void *nand_get_manufacturer_data(struct nand_chip *chip) #define NAND_MFR_ATO 0x9b #define NAND_MFR_WINBOND 0xef -/* The maximum expected count of bytes in the NAND ID sequence */ -#define NAND_MAX_ID_LEN 8 /* * A helper for defining older NAND chips where the second ID byte fully