Lines Matching full:off

27 static int mtdpstore_block_isbad(struct mtdpstore_context *cxt, loff_t off)  in mtdpstore_block_isbad()  argument
33 off = ALIGN_DOWN(off, mtd->erasesize); in mtdpstore_block_isbad()
34 blknum = div_u64(off, mtd->erasesize); in mtdpstore_block_isbad()
38 ret = mtd_block_isbad(mtd, off); in mtdpstore_block_isbad()
50 loff_t off) in mtdpstore_panic_block_isbad() argument
55 off = ALIGN_DOWN(off, mtd->erasesize); in mtdpstore_panic_block_isbad()
56 blknum = div_u64(off, mtd->erasesize); in mtdpstore_panic_block_isbad()
61 loff_t off) in mtdpstore_mark_used() argument
64 u64 zonenum = div_u64(off, cxt->info.kmsg_size); in mtdpstore_mark_used()
71 loff_t off) in mtdpstore_mark_unused() argument
74 u64 zonenum = div_u64(off, cxt->info.kmsg_size); in mtdpstore_mark_unused()
81 loff_t off) in mtdpstore_block_mark_unused() argument
87 off = ALIGN_DOWN(off, mtd->erasesize); in mtdpstore_block_mark_unused()
88 zonenum = div_u64(off, cxt->info.kmsg_size); in mtdpstore_block_mark_unused()
97 static inline int mtdpstore_is_used(struct mtdpstore_context *cxt, loff_t off) in mtdpstore_is_used() argument
99 u64 zonenum = div_u64(off, cxt->info.kmsg_size); in mtdpstore_is_used()
100 u64 blknum = div_u64(off, cxt->mtd->erasesize); in mtdpstore_is_used()
108 loff_t off) in mtdpstore_block_is_used() argument
114 off = ALIGN_DOWN(off, mtd->erasesize); in mtdpstore_block_is_used()
115 zonenum = div_u64(off, cxt->info.kmsg_size); in mtdpstore_block_is_used()
140 static void mtdpstore_mark_removed(struct mtdpstore_context *cxt, loff_t off) in mtdpstore_mark_removed() argument
143 u64 zonenum = div_u64(off, cxt->info.kmsg_size); in mtdpstore_mark_removed()
150 loff_t off) in mtdpstore_block_clear_removed() argument
156 off = ALIGN_DOWN(off, mtd->erasesize); in mtdpstore_block_clear_removed()
157 zonenum = div_u64(off, cxt->info.kmsg_size); in mtdpstore_block_clear_removed()
166 loff_t off) in mtdpstore_block_is_removed() argument
172 off = ALIGN_DOWN(off, mtd->erasesize); in mtdpstore_block_is_removed()
173 zonenum = div_u64(off, cxt->info.kmsg_size); in mtdpstore_block_is_removed()
183 static int mtdpstore_erase_do(struct mtdpstore_context *cxt, loff_t off) in mtdpstore_erase_do() argument
189 off = ALIGN_DOWN(off, cxt->mtd->erasesize); in mtdpstore_erase_do()
190 dev_dbg(&mtd->dev, "try to erase off 0x%llx\n", off); in mtdpstore_erase_do()
192 erase.addr = off; in mtdpstore_erase_do()
195 mtdpstore_block_clear_removed(cxt, off); in mtdpstore_erase_do()
210 static ssize_t mtdpstore_erase(size_t size, loff_t off) in mtdpstore_erase() argument
214 if (mtdpstore_block_isbad(cxt, off)) in mtdpstore_erase()
217 mtdpstore_mark_unused(cxt, off); in mtdpstore_erase()
220 if (likely(mtdpstore_block_is_used(cxt, off))) { in mtdpstore_erase()
221 mtdpstore_mark_removed(cxt, off); in mtdpstore_erase()
226 return mtdpstore_erase_do(cxt, off); in mtdpstore_erase()
237 static int mtdpstore_security(struct mtdpstore_context *cxt, loff_t off) in mtdpstore_security() argument
241 u32 zonenum = (u32)div_u64(off, cxt->info.kmsg_size); in mtdpstore_security()
256 div64_u64_rem(off + erasesize, cxt->mtd->size, (u64 *)&off); in mtdpstore_security()
258 if (mtdpstore_block_isbad(cxt, off)) in mtdpstore_security()
261 ret = mtdpstore_erase_do(cxt, off); in mtdpstore_security()
263 mtdpstore_block_mark_unused(cxt, off); in mtdpstore_security()
274 static ssize_t mtdpstore_write(const char *buf, size_t size, loff_t off) in mtdpstore_write() argument
281 if (mtdpstore_block_isbad(cxt, off)) in mtdpstore_write()
285 if (mtdpstore_is_used(cxt, off)) in mtdpstore_write()
288 dev_dbg(&mtd->dev, "try to write off 0x%llx size %zu\n", off, size); in mtdpstore_write()
289 ret = mtd_write(cxt->mtd, off, size, &retlen, (u_char *)buf); in mtdpstore_write()
292 off, retlen, size, ret); in mtdpstore_write()
295 mtdpstore_mark_used(cxt, off); in mtdpstore_write()
297 mtdpstore_security(cxt, off); in mtdpstore_write()
310 static ssize_t mtdpstore_read(char *buf, size_t size, loff_t off) in mtdpstore_read() argument
317 if (mtdpstore_block_isbad(cxt, off)) in mtdpstore_read()
320 dev_dbg(&mtd->dev, "try to read off 0x%llx size %zu\n", off, size); in mtdpstore_read()
324 ret = mtd_read(cxt->mtd, off + done, size - done, &retlen, in mtdpstore_read()
328 off + done, retlen, size - done, ret); in mtdpstore_read()
341 off + done, retlen, size - done, ret); in mtdpstore_read()
348 mtdpstore_mark_unused(cxt, off); in mtdpstore_read()
350 mtdpstore_mark_used(cxt, off); in mtdpstore_read()
352 mtdpstore_security(cxt, off); in mtdpstore_read()
356 static ssize_t mtdpstore_panic_write(const char *buf, size_t size, loff_t off) in mtdpstore_panic_write() argument
363 if (mtdpstore_panic_block_isbad(cxt, off)) in mtdpstore_panic_write()
367 if (mtdpstore_is_used(cxt, off)) in mtdpstore_panic_write()
370 ret = mtd_panic_write(cxt->mtd, off, size, &retlen, (u_char *)buf); in mtdpstore_panic_write()
373 off, retlen, size, ret); in mtdpstore_panic_write()
376 mtdpstore_mark_used(cxt, off); in mtdpstore_panic_write()
445 loff_t off, size_t size) in mtdpstore_flush_removed_do() argument
458 ret = mtd_read(mtd, off, mtd->erasesize, &retlen, buf); in mtdpstore_flush_removed_do()
464 erase.addr = off; in mtdpstore_flush_removed_do()
474 if (mtdpstore_is_used(cxt, off)) { in mtdpstore_flush_removed_do()
475 ret = mtd_write(mtd, off, zonesize, &retlen, buf); in mtdpstore_flush_removed_do()
478 off, retlen, zonesize, ret); in mtdpstore_flush_removed_do()
481 off += zonesize; in mtdpstore_flush_removed_do()
501 loff_t off; in mtdpstore_flush_removed() local
504 for (off = 0; blkcnt > 0; blkcnt--, off += mtd->erasesize) { in mtdpstore_flush_removed()
505 ret = mtdpstore_block_isbad(cxt, off); in mtdpstore_flush_removed()
509 ret = mtdpstore_block_is_removed(cxt, off); in mtdpstore_flush_removed()
513 ret = mtdpstore_flush_removed_do(cxt, off, mtd->erasesize); in mtdpstore_flush_removed()