int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing) { dev->checkpt_open_write = writing; /* Got the functions we need? */ if (!dev->param.write_chunk_tags_fn || !dev->param.read_chunk_tags_fn || !dev->param.erase_fn || !dev->param.bad_block_fn) return 0; if (writing && !yaffs2_checkpt_space_ok(dev)) return 0; if (!dev->checkpt_buffer) dev->checkpt_buffer = kmalloc(dev->param.total_bytes_per_chunk, GFP_NOFS); if (!dev->checkpt_buffer) return 0; dev->checkpt_page_seq = 0; dev->checkpt_byte_count = 0; dev->checkpt_sum = 0; dev->checkpt_xor = 0; dev->checkpt_cur_block = -1; dev->checkpt_cur_chunk = -1; dev->checkpt_next_block = dev->internal_start_block; /* Erase all the blocks in the checkpoint area */ if (writing) { memset(dev->checkpt_buffer, 0, dev->data_bytes_per_chunk); dev->checkpt_byte_offs = 0; return yaffs_checkpt_erase(dev); } else { int i; /* Set to a value that will kick off a read */ dev->checkpt_byte_offs = dev->data_bytes_per_chunk; /* A checkpoint block list of 1 checkpoint block per 16 block is (hopefully) * going to be way more than we need */ dev->blocks_in_checkpt = 0; dev->checkpt_max_blocks = (dev->internal_end_block - dev->internal_start_block) / 16 + 2; dev->checkpt_block_list = kmalloc(sizeof(int) * dev->checkpt_max_blocks, GFP_NOFS); if (!dev->checkpt_block_list) return 0; for (i = 0; i < dev->checkpt_max_blocks; i++) dev->checkpt_block_list[i] = -1; } return 1; }
int yaffs2_checkpt_open(struct yaffs_dev *dev, int writing) { dev->checkpt_open_write = writing; if (!dev->param.write_chunk_tags_fn || !dev->param.read_chunk_tags_fn || !dev->param.erase_fn || !dev->param.bad_block_fn) return 0; if (writing && !yaffs2_checkpt_space_ok(dev)) return 0; if (!dev->checkpt_buffer) dev->checkpt_buffer = kmalloc(dev->param.total_bytes_per_chunk, GFP_NOFS); if (!dev->checkpt_buffer) return 0; dev->checkpt_page_seq = 0; dev->checkpt_byte_count = 0; dev->checkpt_sum = 0; dev->checkpt_xor = 0; dev->checkpt_cur_block = -1; dev->checkpt_cur_chunk = -1; dev->checkpt_next_block = dev->internal_start_block; if (writing) { memset(dev->checkpt_buffer, 0, dev->data_bytes_per_chunk); dev->checkpt_byte_offs = 0; return yaffs_checkpt_erase(dev); } else { int i; dev->checkpt_byte_offs = dev->data_bytes_per_chunk; dev->blocks_in_checkpt = 0; dev->checkpt_max_blocks = (dev->internal_end_block - dev->internal_start_block) / 16 + 2; dev->checkpt_block_list = kmalloc(sizeof(int) * dev->checkpt_max_blocks, GFP_NOFS); if (!dev->checkpt_block_list) return 0; for (i = 0; i < dev->checkpt_max_blocks; i++) dev->checkpt_block_list[i] = -1; } return 1; }