Lines Matching refs:off

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