]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
nand_util: convert nand_write_skip_bad() to flags
authorBen Gardiner <bengardiner@nanometrics.ca>
Tue, 24 May 2011 14:18:35 +0000 (10:18 -0400)
committerScott Wood <scottwood@freescale.com>
Fri, 1 Jul 2011 20:56:51 +0000 (15:56 -0500)
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_YAFFS_OOB |
WITH_OTHER);

Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Acked-by: Detlev Zundel <dzu@denx.de>
Signed-off-by: Scott Wood <scottwood@freescale.com>
common/cmd_nand.c
drivers/mtd/nand/nand_util.c
include/nand.h

index 44c4d1f89ce2b2e189d275ee297e7090835f5805..27a88796eec613aa6d70b2fd016f9f2c177a04c4 100644 (file)
@@ -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_YAFFS_OOB);
 #endif
                } else if (!strcmp(s, ".oob")) {
                        /* out-of-band data */
index 5a6f7aec8884bb9af295fe3dd8d04bb534faf505..762ac53287d721b5fc303d95dc94532187b69992 100644 (file)
@@ -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 modifying 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_YAFFS_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_YAFFS_OOB) {
                        int page, pages;
                        size_t pagesize = nand->writesize;
                        size_t pagesize_oob = pagesize + nand->oobsize;
index 7459bd0330a1b16f9153b8e1ee3dc2134739bf63..b0a31b8f0205880f4464b2a8e99294a1662a8309 100644 (file)
@@ -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_YAFFS_OOB (1 << 0) /* whether write with yaffs format */
+
 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