From patchwork Tue Oct 21 13:53:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 39148 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 38EAB202DB for ; Tue, 21 Oct 2014 13:54:45 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id hi2sf988623wib.1 for ; Tue, 21 Oct 2014 06:54:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=YilUWIlYktRVErsYGm1m+csLNHBdidvUO9c+7V6pwyo=; b=ZqPL8JKKNIKYQm3ZODQ9rpw7r6jnZLIMST5Z7EbzWp/InPglcAiE9XUgaVkbQD/rcP E+IKSZpsrM2J7JDsj1T3tHCKND4aGt/Ex7qkcrcd586c1Ln8oLMneyWYn2ujaFEUZwYB NEFOAkswvS7E5V3vgKfIG27WlypCCXxv+c2hu7vnOBebDAX2ahuiUmegNiKt5T2OuTQJ g2RC2ws7i8bVOLtW6uO0qdN6Y9e4DCouO90dsnBoJ5lKGujPnZMxgxxegaaz17tBm9aE 07t0/tsJF10u8+Elf1BvUsgaaPIv6NPNn8znIdcseWQq9LPxaRwSF792yGon7DZLxu1t 6NYA== X-Gm-Message-State: ALoCoQkPwUqR2lBHyeJUAWmEtCv3QRW5LDgE6K/ZBrC19NHWZpQblME4qlz2rXRIaeTQcICHyk/u X-Received: by 10.152.4.165 with SMTP id l5mr537833lal.4.1413899682091; Tue, 21 Oct 2014 06:54:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.41 with SMTP id s9ls63785lae.41.gmail; Tue, 21 Oct 2014 06:54:41 -0700 (PDT) X-Received: by 10.152.18.166 with SMTP id x6mr34349416lad.18.1413899681919; Tue, 21 Oct 2014 06:54:41 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id p8si19066311lag.62.2014.10.21.06.54.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 06:54:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id q1so1066741lam.8 for ; Tue, 21 Oct 2014 06:54:41 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr35176544lbb.46.1413899681695; Tue, 21 Oct 2014 06:54:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp501988lbz; Tue, 21 Oct 2014 06:54:40 -0700 (PDT) X-Received: by 10.70.61.37 with SMTP id m5mr2904064pdr.162.1413899679506; Tue, 21 Oct 2014 06:54:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ra10si11275816pab.86.2014.10.21.06.54.38 for ; Tue, 21 Oct 2014 06:54:39 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932839AbaJUNye (ORCPT + 27 others); Tue, 21 Oct 2014 09:54:34 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:60973 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932627AbaJUNyL (ORCPT ); Tue, 21 Oct 2014 09:54:11 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s9LDrlHc007029; Tue, 21 Oct 2014 08:53:47 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9LDrlx4009693; Tue, 21 Oct 2014 08:53:47 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Tue, 21 Oct 2014 08:53:47 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s9LDrgf3021645; Tue, 21 Oct 2014 08:53:45 -0500 From: Roger Quadros To: , CC: , , , Roger Quadros , Sekhar Nori Subject: [PATCH 1/2] mtd: mtd_oobtest: Show the verification error location and data Date: Tue, 21 Oct 2014 16:53:27 +0300 Message-ID: <1413899608-3911-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1413899608-3911-1-git-send-email-rogerq@ti.com> References: <1413899608-3911-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add a function memcmpshow() that compares the 2 data buffers and shows the address:offset and data bytes on comparison failure. This function does not break at a comparison failure but runs the check for the whole data buffer. Use memcmpshow() instead of memcmp() for all the verification paths. Signed-off-by: Roger Quadros Signed-off-by: Sekhar Nori --- drivers/mtd/tests/oobtest.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/tests/oobtest.c b/drivers/mtd/tests/oobtest.c index dc4f960..edd859d 100644 --- a/drivers/mtd/tests/oobtest.c +++ b/drivers/mtd/tests/oobtest.c @@ -115,6 +115,26 @@ static int write_whole_device(void) return 0; } +/* Display the address, offset and data bytes at comparison failure */ +static int memcmpshow(loff_t addr, const void *cs, const void *ct, size_t count) +{ + const unsigned char *su1, *su2; + int res; + int ret = 0; + size_t i = 0; + + for (su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--, i++) { + res = *su1 ^ *su2; + if (res) { + pr_info("error @addr[0x%lx:0x%x] 0x%x -> 0x%x diff 0x%x\n", + (unsigned long)addr, i, *su1, *su2, res); + ret = 1; + } + } + + return ret; +} + static int verify_eraseblock(int ebnum) { int i; @@ -139,8 +159,9 @@ static int verify_eraseblock(int ebnum) errcnt += 1; return err ? err : -1; } - if (memcmp(readbuf, writebuf + (use_len_max * i) + use_offset, - use_len)) { + if (memcmpshow(addr, readbuf, + writebuf + (use_len_max * i) + use_offset, + use_len)) { pr_err("error: verify failed at %#llx\n", (long long)addr); errcnt += 1; @@ -167,9 +188,9 @@ static int verify_eraseblock(int ebnum) errcnt += 1; return err ? err : -1; } - if (memcmp(readbuf + use_offset, - writebuf + (use_len_max * i) + use_offset, - use_len)) { + if (memcmpshow(addr, readbuf + use_offset, + writebuf + (use_len_max * i) + use_offset, + use_len)) { pr_err("error: verify failed at %#llx\n", (long long)addr); errcnt += 1; @@ -233,7 +254,7 @@ static int verify_eraseblock_in_one_go(int ebnum) errcnt += 1; return err ? err : -1; } - if (memcmp(readbuf, writebuf, len)) { + if (memcmpshow(addr, readbuf, writebuf, len)) { pr_err("error: verify failed at %#llx\n", (long long)addr); errcnt += 1; @@ -610,7 +631,8 @@ static int __init mtd_oobtest_init(void) err = mtd_read_oob(mtd, addr, &ops); if (err) goto out; - if (memcmp(readbuf, writebuf, mtd->ecclayout->oobavail * 2)) { + if (memcmpshow(addr, readbuf, writebuf, + mtd->ecclayout->oobavail * 2)) { pr_err("error: verify failed at %#llx\n", (long long)addr); errcnt += 1;