From patchwork Wed Jul 29 17:53:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 501781 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1FC5F1402D5 for ; Thu, 30 Jul 2015 03:56:21 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKVYj-0004Pr-Ih; Wed, 29 Jul 2015 17:54:29 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKVYY-0004KT-98 for linux-mtd@lists.infradead.org; Wed, 29 Jul 2015 17:54:19 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 66897C6563; Wed, 29 Jul 2015 17:54:02 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-7-2.ams2.redhat.com [10.36.7.2]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6THrtO0026948; Wed, 29 Jul 2015 13:54:00 -0400 From: Hans de Goede To: David Woodhouse , Brian Norris Subject: [PATCH 4/4] mtd: nand: print full chip ID Date: Wed, 29 Jul 2015 19:53:54 +0200 Message-Id: <1438192434-18363-4-git-send-email-hdegoede@redhat.com> In-Reply-To: <1438192434-18363-1-git-send-email-hdegoede@redhat.com> References: <1438192434-18363-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150729_105418_377640_8AB8A668 X-CRM114-Status: GOOD ( 11.14 ) X-Spam-Score: -8.3 (--------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-8.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [209.132.183.28 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -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.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mtd@lists.infradead.org, linux-sunxi@googlegroups.com, Michal Suchanek , Boris BREZILLON , Hans de Goede MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Michal Suchanek Full chip ID is printed so user has data to paste from syslog in case of chip misidentification. Signed-off-by: Michal Suchanek Signed-off-by: Hans de Goede --- drivers/mtd/nand/nand_base.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index e2e2690..13e9938 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -4243,7 +4243,7 @@ static inline bool is_full_id_nand(struct nand_flash_dev *type) } static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, - struct nand_flash_dev *type, u8 *id_data, int *busw) + struct nand_flash_dev *type, const u8 *id_data, int *busw) { if (!strncmp(type->id, id_data, type->id_len)) { mtd->writesize = type->pagesize; @@ -4269,6 +4269,26 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, } /* + * Print full detail of chip ID read from chip. + */ +static void print_nand_chip_info(int maf_id, int dev_id, u8 id_data[8]) +{ + u8 delim[8] = { [0 ... 7] = ',' }; + + pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", + maf_id, dev_id); + + delim[7] = ' '; + delim[nand_id_len(id_data, 8) - 1] = ';'; + + pr_info("chip id data: 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c\n", + id_data[0], delim[0], id_data[1], delim[1], + id_data[2], delim[2], id_data[3], delim[3], + id_data[4], delim[4], id_data[5], delim[5], + id_data[6], delim[6], id_data[7], delim[7]); +} + +/* * Get the flash and manufacturer id and lookup if the type is supported. */ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, @@ -4381,8 +4401,7 @@ ident_done: * Check, if buswidth is correct. Hardware drivers should set * chip correct! */ - pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", - *maf_id, *dev_id); + print_nand_chip_info(*maf_id, *dev_id, id_data); pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, mtd->name); pr_warn("bus width %d instead %d bit\n", (chip->options & NAND_BUSWIDTH_16) ? 16 : 8, @@ -4420,8 +4439,7 @@ ident_done: return ERR_PTR(err); } - pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", - *maf_id, *dev_id); + print_nand_chip_info(*maf_id, *dev_id, id_data); if (chip->onfi_version) pr_info("%s %s\n", nand_manuf_ids[maf_idx].name,