From patchwork Tue Jun 14 20:35:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardiner X-Patchwork-Id: 100436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B1A15B6F9B for ; Wed, 15 Jun 2011 06:35:26 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4AC2E28109; Tue, 14 Jun 2011 22:35:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HhkihyEbM0MU; Tue, 14 Jun 2011 22:35:22 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 28F65280FB; Tue, 14 Jun 2011 22:35:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 95431280FB for ; Tue, 14 Jun 2011 22:35:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IuL-BHsi7FYs for ; Tue, 14 Jun 2011 22:35:16 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from na3sys009aog110.obsmtp.com (na3sys009aog110.obsmtp.com [74.125.149.203]) by theia.denx.de (Postfix) with ESMTPS id 1ED04280F8 for ; Tue, 14 Jun 2011 22:35:14 +0200 (CEST) Received: from mail-pz0-f46.google.com ([209.85.210.46]) (using TLSv1) by na3sys009aob110.postini.com ([74.125.148.12]) with SMTP ID DSNKTffGAYjN2U/ane/1n99LqMB6eqbsKJ9q@postini.com; Tue, 14 Jun 2011 13:35:16 PDT Received: by mail-pz0-f46.google.com with SMTP id 9so3425568pzk.5 for ; Tue, 14 Jun 2011 13:35:13 -0700 (PDT) Received: by 10.68.39.38 with SMTP id m6mr3441199pbk.150.1308083713144; Tue, 14 Jun 2011 13:35:13 -0700 (PDT) Received: from localhost.localdomain ([206.191.47.130]) by mx.google.com with ESMTPS id x1sm5838021pbb.34.2011.06.14.13.35.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2011 13:35:12 -0700 (PDT) From: Ben Gardiner To: Scott Wood , u-boot@lists.denx.de Date: Tue, 14 Jun 2011 16:35:05 -0400 Message-Id: <0f8d8f4d66625d5117a8f4225ca3e99d43899208.1308083237.git.bengardiner@nanometrics.ca> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: References: <20110607113405.3e395910@schlenkerla.am.freescale.net> Subject: [U-Boot] [PATCH 1/3] [v4] nand_util: treat WITH_YAFFS_OOB as a mode X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de When specified in the flags argument of nand_write, WITH_YAFFS_OOB causes an operation which is mutually exclusive with the 'usual' way of writing. Add a check that client code does not specify WITH_YAFFS_OOB along with any other flags and add a comment indicating that the WITH_YAFFS_OOB flag should not be mixed with other flags. Signed-off-by: Ben Gardiner CC: Scott Wood --- Changes since v3: * none. This patch was introduced in v4 to adress Scott Wood's v3 review comments. --- drivers/mtd/nand/nand_util.c | 3 +++ include/nand.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index 762ac53..e4ef858 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -461,6 +461,9 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, #ifdef CONFIG_CMD_NAND_YAFFS if (flags & WITH_YAFFS_OOB) { + if (flags & ~WITH_YAFFS_OOB) + return -EINVAL; + int pages; pages = nand->erasesize / nand->writesize; blocksize = (pages * nand->oobsize) + nand->erasesize; diff --git a/include/nand.h b/include/nand.h index b0a31b8..c5818f1 100644 --- a/include/nand.h +++ b/include/nand.h @@ -115,7 +115,9 @@ typedef struct nand_erase_options nand_erase_options_t; int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, u_char *buffer); -#define WITH_YAFFS_OOB (1 << 0) /* whether write with yaffs format */ +#define WITH_YAFFS_OOB (1 << 0) /* whether write with yaffs format. This flag + * is a 'mode' meaning it cannot be mixed with + * other flags */ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, u_char *buffer, int flags);