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;
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");
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];
}
else
maxRead = 0;
- if (nbyte > maxRead)
+ if ((Y_LOFF_T)nbyte > maxRead)
nbyte = maxRead;
yaffsfs_GetHandle(handle);
*/
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;
/* 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;
*/
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;
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;
* 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.
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;