More clean up clean-up
authorCharles Manning <cdhmanning@gmail.com>
Mon, 16 Mar 2015 18:36:38 +0000 (07:36 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Mon, 16 Mar 2015 18:36:38 +0000 (07:36 +1300)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/u-boot/fs/yaffs2/yaffs_mtdif2.c
direct/yaffs_hweight.c
direct/yaffsfs.c
yaffs_guts.c
yaffs_yaffs1.c
yaffs_yaffs2.c

index b27fe56214d3b7fda21654ef381fe3773bdd5273..f5c0951dae4a7f451063bbcc8204dc2edef21cfd 100644 (file)
@@ -184,7 +184,7 @@ int nandmtd2_MarkNANDBlockBad(struct yaffs_dev *dev, int blockNo)
        retval =
            mtd->block_markbad(mtd,
                               blockNo * dev->param.chunks_per_block *
-                              dev->data_bytes_per_chunk);
+                              dev->param.total_bytes_per_chunk);
 
        if (retval == 0)
                return YAFFS_OK;
@@ -203,7 +203,7 @@ int nandmtd2_QueryNANDBlock(struct yaffs_dev *dev, int blockNo,
        retval =
            mtd->block_isbad(mtd,
                             blockNo * dev->param.chunks_per_block *
-                            dev->data_bytes_per_chunk);
+                            dev->param.total_bytes_per_chunk);
 
        if (retval) {
                yaffs_trace(YAFFS_TRACE_MTD, "block is bad");
index 7e2c250a598138d59a904af52d94c0d02c61fa51..89d7f842a7b56e29e44265550ed67905c1a5be7a 100644 (file)
@@ -38,16 +38,15 @@ static const char yaffs_count_bits_table[256] = {
 
 int yaffs_hweight8(u8 x)
 {
-       int ret_val;
-       ret_val = yaffs_count_bits_table[x];
-       return ret_val;
+       return yaffs_count_bits_table[x];
 }
 
 int yaffs_hweight32(u32 x)
 {
-       return yaffs_hweight8(x & 0xff) +
-               yaffs_hweight8((x >> 8) & 0xff) +
-               yaffs_hweight8((x >> 16) & 0xff) +
-               yaffs_hweight8((x >> 24) & 0xff);
+       return 
+               yaffs_count_bits_table[x & 0xff] +
+               yaffs_count_bits_table[(x>>8) & 0xff] +
+               yaffs_count_bits_table[(x>>16) & 0xff] +
+               yaffs_count_bits_table[(x>>24) & 0xff];
 }
 
index 87d9980cf9a91095a7352eed02117ee787dd3cfa..eaf30808862179807c9540445e3d62ad6fdcc07b 100644 (file)
@@ -1174,7 +1174,7 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte,
                else
                        maxRead = 0;
 
-               if (nbyte > maxRead)
+               if ((Y_LOFF_T)nbyte > maxRead)
                        nbyte = maxRead;
 
                yaffsfs_GetHandle(handle);
index e896ffdf88318b1c5ccb22c0cab75c414806e9c6..2443c78b00df2051328573ed77baca0a48a660be 100644 (file)
@@ -2809,7 +2809,7 @@ static unsigned yaffs_find_gc_block(struct yaffs_dev *dev,
         */
 
        if (!selected && dev->param.is_yaffs2 &&
-           dev->gc_not_done >= (background ? 10 : 20)) {
+           dev->gc_not_done >= (unsigned)(background ? 10 : 20)) {
                yaffs2_find_oldest_dirty_seq(dev);
                if (dev->oldest_dirty_block > 0) {
                        selected = dev->oldest_dirty_block;
@@ -3650,7 +3650,7 @@ int yaffs_do_file_wr(struct yaffs_obj *in, const u8 *buffer, loff_t offset,
 
        /* Update file object */
 
-       if ((start_write + n_done) > in->variant.file_variant.file_size)
+       if ((start_write + n_done) > (u32)in->variant.file_variant.file_size)
                in->variant.file_variant.file_size = (start_write + n_done);
 
        in->dirty = 1;
@@ -5096,16 +5096,22 @@ int yaffs_get_n_free_chunks(struct yaffs_dev *dev)
  */
 void yaffs_oh_size_load(struct yaffs_obj_hdr *oh, loff_t fsize)
 {
+       int shift = 32;
+
        oh->file_size_low = (fsize & 0xFFFFFFFF);
-       oh->file_size_high = ((fsize >> 32) & 0xFFFFFFFF);
+       if (sizeof(loff_t) >= 8)
+               oh->file_size_high = ((fsize >> shift) & 0xFFFFFFFF);
+       else
+               oh->file_size_high = 0;
 }
 
 loff_t yaffs_oh_to_size(struct yaffs_obj_hdr *oh)
 {
+       int shift = 32;
        loff_t retval;
 
        if (sizeof(loff_t) >= 8 && ~(oh->file_size_high))
-               retval = (((loff_t) oh->file_size_high) << 32) |
+               retval = (((loff_t) oh->file_size_high) << shift) |
                        (((loff_t) oh->file_size_low) & 0xFFFFFFFF);
        else
                retval = (loff_t) oh->file_size_low;
index e0c0ee5794bf0f7d26942275b90ca4d288fae495..b24cf4f58ec01bc34b2aad63cf424a7ffb1ee819 100644 (file)
@@ -160,8 +160,8 @@ int yaffs1_scan(struct yaffs_dev *dev)
                                    tags.n_bytes;
                                if (in &&
                                    in->variant_type ==
-                                    YAFFS_OBJECT_TYPE_FILE &&
-                                   in->variant.file_variant.scanned_size <
+                                   YAFFS_OBJECT_TYPE_FILE &&
+                                   (unsigned)in->variant.file_variant.scanned_size <
                                      endpos) {
                                        in->variant.file_variant.scanned_size =
                                            endpos;
index 4bbc76989127bab3cd3ce5f1edba99e52542840b..17b9210d7c9755a18d40e15460ff35e251a9d22c 100644 (file)
@@ -29,7 +29,7 @@
  * the partition is at least this big.
  */
 #define YAFFS_CHECKPOINT_MIN_BLOCKS 60
-#define YAFFS_SMALL_HOLE_THRESHOLD 4
+#define YAFFS_SMALL_HOLE_BLOCKS 4
 
 /*
  * Oldest Dirty Sequence Number handling.
@@ -862,8 +862,9 @@ int yaffs2_handle_hole(struct yaffs_obj *obj, loff_t new_size)
 
        increase = new_size - old_file_size;
 
-       if (increase < YAFFS_SMALL_HOLE_THRESHOLD * dev->data_bytes_per_chunk &&
-           yaffs_check_alloc_available(dev, YAFFS_SMALL_HOLE_THRESHOLD + 1))
+       if (increase < 
+            (loff_t)(YAFFS_SMALL_HOLE_BLOCKS * dev->data_bytes_per_chunk) &&
+           yaffs_check_alloc_available(dev, YAFFS_SMALL_HOLE_BLOCKS + 1))
                small_hole = 1;
        else
                small_hole = 0;