Merge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
authorTimothy Manning <tfhmanning@gmail.com>
Mon, 10 Jan 2011 23:23:05 +0000 (12:23 +1300)
committerTimothy Manning <tfhmanning@gmail.com>
Mon, 10 Jan 2011 23:23:05 +0000 (12:23 +1300)
14 files changed:
direct/yaffsfs.c
direct/ydirectenv.h
yaffs_guts.c
yaffs_mtdif1_multi.c
yaffs_mtdif1_single.c
yaffs_nand.c
yaffs_tagscompat.c
yaffs_verify.c
yaffs_vfs_multi.c
yaffs_vfs_single.c
yaffs_yaffs1.c
yaffs_yaffs2.c
yportenv_multi.h
yportenv_single.h

index e3bc19d7fcfca36108ec07c68e748ecae413341c..e4f6df07565dfd5e1fe776425f1a92266c081014 100644 (file)
@@ -650,13 +650,11 @@ static struct yaffs_obj *yaffsfs_DoFindDirectory(struct yaffs_obj *startDir,
                        /* got to the end of the string */
                        return dir;
                else{
-                       if(strcmp(str,_Y(".")) == 0)
-                       {
+                       if(strcmp(str,_Y(".")) == 0){
                                /* Do nothing */
-                       }
-                       else if(strcmp(str,_Y("..")) == 0)
+                       } else if(strcmp(str,_Y("..")) == 0) {
                                dir = dir->parent;
-                       else{
+                       else{
                                dir = yaffs_find_by_name(dir,str);
 
                                dir = yaffsfs_FollowLink(dir,symDepth,loop);
index 63cd6d85182b1f1b899af05a306e50a809e3a431..7063fa649fb25b4e0329ae9ff43925d45bc0d86b 100644 (file)
@@ -61,7 +61,7 @@ void yaffs_qsort(void *aa, size_t n, size_t es,
 #define cond_resched()  do {} while(0)
 
 #define yaffs_trace(msk, fmt, ...) do { \
-       if(yaffs_trace_mask & ((msk) | YAFFS_TRACE_ALWAYS)) \
+       if(yaffs_trace_mask & (msk)) \
                printf("yaffs: " fmt "\n", ##__VA_ARGS__); \
 } while(0)
 
index f4ae9deed727bb968a3db3db393a69e4986915db..486b7e05d0713fd2831a22b705f1df907883c42d 100644 (file)
@@ -1532,7 +1532,7 @@ static struct yaffs_cache *yaffs_grab_chunk_cache(struct yaffs_dev *dev)
 
                        /* With locking we can't assume we can use entry zero */
 
-                       the_obj = NULL;
+                       the_obj = dev->cache[0].object;
                        usage = -1;
                        cache = NULL;
                        pushout = -1;
@@ -1952,16 +1952,12 @@ struct yaffs_obj *yaffs_find_by_number(struct yaffs_dev *dev, u32 number)
 
        list_for_each(i, &dev->obj_bucket[bucket].list) {
                /* Look if it is in the list */
-               if (i) {
-                       in = list_entry(i, struct yaffs_obj, hash_link);
-                       if (in->obj_id == number) {
-
-                               /* Don't tell the VFS about this one if it is defered free */
-                               if (in->defered_free)
-                                       return NULL;
-
-                               return in;
-                       }
+               in = list_entry(i, struct yaffs_obj, hash_link);
+               if (in->obj_id == number) {
+                       /* Don't tell the VFS about this one if it is defered free */
+                       if (in->defered_free)
+                               return NULL;
+                       return in;
                }
        }
 
@@ -4082,11 +4078,13 @@ static int yaffs_unlink_worker(struct yaffs_obj *obj)
 
        int del_now = 0;
 
+       if(!obj)
+               return YAFFS_FAIL;
+
        if (!obj->my_inode)
                del_now = 1;
 
-       if (obj)
-               yaffs_update_parent(obj->parent);
+       yaffs_update_parent(obj->parent);
 
        if (obj->variant_type == YAFFS_OBJECT_TYPE_HARDLINK) {
                return yaffs_del_link(obj);
@@ -4496,29 +4494,26 @@ struct yaffs_obj *yaffs_find_by_name(struct yaffs_obj *directory,
        sum = yaffs_calc_name_sum(name);
 
        list_for_each(i, &directory->variant.dir_variant.children) {
-               if (i) {
-                       l = list_entry(i, struct yaffs_obj, siblings);
+               l = list_entry(i, struct yaffs_obj, siblings);
 
-                       if (l->parent != directory)
-                               YBUG();
+               if (l->parent != directory)
+                       YBUG();
 
-                       yaffs_check_obj_details_loaded(l);
+               yaffs_check_obj_details_loaded(l);
 
-                       /* Special case for lost-n-found */
-                       if (l->obj_id == YAFFS_OBJECTID_LOSTNFOUND) {
-                               if (!strcmp(name, YAFFS_LOSTNFOUND_NAME))
-                                       return l;
-                       } else if (l->sum == sum
-                                  || l->hdr_chunk <= 0) {
-                               /* LostnFound chunk called Objxxx
-                                * Do a real check
-                                */
-                               yaffs_get_obj_name(l, buffer,
-                                                  YAFFS_MAX_NAME_LENGTH + 1);
-                               if (strncmp
-                                   (name, buffer, YAFFS_MAX_NAME_LENGTH) == 0)
-                                       return l;
-                       }
+               /* Special case for lost-n-found */
+               if (l->obj_id == YAFFS_OBJECTID_LOSTNFOUND) {
+                       if (!strcmp(name, YAFFS_LOSTNFOUND_NAME))
+                               return l;
+               } else if (l->sum == sum
+                          || l->hdr_chunk <= 0) {
+                       /* LostnFound chunk called Objxxx
+                        * Do a real check
+                        */
+                       yaffs_get_obj_name(l, buffer,
+                               YAFFS_MAX_NAME_LENGTH + 1);
+                       if (strncmp(name, buffer, YAFFS_MAX_NAME_LENGTH) == 0)
+                               return l;
                }
        }
 
index 603dc97a9f25670682b9d115a94404fa09aaf21c..cf9c54cce23a98aa92a3b130edd21e9b9a6451a1 100644 (file)
@@ -238,7 +238,7 @@ int nandmtd1_read_chunk_tags(struct yaffs_dev *dev,
        deleted = !pt1.deleted;
        pt1.deleted = 1;
 #else
-       deleted = (yaffs_count_bits(((u8 *) & pt1)[8]) < 7);
+       deleted = (hweight8(((u8 *) & pt1)[8]) < 7);
 #endif
 
        /* Check the packed tags mini-ECC and correct if necessary/possible.
index 51083695eb3347eea20734317ac27d2b276338e8..740f7f64d4d0f039337f4df7025cc6081d206d5c 100644 (file)
@@ -207,7 +207,7 @@ int nandmtd1_read_chunk_tags(struct yaffs_dev *dev,
        deleted = !pt1.deleted;
        pt1.deleted = 1;
 #else
-       deleted = (yaffs_count_bits(((u8 *) & pt1)[8]) < 7);
+       deleted = (hweight8(((u8 *) & pt1)[8]) < 7);
 #endif
 
        /* Check the packed tags mini-ECC and correct if necessary/possible.
index e816cabf43f8e9b588a435c6198e85165ca98411..25b5213a436e75e06b8bf6ee77a4061b3e333a17 100644 (file)
@@ -72,6 +72,7 @@ int yaffs_wr_chunk_tags_nand(struct yaffs_dev *dev,
        } else {
                yaffs_trace(YAFFS_TRACE_ERROR, "Writing with no tags");
                YBUG();
+               return YAFFS_FAIL;
        }
 
        if (dev->param.write_chunk_tags_fn)
index 7578075d9ac10a26dca7ff93a9e4d6735795c8a2..818f72bbc64c17ea8f47cc61133289f3c386dff1 100644 (file)
@@ -151,7 +151,7 @@ static int yaffs_rd_chunk_nand(struct yaffs_dev *dev,
        int ret_val;
        struct yaffs_spare local_spare;
 
-       if (!spare && data) {
+       if (!spare) {
                /* If we don't have a real spare, then we use a local one. */
                /* Need this for the calculation of the ecc */
                spare = &local_spare;
@@ -290,7 +290,7 @@ int yaffs_tags_compat_wr(struct yaffs_dev *dev,
        struct yaffs_tags tags;
 
        yaffs_spare_init(&spare);
-
+        
        if (ext_tags->is_deleted)
                spare.page_status = 0;
        else {
index 738c7f69a5ec1de2c10d0fcc0d77cc7d82d52917..55884b97484726beb2d3060ee74e5000d1e289a1 100644 (file)
@@ -163,8 +163,8 @@ void yaffs_verify_blocks(struct yaffs_dev *dev)
 }
 
 /*
- * Verify the object header. oh must be valid, but obj and tags may be NULL in which
- * case those tests will not be performed.
+ * Verify the object header. oh must be valid, but obj and tags may be NULL in
+ * which case those tests will not be performed.
  */
 void yaffs_verify_oh(struct yaffs_obj *obj, struct yaffs_obj_hdr *oh,
                     struct yaffs_ext_tags *tags, int parent_check)
@@ -414,11 +414,8 @@ void yaffs_verify_objects(struct yaffs_dev *dev)
 
        for (i = 0; i < YAFFS_NOBJECT_BUCKETS; i++) {
                list_for_each(lh, &dev->obj_bucket[i].list) {
-                       if (lh) {
-                               obj =
-                                   list_entry(lh, struct yaffs_obj, hash_link);
-                               yaffs_verify_obj(obj);
-                       }
+                       obj = list_entry(lh, struct yaffs_obj, hash_link);      
+                       yaffs_verify_obj(obj);
                }
        }
 }
@@ -453,12 +450,10 @@ void yaffs_verify_obj_in_dir(struct yaffs_obj *obj)
        /* Iterate through the objects in each hash entry */
 
        list_for_each(lh, &obj->parent->variant.dir_variant.children) {
-               if (lh) {
-                       list_obj = list_entry(lh, struct yaffs_obj, siblings);
-                       yaffs_verify_obj(list_obj);
-                       if (obj == list_obj)
-                               count++;
-               }
+               list_obj = list_entry(lh, struct yaffs_obj, siblings);
+               yaffs_verify_obj(list_obj);
+               if (obj == list_obj)
+                       count++;
        }
 
        if (count != 1) {
@@ -492,16 +487,14 @@ void yaffs_verify_dir(struct yaffs_obj *directory)
        /* Iterate through the objects in each hash entry */
 
        list_for_each(lh, &directory->variant.dir_variant.children) {
-               if (lh) {
-                       list_obj = list_entry(lh, struct yaffs_obj, siblings);
-                       if (list_obj->parent != directory) {
-                               yaffs_trace(YAFFS_TRACE_ALWAYS,
-                                       "Object in directory list has wrong parent %p",
-                                       list_obj->parent);
-                               YBUG();
-                       }
-                       yaffs_verify_obj_in_dir(list_obj);
+               list_obj = list_entry(lh, struct yaffs_obj, siblings);
+               if (list_obj->parent != directory) {
+                       yaffs_trace(YAFFS_TRACE_ALWAYS,
+                               "Object in directory list has wrong parent %p",
+                               list_obj->parent);
+                       YBUG();
                }
+               yaffs_verify_obj_in_dir(list_obj);
        }
 }
 
index 85df2d75ff1ead531a1a5d0c66b6f845d76c2974..78e2f9f6ac837ce52421b280ee1f713f27ec7cb4 100644 (file)
@@ -692,11 +692,9 @@ static void yaffs_remove_obj_callback(struct yaffs_obj *obj)
         * the search context to the next object to prevent a hanging pointer.
         */
        list_for_each(i, search_contexts) {
-               if (i) {
-                       sc = list_entry(i, struct yaffs_search_context, others);
-                       if (sc->next_return == obj)
-                               yaffs_search_advance(sc);
-               }
+               sc = list_entry(i, struct yaffs_search_context, others);
+               if (sc->next_return == obj)
+                       yaffs_search_advance(sc);
        }
 
 }
@@ -866,7 +864,7 @@ static void yaffs_evict_inode(struct inode *inode)
        yaffs_trace(YAFFS_TRACE_OS,
                "yaffs_evict_inode: ino %d, count %d %s",
                (int)inode->i_ino, atomic_read(&inode->i_count),
-               obj ? "object exists" : "null object"));
+               obj ? "object exists" : "null object");
 
        if (!inode->i_nlink && !is_bad_inode(inode))
                deleteme = 1;
@@ -1421,6 +1419,12 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
 
        obj = yaffs_dentry_to_obj(f->f_dentry);
 
+       if (!obj) {
+               yaffs_trace(YAFFS_TRACE_OS,
+                       "yaffs_file_write: hey obj is null!");
+                return -EINVAL;
+        }
+
        dev = obj->my_dev;
 
        yaffs_gross_lock(dev);
@@ -1432,13 +1436,9 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
        else
                ipos = *pos;
 
-       if (!obj)
-               yaffs_trace(YAFFS_TRACE_OS,
-                       "yaffs_file_write: hey obj is null!");
-       else
-               yaffs_trace(YAFFS_TRACE_OS,
-                       "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
-                       (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
+       yaffs_trace(YAFFS_TRACE_OS,
+               "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
+               (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
 
        n_written = yaffs_wr_file(obj, buf, ipos, n, 0);
 
@@ -2623,6 +2623,11 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        struct yaffs_linux_context *context_iterator;
        struct list_head *l;
 
+       if (!sb) {
+               printk(KERN_INFO "yaffs: sb is NULL\n");
+               return NULL;
+        }
+
        sb->s_magic = YAFFS_MAGIC;
        sb->s_op = &yaffs_super_ops;
        sb->s_flags |= MS_NOATIME;
@@ -2633,9 +2638,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        sb->s_export_op = &yaffs_export_ops;
 #endif
 
-       if (!sb)
-               printk(KERN_INFO "yaffs: sb is NULL\n");
-       else if (!sb->s_dev)
+       if (!sb->s_dev)
                printk(KERN_INFO "yaffs: sb->s_dev is NULL\n");
        else if (!yaffs_devname(sb, devname_buf))
                printk(KERN_INFO "yaffs: devname is NULL\n");
index d5b875314005a36afe115ba7abd656bf6b3eff39..1893125d338f4322ec27bde53a4e1839b1b67cc5 100644 (file)
@@ -59,9 +59,6 @@
 
 #include <linux/statfs.h>
 
-#define UnlockPage(p) unlock_page(p)
-#define Page_Uptodate(page)    test_bit(PG_uptodate, &(page)->flags)
-
 #define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf)
 
 #define YPROC_ROOT  NULL
@@ -786,11 +783,9 @@ static void yaffs_remove_obj_callback(struct yaffs_obj *obj)
         * the search context to the next object to prevent a hanging pointer.
         */
        list_for_each(i, search_contexts) {
-               if (i) {
-                       sc = list_entry(i, struct yaffs_search_context, others);
-                       if (sc->next_return == obj)
-                               yaffs_search_advance(sc);
-               }
+               sc = list_entry(i, struct yaffs_search_context, others);
+               if (sc->next_return == obj)
+                       yaffs_search_advance(sc);
        }
 
 }
@@ -1177,7 +1172,7 @@ static int yaffs_readpage_nolock(struct file *f, struct page *pg)
 static int yaffs_readpage_unlock(struct file *f, struct page *pg)
 {
        int ret = yaffs_readpage_nolock(f, pg);
-       UnlockPage(pg);
+       unlock_page(pg);
        return ret;
 }
 
@@ -1334,7 +1329,7 @@ static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
        }
        yaffs_trace(YAFFS_TRACE_OS,
                "start yaffs_write_begin index %d(%x) uptodate %d",
-               (int)index, (int)index, Page_Uptodate(pg) ? 1 : 0);
+               (int)index, (int)index, PageUptodate(pg) ? 1 : 0);
 
        /* Get fs space */
        space_held = yaffs_hold_space(filp);
@@ -1346,7 +1341,7 @@ static int yaffs_write_begin(struct file *filp, struct address_space *mapping,
 
        /* Update page if required */
 
-       if (!Page_Uptodate(pg))
+       if (!PageUptodate(pg))
                ret = yaffs_readpage_nolock(filp, pg);
 
        if (ret)
@@ -1379,6 +1374,13 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
 
        obj = yaffs_dentry_to_obj(f->f_dentry);
 
+       if (!obj) {
+               /* This should not happen */
+               yaffs_trace(YAFFS_TRACE_OS,
+                       "yaffs_file_write: hey obj is null!");
+                return -ENINVAL;
+        }
+
        dev = obj->my_dev;
 
        yaffs_gross_lock(dev);
@@ -1390,13 +1392,9 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
        else
                ipos = *pos;
 
-       if (!obj)
-               yaffs_trace(YAFFS_TRACE_OS,
-                       "yaffs_file_write: hey obj is null!");
-       else
-               yaffs_trace(YAFFS_TRACE_OS,
-                       "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
-                       (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
+       yaffs_trace(YAFFS_TRACE_OS,
+               "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
+               (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
 
        n_written = yaffs_wr_file(obj, buf, ipos, n, 0);
 
@@ -2030,6 +2028,11 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        struct yaffs_linux_context *context_iterator;
        struct list_head *l;
 
+       if (!sb) {
+               printk(KERN_INFO "yaffs: sb is NULL\n");
+               return NULL;
+        }
+
        sb->s_magic = YAFFS_MAGIC;
        sb->s_op = &yaffs_super_ops;
        sb->s_flags |= MS_NOATIME;
@@ -2038,9 +2041,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
 
        sb->s_export_op = &yaffs_export_ops;
 
-       if (!sb)
-               printk(KERN_INFO "yaffs: sb is NULL\n");
-       else if (!sb->s_dev)
+       if (!sb->s_dev)
                printk(KERN_INFO "yaffs: sb->s_dev is NULL\n");
        else if (!yaffs_devname(sb, devname_buf))
                printk(KERN_INFO "yaffs: devname is NULL\n");
index 9eb6030825475133b8c02508aec0f11aa39db6d1..c879f57f921116e14243c87692ee079aaf7737da 100644 (file)
@@ -110,7 +110,6 @@ int yaffs1_scan(struct yaffs_dev *dev)
                                 */
                                deleted++;
                                dev->n_free_chunks++;
-                               /*T((" %d %d deleted\n",blk,c)); */
                        } else if (!tags.chunk_used) {
                                /* An unassigned chunk in the block
                                 * This means that either the block is empty or
@@ -178,7 +177,6 @@ int yaffs1_scan(struct yaffs_dev *dev)
                                        }
 
                                }
-                               /* T((" %d %d data %d %d\n",blk,c,tags.obj_id,tags.chunk_id));   */
                        } else {
                                /* chunk_id == 0, so it is an ObjectHeader.
                                 * Thus, we read in the object header and make the object
index 33397af7003d1fd6249cf7769a5e7683c594e431..339f47fc6ac1cddcce1eddfdf186d3c9870f74f3 100644 (file)
@@ -568,28 +568,23 @@ static int yaffs2_wr_checkpt_objs(struct yaffs_dev *dev)
 
        for (i = 0; ok && i < YAFFS_NOBJECT_BUCKETS; i++) {
                list_for_each(lh, &dev->obj_bucket[i].list) {
-                       if (lh) {
-                               obj =
-                                   list_entry(lh, struct yaffs_obj, hash_link);
-                               if (!obj->defered_free) {
-                                       yaffs2_obj_checkpt_obj(&cp, obj);
-                                       cp.struct_type = sizeof(cp);
-
-                                       yaffs_trace(YAFFS_TRACE_CHECKPOINT,
-                                               "Checkpoint write object %d parent %d type %d chunk %d obj addr %p",
-                                               cp.obj_id, cp.parent_id,
-                                               cp.variant_type, cp.hdr_chunk, obj);
-
-                                       ok = (yaffs2_checkpt_wr
-                                             (dev, &cp,
+                       obj = list_entry(lh, struct yaffs_obj, hash_link);
+                        if (!obj->defered_free) {
+                               yaffs2_obj_checkpt_obj(&cp, obj);
+                               cp.struct_type = sizeof(cp);
+
+                               yaffs_trace(YAFFS_TRACE_CHECKPOINT,
+                                       "Checkpoint write object %d parent %d type %d chunk %d obj addr %p",
+                                       cp.obj_id, cp.parent_id,
+                                       cp.variant_type, cp.hdr_chunk, obj);
+
+                               ok = (yaffs2_checkpt_wr(dev, &cp,
                                               sizeof(cp)) == sizeof(cp));
 
-                                       if (ok
-                                           && obj->variant_type ==
-                                           YAFFS_OBJECT_TYPE_FILE)
-                                               ok = yaffs2_wr_checkpt_tnodes
-                                                   (obj);
-                               }
+                               if (ok &&
+                                       obj->variant_type ==
+                                               YAFFS_OBJECT_TYPE_FILE)
+                                        ok = yaffs2_wr_checkpt_tnodes(obj);
                        }
                }
        }
index 4dddf63ebb2469f15429cb56f518ec6dbd023a3a..10e284e8ec7b4e0271f5837f18ef04ef9973f862 100644 (file)
@@ -24,7 +24,9 @@
 
 #define MTD_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
 
+#ifdef YAFFS_OUT_OF_TREE
 #include "moduleconfig.h"
+#endif
 
 #include <linux/version.h>
 #define MTD_VERSION_CODE LINUX_VERSION_CODE
@@ -75,7 +77,7 @@
 #endif
 
 #define yaffs_trace(msk, fmt, ...) do { \
-       if(yaffs_trace_mask & ((msk) | YAFFS_TRACE_ALWAYS)) \
+       if(yaffs_trace_mask & (msk)) \
                printk(KERN_DEBUG "yaffs: " fmt "\n", ##__VA_ARGS__); \
 } while(0)
 
index 236f5793eccfdc4d099918771d332eb5c55245a0..8183425448cde06732aa5499156c661fe1314e90 100644 (file)
@@ -54,7 +54,7 @@
 #endif
 
 #define yaffs_trace(msk, fmt, ...) do { \
-       if(yaffs_trace_mask & ((msk) | YAFFS_TRACE_ALWAYS)) \
+       if(yaffs_trace_mask & (msk)) \
                printk(KERN_DEBUG "yaffs: " fmt "\n", ##__VA_ARGS__); \
 } while(0)