From patchwork Sat Jan 30 15:02:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 44070 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 A9CB6B7CE6 for ; Sun, 31 Jan 2010 02:16:41 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NbF1J-0006w6-Fi; Sat, 30 Jan 2010 15:13:57 +0000 Received: from fg-out-1718.google.com ([72.14.220.154]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1NbEr2-0006ac-Sc for linux-mtd@lists.infradead.org; Sat, 30 Jan 2010 15:03:28 +0000 Received: by fg-out-1718.google.com with SMTP id e21so15590fga.0 for ; Sat, 30 Jan 2010 07:03:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=cAv166eBUIBvELjRm93jPkUpoVPb6RVpo3Nl88beK7E=; b=Ds0UkSKtInpRGafjJ491WOTs8iLZCZnBRky1lyW4Mk76ljqBuJjTO3ZT+DfPVyKpv6 GA+DAB3Q+ZsCf7suT5wwXHyzXG6iuJ/asPhRD4Uvl6C8ou7L5C6iKG4H9julC4JQV5ew Vnu9tc29bVaRiCFbSFTy7GCRQZ1/F+q3RxZJs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=ZCBoyZzkLbOLmXyYsGnQEzl5/QXh7JRl5zLiUx3OF0CiWlKDNfDi8KFSoh+uqgwddZ OpBnBZG9Bk1q90e3dn/3kva5oNooapUbCIXwq9kuBxizfOsjK8du2UQdSlRy2MeiWxBY VOhvJxRC9DnxkYIXlFk2euI6OGo+xvRdCg0yc= Received: by 10.87.69.20 with SMTP id w20mr3523375fgk.78.1264863800536; Sat, 30 Jan 2010 07:03:20 -0800 (PST) Received: from localhost.localdomain (IGLD-84-229-248-49.inter.net.il [84.229.248.49]) by mx.google.com with ESMTPS id l19sm4125281fgb.0.2010.01.30.07.03.19 (version=SSLv3 cipher=RC4-MD5); Sat, 30 Jan 2010 07:03:20 -0800 (PST) From: Maxim Levitsky To: David Woodhouse Subject: [PATCH 11/17] MTD: nand: fix bug that prevented write of more that one page by ->write_oob Date: Sat, 30 Jan 2010 17:02:42 +0200 Message-Id: <1264863768-27606-12-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1264863768-27606-1-git-send-email-maximlevitsky@gmail.com> References: <1264863768-27606-1-git-send-email-maximlevitsky@gmail.com> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100130_100321_034125_0F6032E1 X-CRM114-Status: GOOD ( 14.45 ) 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: Maxim Levitsky , Alex Dubov , Artem Bityutskiy , joern , linux-kernel , linux-mtd , Thomas Gleixner 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 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);