Lines Matching full:dev
55 static void yaffs_summary_clear(struct yaffs_dev *dev) in yaffs_summary_clear() argument
57 if (!dev->sum_tags) in yaffs_summary_clear()
59 memset(dev->sum_tags, 0, dev->chunks_per_summary * in yaffs_summary_clear()
64 void yaffs_summary_deinit(struct yaffs_dev *dev) in yaffs_summary_deinit() argument
66 kfree(dev->sum_tags); in yaffs_summary_deinit()
67 dev->sum_tags = NULL; in yaffs_summary_deinit()
68 kfree(dev->gc_sum_tags); in yaffs_summary_deinit()
69 dev->gc_sum_tags = NULL; in yaffs_summary_deinit()
70 dev->chunks_per_summary = 0; in yaffs_summary_deinit()
73 int yaffs_summary_init(struct yaffs_dev *dev) in yaffs_summary_init() argument
79 sum_bytes = dev->param.chunks_per_block * in yaffs_summary_init()
82 chunks_used = (sum_bytes + dev->data_bytes_per_chunk - 1)/ in yaffs_summary_init()
83 (dev->data_bytes_per_chunk - in yaffs_summary_init()
86 dev->chunks_per_summary = dev->param.chunks_per_block - chunks_used; in yaffs_summary_init()
88 dev->chunks_per_summary; in yaffs_summary_init()
89 dev->sum_tags = kmalloc(sum_tags_bytes, GFP_NOFS); in yaffs_summary_init()
90 dev->gc_sum_tags = kmalloc(sum_tags_bytes, GFP_NOFS); in yaffs_summary_init()
91 if (!dev->sum_tags || !dev->gc_sum_tags) { in yaffs_summary_init()
92 yaffs_summary_deinit(dev); in yaffs_summary_init()
96 yaffs_summary_clear(dev); in yaffs_summary_init()
101 static unsigned yaffs_summary_sum(struct yaffs_dev *dev) in yaffs_summary_sum() argument
103 u8 *sum_buffer = (u8 *)dev->sum_tags; in yaffs_summary_sum()
108 dev->chunks_per_summary; in yaffs_summary_sum()
118 static int yaffs_summary_write(struct yaffs_dev *dev, int blk) in yaffs_summary_write() argument
122 u8 *sum_buffer = (u8 *)dev->sum_tags; in yaffs_summary_write()
129 int sum_bytes_per_chunk = dev->data_bytes_per_chunk - sizeof(hdr); in yaffs_summary_write()
130 struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk); in yaffs_summary_write()
132 buffer = yaffs_get_temp_buffer(dev); in yaffs_summary_write()
134 dev->chunks_per_summary; in yaffs_summary_write()
138 chunk_in_block = dev->chunks_per_summary; in yaffs_summary_write()
139 chunk_in_nand = dev->alloc_block * dev->param.chunks_per_block + in yaffs_summary_write()
140 dev->chunks_per_summary; in yaffs_summary_write()
144 hdr.sum = yaffs_summary_sum(dev); in yaffs_summary_write()
153 result = yaffs_wr_chunk_tags_nand(dev, chunk_in_nand, in yaffs_summary_write()
158 yaffs_set_chunk_bit(dev, blk, chunk_in_block); in yaffs_summary_write()
160 dev->n_free_chunks--; in yaffs_summary_write()
168 yaffs_release_temp_buffer(dev, buffer); in yaffs_summary_write()
178 int yaffs_summary_read(struct yaffs_dev *dev, in yaffs_summary_read() argument
192 struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk); in yaffs_summary_read()
193 int sum_bytes_per_chunk = dev->data_bytes_per_chunk - sizeof(hdr); in yaffs_summary_read()
195 buffer = yaffs_get_temp_buffer(dev); in yaffs_summary_read()
196 n_bytes = sizeof(struct yaffs_summary_tags) * dev->chunks_per_summary; in yaffs_summary_read()
197 chunk_in_block = dev->chunks_per_summary; in yaffs_summary_read()
198 chunk_in_nand = blk * dev->param.chunks_per_block + in yaffs_summary_read()
199 dev->chunks_per_summary; in yaffs_summary_read()
205 result = yaffs_rd_chunk_tags_nand(dev, chunk_in_nand, in yaffs_summary_read()
217 if (st == dev->sum_tags) { in yaffs_summary_read()
219 yaffs_set_chunk_bit(dev, blk, chunk_in_block); in yaffs_summary_read()
230 yaffs_release_temp_buffer(dev, buffer); in yaffs_summary_read()
236 hdr.sum != yaffs_summary_sum(dev)) in yaffs_summary_read()
240 if (st == dev->sum_tags && result == YAFFS_OK) in yaffs_summary_read()
246 int yaffs_summary_add(struct yaffs_dev *dev, in yaffs_summary_add() argument
252 int block_in_nand = chunk_in_nand / dev->param.chunks_per_block; in yaffs_summary_add()
253 int chunk_in_block = chunk_in_nand % dev->param.chunks_per_block; in yaffs_summary_add()
255 if (!dev->sum_tags) in yaffs_summary_add()
258 if (chunk_in_block >= 0 && chunk_in_block < dev->chunks_per_summary) { in yaffs_summary_add()
260 sum_tags = &dev->sum_tags[chunk_in_block]; in yaffs_summary_add()
265 if (chunk_in_block == dev->chunks_per_summary - 1) { in yaffs_summary_add()
267 yaffs_summary_write(dev, block_in_nand); in yaffs_summary_add()
268 yaffs_summary_clear(dev); in yaffs_summary_add()
269 yaffs_skip_rest_of_block(dev); in yaffs_summary_add()
275 int yaffs_summary_fetch(struct yaffs_dev *dev, in yaffs_summary_fetch() argument
281 if (chunk_in_block >= 0 && chunk_in_block < dev->chunks_per_summary) { in yaffs_summary_fetch()
282 sum_tags = &dev->sum_tags[chunk_in_block]; in yaffs_summary_fetch()
292 void yaffs_summary_gc(struct yaffs_dev *dev, int blk) in yaffs_summary_gc() argument
294 struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk); in yaffs_summary_gc()
300 for (i = dev->chunks_per_summary; in yaffs_summary_gc()
301 i < dev->param.chunks_per_block; in yaffs_summary_gc()
303 if (yaffs_check_chunk_bit(dev, blk, i)) { in yaffs_summary_gc()
304 yaffs_clear_chunk_bit(dev, blk, i); in yaffs_summary_gc()
306 dev->n_free_chunks++; in yaffs_summary_gc()