From 8151c9a6c035743c7d12229eaab73e6f5adb9c39 Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Tue, 17 Mar 2015 07:36:38 +1300 Subject: [PATCH] More clean up Signed-off-by: Charles Manning --- direct/u-boot/fs/yaffs2/yaffs_mtdif2.c | 4 ++-- direct/yaffs_hweight.c | 13 ++++++------- direct/yaffsfs.c | 2 +- yaffs_guts.c | 14 ++++++++++---- yaffs_yaffs1.c | 4 ++-- yaffs_yaffs2.c | 7 ++++--- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/direct/u-boot/fs/yaffs2/yaffs_mtdif2.c b/direct/u-boot/fs/yaffs2/yaffs_mtdif2.c index b27fe56..f5c0951 100644 --- a/direct/u-boot/fs/yaffs2/yaffs_mtdif2.c +++ b/direct/u-boot/fs/yaffs2/yaffs_mtdif2.c @@ -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"); diff --git a/direct/yaffs_hweight.c b/direct/yaffs_hweight.c index 7e2c250..89d7f84 100644 --- a/direct/yaffs_hweight.c +++ b/direct/yaffs_hweight.c @@ -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]; } diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 87d9980..eaf3080 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -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); diff --git a/yaffs_guts.c b/yaffs_guts.c index e896ffd..2443c78 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -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; diff --git a/yaffs_yaffs1.c b/yaffs_yaffs1.c index e0c0ee5..b24cf4f 100644 --- a/yaffs_yaffs1.c +++ b/yaffs_yaffs1.c @@ -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; diff --git a/yaffs_yaffs2.c b/yaffs_yaffs2.c index 4bbc769..17b9210 100644 --- a/yaffs_yaffs2.c +++ b/yaffs_yaffs2.c @@ -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; -- 2.30.2