Lines Matching refs:dev
55 static void yaffs_summary_clear(struct yaffs_dev *dev)
57 if (!dev->sum_tags)
59 memset(dev->sum_tags, 0, dev->chunks_per_summary *
64 void yaffs_summary_deinit(struct yaffs_dev *dev)
66 kfree(dev->sum_tags);
67 dev->sum_tags = NULL;
68 kfree(dev->gc_sum_tags);
69 dev->gc_sum_tags = NULL;
70 dev->chunks_per_summary = 0;
73 int yaffs_summary_init(struct yaffs_dev *dev)
79 sum_bytes = dev->param.chunks_per_block *
82 chunks_used = (sum_bytes + dev->data_bytes_per_chunk - 1)/
83 (dev->data_bytes_per_chunk -
86 dev->chunks_per_summary = dev->param.chunks_per_block - chunks_used;
88 dev->chunks_per_summary;
89 dev->sum_tags = kmalloc(sum_tags_bytes, GFP_NOFS);
90 dev->gc_sum_tags = kmalloc(sum_tags_bytes, GFP_NOFS);
91 if (!dev->sum_tags || !dev->gc_sum_tags) {
92 yaffs_summary_deinit(dev);
96 yaffs_summary_clear(dev);
101 static unsigned yaffs_summary_sum(struct yaffs_dev *dev)
103 u8 *sum_buffer = (u8 *)dev->sum_tags;
108 dev->chunks_per_summary;
118 static int yaffs_summary_write(struct yaffs_dev *dev, int blk)
122 u8 *sum_buffer = (u8 *)dev->sum_tags;
129 int sum_bytes_per_chunk = dev->data_bytes_per_chunk - sizeof(hdr);
130 struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk);
132 buffer = yaffs_get_temp_buffer(dev);
134 dev->chunks_per_summary;
138 chunk_in_block = dev->chunks_per_summary;
139 chunk_in_nand = dev->alloc_block * dev->param.chunks_per_block +
140 dev->chunks_per_summary;
144 hdr.sum = yaffs_summary_sum(dev);
153 result = yaffs_wr_chunk_tags_nand(dev, chunk_in_nand,
158 yaffs_set_chunk_bit(dev, blk, chunk_in_block);
160 dev->n_free_chunks--;
168 yaffs_release_temp_buffer(dev, buffer);
178 int yaffs_summary_read(struct yaffs_dev *dev,
192 struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk);
193 int sum_bytes_per_chunk = dev->data_bytes_per_chunk - sizeof(hdr);
197 dev->chunks_per_summary;
198 buffer = yaffs_get_temp_buffer(dev);
199 n_bytes = sizeof(struct yaffs_summary_tags) * dev->chunks_per_summary;
200 chunk_in_block = dev->chunks_per_summary;
201 chunk_in_nand = blk * dev->param.chunks_per_block +
202 dev->chunks_per_summary;
208 result = yaffs_rd_chunk_tags_nand(dev, chunk_in_nand,
220 if (st == dev->sum_tags) {
222 yaffs_set_chunk_bit(dev, blk, chunk_in_block);
233 yaffs_release_temp_buffer(dev, buffer);
239 hdr.sum != yaffs_summary_sum(dev))
243 if (st == dev->sum_tags && result == YAFFS_OK)
249 int yaffs_summary_add(struct yaffs_dev *dev,
255 int block_in_nand = chunk_in_nand / dev->param.chunks_per_block;
256 int chunk_in_block = chunk_in_nand % dev->param.chunks_per_block;
258 if (!dev->sum_tags)
261 if (chunk_in_block >= 0 && chunk_in_block < dev->chunks_per_summary) {
263 sum_tags = &dev->sum_tags[chunk_in_block];
268 if (chunk_in_block == dev->chunks_per_summary - 1) {
270 yaffs_summary_write(dev, block_in_nand);
271 yaffs_summary_clear(dev);
272 yaffs_skip_rest_of_block(dev);
278 int yaffs_summary_fetch(struct yaffs_dev *dev,
284 if (chunk_in_block >= 0 && chunk_in_block < dev->chunks_per_summary) {
285 sum_tags = &dev->sum_tags[chunk_in_block];
295 void yaffs_summary_gc(struct yaffs_dev *dev, int blk)
297 struct yaffs_block_info *bi = yaffs_get_block_info(dev, blk);
303 for (i = dev->chunks_per_summary;
304 i < dev->param.chunks_per_block;
306 if (yaffs_check_chunk_bit(dev, blk, i)) {
307 yaffs_clear_chunk_bit(dev, blk, i);
309 dev->n_free_chunks++;