From patchwork Mon Sep 6 08:54:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 63901 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 7903DB70EE for ; Mon, 6 Sep 2010 18:56:34 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OsXU4-0000ow-NU; Mon, 06 Sep 2010 08:55:24 +0000 Received: from smtp.nokia.com ([192.100.122.230] helo=mgw-mx03.nokia.com) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1OsXU0-0000lv-NF for linux-mtd@lists.infradead.org; Mon, 06 Sep 2010 08:55:21 +0000 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o868t1Y3013941; Mon, 6 Sep 2010 11:55:16 +0300 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 6 Sep 2010 11:55:15 +0300 Received: from mgw-da01.ext.nokia.com ([147.243.128.24]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 6 Sep 2010 11:55:09 +0300 Received: from eru.research.nokia.com (helruo-dhcp022138.ntc.nokia.com [172.21.22.138]) by mgw-da01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o868srr0018627; Mon, 6 Sep 2010 11:55:06 +0300 From: Artem Bityutskiy To: linux-mtd@lists.infradead.org Subject: [PATCH 08/13] UBI: separate out corrupted list Date: Mon, 6 Sep 2010 11:54:52 +0300 Message-Id: <1283763293-1882-9-git-send-email-dedekind1@gmail.com> X-Mailer: git-send-email 1.7.1.1 In-Reply-To: <1283763293-1882-1-git-send-email-dedekind1@gmail.com> References: <1283763293-1882-1-git-send-email-dedekind1@gmail.com> X-OriginalArrivalTime: 06 Sep 2010 08:55:09.0521 (UTC) FILETIME=[35A41410:01CB4DA1] X-Nokia-AV: Clean X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100906_045521_132567_4782BCD6 X-CRM114-Status: GOOD ( 14.37 ) X-Spam-Score: 1.1 (+) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is freemail (dedekind1[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 2.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [192.100.122.230 listed in list.dnswl.org] 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL Cc: Matthieu CASTET , "Matthew L. Creech" 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: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Artem Bityutskiy This patch introduces 'add_corrupted()' function and separates out 'corr' list manipulation from the common 'add_to_list()' function. This is just a preparation for further changes - this patch does not change functionality. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/scan.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 34 insertions(+), 11 deletions(-) diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 9405e24..fba3dc6 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c @@ -64,9 +64,9 @@ static struct ubi_vid_hdr *vidh; * @ec: erase counter of the physical eraseblock * @list: the list to add to * - * This function adds physical eraseblock @pnum to free, erase, corrupted or - * alien lists. Returns zero in case of success and a negative error code in - * case of failure. + * This function adds physical eraseblock @pnum to free, erase, or alien lists. + * Returns zero in case of success and a negative error code in case of + * failure. */ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, struct list_head *list) @@ -79,9 +79,6 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, } else if (list == &si->erase) { dbg_bld("add to erase: PEB %d, EC %d", pnum, ec); si->erase_peb_count += 1; - } else if (list == &si->corr) { - dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); - si->corr_peb_count += 1; } else if (list == &si->alien) { dbg_bld("add to alien: PEB %d, EC %d", pnum, ec); si->alien_peb_count += 1; @@ -99,6 +96,33 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec, } /** + * add_corrupted - add a corrupted physical eraseblock. + * @si: scanning information + * @pnum: physical eraseblock number to add + * @ec: erase counter of the physical eraseblock + * + * This function adds corrupted physical eraseblock @pnum to the 'corr' list. + * Returns zero in case of success and a negative error code in case of + * failure. + */ +static int add_corrupted(struct ubi_scan_info *si, int pnum, int ec) +{ + struct ubi_scan_leb *seb; + + dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec); + + seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL); + if (!seb) + return -ENOMEM; + + si->corr_peb_count += 1; + seb->pnum = pnum; + seb->ec = ec; + list_add(&seb->u.list, &si->corr); + return 0; +} + +/** * validate_vid_hdr - check volume identifier header. * @vid_hdr: the volume identifier header to check * @sv: information about the volume this logical eraseblock belongs to @@ -464,8 +488,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, return err; if (cmp_res & 4) - err = add_to_list(si, seb->pnum, seb->ec, - &si->corr); + err = add_corrupted(si, seb->pnum, seb->ec); else err = add_to_list(si, seb->pnum, seb->ec, &si->erase); @@ -488,7 +511,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, * previously. */ if (cmp_res & 4) - return add_to_list(si, pnum, ec, &si->corr); + return add_corrupted(si, pnum, ec); else return add_to_list(si, pnum, ec, &si->erase); } @@ -835,13 +858,13 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, si->read_err_count += 1; case UBI_IO_BAD_HDR: case UBI_IO_FF_BITFLIPS: - err = add_to_list(si, pnum, ec, &si->corr); + err = add_corrupted(si, pnum, ec); if (err) return err; goto adjust_mean_ec; case UBI_IO_FF: if (ec_err) - err = add_to_list(si, pnum, ec, &si->corr); + err = add_corrupted(si, pnum, ec); else err = add_to_list(si, pnum, ec, &si->free); if (err)