From patchwork Sat Jun 26 00:58:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 57048 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C6FCDB7086 for ; Sat, 26 Jun 2010 11:00:39 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OSJjj-00055m-4k; Sat, 26 Jun 2010 00:59:11 +0000 Received: from mms2.broadcom.com ([216.31.210.18]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OSJjg-00054i-0J for linux-mtd@lists.infradead.org; Sat, 26 Jun 2010 00:59:09 +0000 Received: from [10.9.200.133] by mms2.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Fri, 25 Jun 2010 17:58:54 -0700 X-Server-Uuid: D3C04415-6FA8-4F2C-93C1-920E106A2031 Received: from mail-irva-12.broadcom.com (10.11.16.101) by IRVEXCHHUB02.corp.ad.broadcom.com (10.9.200.133) with Microsoft SMTP Server id 8.2.247.2; Fri, 25 Jun 2010 18:00:15 -0700 Received: from ld-irv-0074.broadcom.com (ld-irv-0074.broadcom.com [10.12.160.50]) by mail-irva-12.broadcom.com (Postfix) with ESMTP id BEE5169CA9; Fri, 25 Jun 2010 17:58:53 -0700 (PDT) Received: by ld-irv-0074.broadcom.com (Postfix, from userid 14777) id A22F825E0DCD; Fri, 25 Jun 2010 17:58:53 -0700 (PDT) From: "Brian Norris" To: "Artem Bityutskiy" Subject: [PATCH 1/2] mtd-utils: formatting of odd-sized OOB in nanddump Date: Fri, 25 Jun 2010 17:58:03 -0700 Message-ID: <1277513884-14715-1-git-send-email-norris@broadcom.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 X-WSS-ID: 603B8F4410010537379-01-01 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100625_205908_293693_55A89ED2 X-CRM114-Status: GOOD ( 15.29 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: linux-mtd@lists.infradead.org, Brian Norris X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Changed OOB output formatting in nanddump. Most NAND devices have OOB regions with multiples of 16 bytes. With newer devices, a 218-byte OOB does not split nicely into lines of 16 bytes. This patch fixes the formatting, allowing a last line of 10 bytes instead of 16. Signed-off-by: Brian Norris --- nanddump.c | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-) diff --git a/nanddump.c b/nanddump.c index e44ab36..190a653 100644 --- a/nanddump.c +++ b/nanddump.c @@ -381,15 +381,28 @@ int main(int argc, char * const argv[]) } for (i = 0; i < meminfo.oobsize; i += 16) { - sprintf(pretty_buf, " OOB Data: %02x %02x %02x %02x %02x %02x " - "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", - oobbuf[i], oobbuf[i+1], oobbuf[i+2], - oobbuf[i+3], oobbuf[i+4], oobbuf[i+5], - oobbuf[i+6], oobbuf[i+7], oobbuf[i+8], - oobbuf[i+9], oobbuf[i+10], oobbuf[i+11], - oobbuf[i+12], oobbuf[i+13], oobbuf[i+14], - oobbuf[i+15]); - write(ofd, pretty_buf, 60); + /* Check if we have a full 16 bytes left in the OOB */ + if (i+15 < meminfo.oobsize) { + /* Print 16 bytes */ + sprintf(pretty_buf, " OOB Data: %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", + oobbuf[i], oobbuf[i+1], oobbuf[i+2], + oobbuf[i+3], oobbuf[i+4], oobbuf[i+5], + oobbuf[i+6], oobbuf[i+7], oobbuf[i+8], + oobbuf[i+9], oobbuf[i+10], oobbuf[i+11], + oobbuf[i+12], oobbuf[i+13], oobbuf[i+14], + oobbuf[i+15]); + write(ofd, pretty_buf, 60); + } else { + /* Print 10 bytes */ + sprintf(pretty_buf, " OOB Data: %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x\n", + oobbuf[i], oobbuf[i+1], oobbuf[i+2], + oobbuf[i+3], oobbuf[i+4], oobbuf[i+5], + oobbuf[i+6], oobbuf[i+7], oobbuf[i+8], + oobbuf[i+9]); + write(ofd, pretty_buf, 42); + } } } else write(ofd, oobbuf, meminfo.oobsize);