From patchwork Fri Jan 22 15:59:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 43491 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 574DCB7CB6 for ; Sat, 23 Jan 2010 03:01:20 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NYLux-0007nF-KZ; Fri, 22 Jan 2010 15:59:27 +0000 Received: from mail-bw0-f212.google.com ([209.85.218.212]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NYLus-0007li-3x for linux-mtd@lists.infradead.org; Fri, 22 Jan 2010 15:59:26 +0000 Received: by bwz4 with SMTP id 4so1297934bwz.2 for ; Fri, 22 Jan 2010 07:59:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=37q7i7XOQjrVbmsGREsah4++wnX5haX3cTGPCHhQppI=; b=Xx56Nqg95pV7Whsgr04APxruYWhgb6FLIlEpghIJCRqwgxvIU3cHmCH5Y2jp0d28Dp olNsiAtOh7LK8ab03u0i2I0zXymv8mzBzanVteCTu9q0VVQFju9mrD8mAJ7U0zfORBlt QTR2i/pNGWfaItaPGnWzxQNLXsY7Usn/Pe61w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=GDTPKZtQ078tBwEvghO/nTPxZwAE5wjEaI6guJz/zTqAfu/ZK2/GduVlAqp80jB83m UDfBGRP9p7oYFXhXDAoD++JepIeI1smp+GrfvkSdW90glpshAopdp+sLJa9x9eZhVpf2 bYjtDq30wTEd2aAvC49mfp0TobfGD77r1o6IU= Received: by 10.204.160.147 with SMTP id n19mr636045bkx.182.1264175960980; Fri, 22 Jan 2010 07:59:20 -0800 (PST) Received: from ?10.1.0.2? ([87.70.246.165]) by mx.google.com with ESMTPS id 14sm1033685bwz.9.2010.01.22.07.59.18 (version=SSLv3 cipher=RC4-MD5); Fri, 22 Jan 2010 07:59:20 -0800 (PST) Subject: [PATCH 3/6] MTD: nand: fix bug that prevented write of more that one page by ->write_oob From: Maxim Levitsky To: David Woodhouse In-Reply-To: <1264175781.24012.42.camel@maxim-laptop> References: <1264175781.24012.42.camel@maxim-laptop> Date: Fri, 22 Jan 2010 17:59:15 +0200 Message-ID: <1264175955.24012.45.camel@maxim-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100122_105922_331606_1F7B1761 X-CRM114-Status: GOOD ( 15.06 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: Thomas Gleixner , joern , linux-mtd , linux-kernel , Alex Dubov 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 >From ed559063edac36892098915c8e4747ad74203b91 Mon Sep 17 00:00:00 2001 From: Maxim Levitsky Date: Fri, 22 Jan 2010 16:41:33 +0200 Subject: [PATCH 3/6] MTD: nand: fix bug that prevented write of more that one page by ->write_oob Although nand_do_write_ops intends to allow such mode, it fails do do so Probably this was never tested Signed-off-by: Maxim Levitsky --- drivers/mtd/nand/nand_base.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 8ff36be..29e986e 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -1879,11 +1879,9 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, * @oob: oob data buffer * @ops: oob ops structure */ -static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob, - struct mtd_oob_ops *ops) +static uint8_t *nand_fill_oob(struct nand_chip *chip, uint8_t *oob, size_t len, + struct mtd_oob_ops *ops) { - size_t len = ops->ooblen; - switch(ops->mode) { case MTD_OOB_PLACE: @@ -1938,6 +1936,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, int chipnr, realpage, page, blockmask, column; struct nand_chip *chip = mtd->priv; uint32_t writelen = ops->len; + uint32_t oobwritelen = ops->ooblen; uint8_t *oob = ops->oobbuf; uint8_t *buf = ops->datbuf; int ret, subpage; @@ -1994,8 +1993,11 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, wbuf = chip->buffers->databuf; } - if (unlikely(oob)) - oob = nand_fill_oob(chip, oob, ops); + if (unlikely(oob)) { + size_t len = min(oobwritelen, mtd->oobsize); + oob = nand_fill_oob(chip, oob, len, ops); + oobwritelen -= len; + } ret = chip->write_page(mtd, chip, wbuf, page, cached, (ops->mode == MTD_OOB_RAW)); @@ -2169,7 +2171,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, chip->pagebuf = -1; memset(chip->oob_poi, 0xff, mtd->oobsize); - nand_fill_oob(chip, ops->oobbuf, ops); + nand_fill_oob(chip, ops->oobbuf, ops->ooblen, ops); status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask); memset(chip->oob_poi, 0xff, mtd->oobsize);