public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Detlev Zundel <dzu@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/5] nand_util: convert nand_write_skip_bad() to flags
Date: Fri, 29 Apr 2011 13:44:46 +0200	[thread overview]
Message-ID: <m2liyt5ljl.fsf@ohwell.denx.de> (raw)
In-Reply-To: <9dc5db5312babdb5b3200e84aace3108fabac9c6.1304026883.git.bengardiner@nanometrics.ca> (Ben Gardiner's message of "Thu, 28 Apr 2011 17:47:52 -0400")

Hi Ben,

> In a future commit the behaviour of nand_write_skip_bad()
> will be further extended.
>
> Convert the only flag currently passed to the nand_write_
> skip_bad() function to a bitfield of only one allocated
> member. This should avoid an explosion of int's at the
> end of the parameter list or the ambiguous calls like
>
> nand_write_skip_bad(info, offset, len, buf, 0, 1, 1);
> nand_write_skip_bad(info, offset, len, buf, 0, 1, 0);
>
> Instead there will be:
>
> nand_write_skip_bad(info, offset, len, buf, WITH_OOB |
> 			WITH_OTHER);
>
> Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
> ---
>  common/cmd_nand.c            |    3 ++-
>  drivers/mtd/nand/nand_util.c |    8 ++++----
>  include/nand.h               |    5 ++++-
>  3 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/common/cmd_nand.c b/common/cmd_nand.c
> index 7bd37de..69b2acc 100644
> --- a/common/cmd_nand.c
> +++ b/common/cmd_nand.c
> @@ -581,7 +581,8 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
>  				printf("Unknown nand command suffix '%s'.\n", s);
>  				return 1;
>  			}
> -			ret = nand_write_skip_bad(nand, off, &rwsize, (u_char *)addr, 1);
> +			ret = nand_write_skip_bad(nand, off, &rwsize,
> +						(u_char *)addr, WITH_OOB);
>  #endif
>  		} else if (!strcmp(s, ".oob")) {
>  			/* out-of-band data */

I see an occurrence of nand_write_skip_bad just above this if block.
Please replace this also.

> diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
> index 5a6f7ae..2bd8758 100644
> --- a/drivers/mtd/nand/nand_util.c
> +++ b/drivers/mtd/nand/nand_util.c
> @@ -448,11 +448,11 @@ static int check_skip_len(nand_info_t *nand, loff_t offset, size_t length)
>   * @param offset	offset in flash
>   * @param length	buffer length
>   * @param buffer        buffer to read from
> - * @param withoob	whether write with yaffs format
> + * @param flags		flags mmofying the behaviour of the write to NAND
>   * @return		0 in case of success
>   */
>  int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
> -			u_char *buffer, int withoob)
> +			u_char *buffer, int flags)
>  {
>  	int rval = 0, blocksize;
>  	size_t left_to_write = *length;
> @@ -460,7 +460,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
>  	int need_skip;
>  
>  #ifdef CONFIG_CMD_NAND_YAFFS
> -	if (withoob) {
> +	if (flags & WITH_OOB) {
>  		int pages;
>  		pages = nand->erasesize / nand->writesize;
>  		blocksize = (pages * nand->oobsize) + nand->erasesize;
> @@ -529,7 +529,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
>  			write_size = blocksize - block_offset;
>  
>  #ifdef CONFIG_CMD_NAND_YAFFS
> -		if (withoob) {
> +		if (flags & WITH_OOB) {
>  			int page, pages;
>  			size_t pagesize = nand->writesize;
>  			size_t pagesize_oob = pagesize + nand->oobsize;
> diff --git a/include/nand.h b/include/nand.h
> index 7459bd0..628317a 100644
> --- a/include/nand.h
> +++ b/include/nand.h
> @@ -114,8 +114,11 @@ 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_OOB (1 << 0) /* whether write with yaffs format */
> +

If this flag is really only relevant for YAFFS, then please include this
in its name, i.e. rename it to "WITH_YAFFS_OOB".

>  int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
> -			u_char *buffer, int withoob);
> +			u_char *buffer, int flags);
>  int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts);
>  
>  #define NAND_LOCK_STATUS_TIGHT	0x01

Cheers
  Detlev

-- 
 Those who do not understand Unix are condemned to reinvent it,
 poorly.
 - Henry Spencer, University of Toronto Unix hack
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de

  reply	other threads:[~2011-04-29 11:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-28 21:47 [U-Boot] [PATCH 0/5] introduce nand write.ubi, and drop ffs for jffs2 too Ben Gardiner
2011-04-28 21:47 ` [U-Boot] [PATCH 1/5] nand_base: trivial: fix comment read/write comment Ben Gardiner
2011-04-28 21:47 ` [U-Boot] [PATCH 2/5] nand_util: convert nand_write_skip_bad() to flags Ben Gardiner
2011-04-29 11:44   ` Detlev Zundel [this message]
2011-04-28 21:47 ` [U-Boot] [PATCH 3/5] nand_util: drop trailing all-0xff pages if requested Ben Gardiner
2011-04-28 21:47 ` [U-Boot] [PATCH 4/5] cmd_nand: add nand write.ubi command Ben Gardiner
2011-04-29 11:52   ` Detlev Zundel
2011-04-28 21:47 ` [U-Boot] [PATCH 5/5] cmd_nand: also drop 0xff pages for jffs2 Ben Gardiner
2011-04-29 11:58 ` [U-Boot] [PATCH 0/5] introduce nand write.ubi, and drop ffs for jffs2 too Detlev Zundel
2011-04-29 13:59   ` Artem Bityutskiy
2011-05-02 13:14     ` Detlev Zundel
2011-05-11 21:04       ` Ben Gardiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2liyt5ljl.fsf@ohwell.denx.de \
    --to=dzu@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox