• Home
  • Raw
  • Download

Lines Matching refs:ubi

94 static int self_check_not_bad(const struct ubi_device *ubi, int pnum);
95 static int self_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum);
96 static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum,
98 static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum);
99 static int self_check_vid_hdr(const struct ubi_device *ubi, int pnum,
101 static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum,
126 int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, in ubi_io_read() argument
135 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_read()
136 ubi_assert(offset >= 0 && offset + len <= ubi->peb_size); in ubi_io_read()
139 err = self_check_not_bad(ubi, pnum); in ubi_io_read()
165 addr = (loff_t)pnum * ubi->peb_size + offset; in ubi_io_read()
167 err = mtd_read(ubi->mtd, addr, len, &read, buf); in ubi_io_read()
208 if (ubi_dbg_is_bitflip(ubi)) { in ubi_io_read()
234 int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, in ubi_io_write() argument
243 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_write()
244 ubi_assert(offset >= 0 && offset + len <= ubi->peb_size); in ubi_io_write()
245 ubi_assert(offset % ubi->hdrs_min_io_size == 0); in ubi_io_write()
246 ubi_assert(len > 0 && len % ubi->hdrs_min_io_size == 0); in ubi_io_write()
248 if (ubi->ro_mode) { in ubi_io_write()
253 err = self_check_not_bad(ubi, pnum); in ubi_io_write()
258 err = ubi_self_check_all_ff(ubi, pnum, offset, len); in ubi_io_write()
262 if (offset >= ubi->leb_start) { in ubi_io_write()
267 err = self_check_peb_ec_hdr(ubi, pnum); in ubi_io_write()
270 err = self_check_peb_vid_hdr(ubi, pnum); in ubi_io_write()
275 if (ubi_dbg_is_write_failure(ubi)) { in ubi_io_write()
282 addr = (loff_t)pnum * ubi->peb_size + offset; in ubi_io_write()
283 err = mtd_write(ubi->mtd, addr, len, &written, buf); in ubi_io_write()
288 ubi_dump_flash(ubi, pnum, offset, len); in ubi_io_write()
293 err = self_check_write(ubi, buf, pnum, offset, len); in ubi_io_write()
302 len = ubi->peb_size - offset; in ubi_io_write()
304 err = ubi_self_check_all_ff(ubi, pnum, offset, len); in ubi_io_write()
331 static int do_sync_erase(struct ubi_device *ubi, int pnum) in do_sync_erase() argument
338 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in do_sync_erase()
340 if (ubi->ro_mode) { in do_sync_erase()
349 ei.mtd = ubi->mtd; in do_sync_erase()
350 ei.addr = (loff_t)pnum * ubi->peb_size; in do_sync_erase()
351 ei.len = ubi->peb_size; in do_sync_erase()
355 err = mtd_erase(ubi->mtd, &ei); in do_sync_erase()
386 err = ubi_self_check_all_ff(ubi, pnum, 0, ubi->peb_size); in do_sync_erase()
390 if (ubi_dbg_is_erase_failure(ubi)) { in do_sync_erase()
410 static int torture_peb(struct ubi_device *ubi, int pnum) in torture_peb() argument
418 mutex_lock(&ubi->buf_mutex); in torture_peb()
420 err = do_sync_erase(ubi, pnum); in torture_peb()
425 err = ubi_io_read(ubi, ubi->peb_buf, pnum, 0, ubi->peb_size); in torture_peb()
429 err = ubi_check_pattern(ubi->peb_buf, 0xFF, ubi->peb_size); in torture_peb()
438 memset(ubi->peb_buf, patterns[i], ubi->peb_size); in torture_peb()
439 err = ubi_io_write(ubi, ubi->peb_buf, pnum, 0, ubi->peb_size); in torture_peb()
443 memset(ubi->peb_buf, ~patterns[i], ubi->peb_size); in torture_peb()
444 err = ubi_io_read(ubi, ubi->peb_buf, pnum, 0, ubi->peb_size); in torture_peb()
448 err = ubi_check_pattern(ubi->peb_buf, patterns[i], in torture_peb()
449 ubi->peb_size); in torture_peb()
462 mutex_unlock(&ubi->buf_mutex); in torture_peb()
496 static int nor_erase_prepare(struct ubi_device *ubi, int pnum) in nor_erase_prepare() argument
517 addr = (loff_t)pnum * ubi->peb_size; in nor_erase_prepare()
518 err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data); in nor_erase_prepare()
520 addr += ubi->vid_hdr_aloffset; in nor_erase_prepare()
521 err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data); in nor_erase_prepare()
533 err1 = ubi_io_read_vid_hdr(ubi, pnum, &vid_hdr, 0); in nor_erase_prepare()
538 err1 = ubi_io_read_ec_hdr(ubi, pnum, &ec_hdr, 0); in nor_erase_prepare()
556 ubi_dump_flash(ubi, pnum, 0, ubi->peb_size); in nor_erase_prepare()
576 int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture) in ubi_io_sync_erase() argument
580 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_sync_erase()
582 err = self_check_not_bad(ubi, pnum); in ubi_io_sync_erase()
586 if (ubi->ro_mode) { in ubi_io_sync_erase()
591 if (ubi->nor_flash) { in ubi_io_sync_erase()
592 err = nor_erase_prepare(ubi, pnum); in ubi_io_sync_erase()
598 ret = torture_peb(ubi, pnum); in ubi_io_sync_erase()
603 err = do_sync_erase(ubi, pnum); in ubi_io_sync_erase()
618 int ubi_io_is_bad(const struct ubi_device *ubi, int pnum) in ubi_io_is_bad() argument
620 struct mtd_info *mtd = ubi->mtd; in ubi_io_is_bad()
622 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_is_bad()
624 if (ubi->bad_allowed) { in ubi_io_is_bad()
627 ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size); in ubi_io_is_bad()
647 int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum) in ubi_io_mark_bad() argument
650 struct mtd_info *mtd = ubi->mtd; in ubi_io_mark_bad()
652 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_mark_bad()
654 if (ubi->ro_mode) { in ubi_io_mark_bad()
659 if (!ubi->bad_allowed) in ubi_io_mark_bad()
662 err = mtd_block_markbad(mtd, (loff_t)pnum * ubi->peb_size); in ubi_io_mark_bad()
676 static int validate_ec_hdr(const struct ubi_device *ubi, in validate_ec_hdr() argument
692 if (vid_hdr_offset != ubi->vid_hdr_offset) { in validate_ec_hdr()
694 vid_hdr_offset, ubi->vid_hdr_offset); in validate_ec_hdr()
698 if (leb_start != ubi->leb_start) { in validate_ec_hdr()
700 leb_start, ubi->leb_start); in validate_ec_hdr()
740 int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, in ubi_io_read_ec_hdr() argument
747 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_read_ec_hdr()
749 read_err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); in ubi_io_read_ec_hdr()
821 err = validate_ec_hdr(ubi, ec_hdr); in ubi_io_read_ec_hdr()
849 int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum, in ubi_io_write_ec_hdr() argument
856 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_write_ec_hdr()
860 ec_hdr->vid_hdr_offset = cpu_to_be32(ubi->vid_hdr_offset); in ubi_io_write_ec_hdr()
861 ec_hdr->data_offset = cpu_to_be32(ubi->leb_start); in ubi_io_write_ec_hdr()
862 ec_hdr->image_seq = cpu_to_be32(ubi->image_seq); in ubi_io_write_ec_hdr()
866 err = self_check_ec_hdr(ubi, pnum, ec_hdr); in ubi_io_write_ec_hdr()
870 err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize); in ubi_io_write_ec_hdr()
882 static int validate_vid_hdr(const struct ubi_device *ubi, in validate_vid_hdr() argument
894 int usable_leb_size = ubi->leb_size - data_pad; in validate_vid_hdr()
929 if (data_pad >= ubi->leb_size / 2) { in validate_vid_hdr()
1010 int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, in ubi_io_read_vid_hdr() argument
1018 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_read_vid_hdr()
1020 p = (char *)vid_hdr - ubi->vid_hdr_shift; in ubi_io_read_vid_hdr()
1021 read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, in ubi_io_read_vid_hdr()
1022 ubi->vid_hdr_alsize); in ubi_io_read_vid_hdr()
1070 err = validate_vid_hdr(ubi, vid_hdr); in ubi_io_read_vid_hdr()
1094 int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, in ubi_io_write_vid_hdr() argument
1102 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_write_vid_hdr()
1104 err = self_check_peb_ec_hdr(ubi, pnum); in ubi_io_write_vid_hdr()
1113 err = self_check_vid_hdr(ubi, pnum, vid_hdr); in ubi_io_write_vid_hdr()
1117 p = (char *)vid_hdr - ubi->vid_hdr_shift; in ubi_io_write_vid_hdr()
1118 err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset, in ubi_io_write_vid_hdr()
1119 ubi->vid_hdr_alsize); in ubi_io_write_vid_hdr()
1131 static int self_check_not_bad(const struct ubi_device *ubi, int pnum) in self_check_not_bad() argument
1135 if (!ubi_dbg_chk_io(ubi)) in self_check_not_bad()
1138 err = ubi_io_is_bad(ubi, pnum); in self_check_not_bad()
1156 static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum, in self_check_ec_hdr() argument
1162 if (!ubi_dbg_chk_io(ubi)) in self_check_ec_hdr()
1172 err = validate_ec_hdr(ubi, ec_hdr); in self_check_ec_hdr()
1194 static int self_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum) in self_check_peb_ec_hdr() argument
1200 if (!ubi_dbg_chk_io(ubi)) in self_check_peb_ec_hdr()
1203 ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS); in self_check_peb_ec_hdr()
1207 err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); in self_check_peb_ec_hdr()
1222 err = self_check_ec_hdr(ubi, pnum, ec_hdr); in self_check_peb_ec_hdr()
1238 static int self_check_vid_hdr(const struct ubi_device *ubi, int pnum, in self_check_vid_hdr() argument
1244 if (!ubi_dbg_chk_io(ubi)) in self_check_vid_hdr()
1254 err = validate_vid_hdr(ubi, vid_hdr); in self_check_vid_hdr()
1278 static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) in self_check_peb_vid_hdr() argument
1285 if (!ubi_dbg_chk_io(ubi)) in self_check_peb_vid_hdr()
1288 vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); in self_check_peb_vid_hdr()
1292 p = (char *)vid_hdr - ubi->vid_hdr_shift; in self_check_peb_vid_hdr()
1293 err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, in self_check_peb_vid_hdr()
1294 ubi->vid_hdr_alsize); in self_check_peb_vid_hdr()
1310 err = self_check_vid_hdr(ubi, pnum, vid_hdr); in self_check_peb_vid_hdr()
1313 ubi_free_vid_hdr(ubi, vid_hdr); in self_check_peb_vid_hdr()
1329 static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, in self_check_write() argument
1335 loff_t addr = (loff_t)pnum * ubi->peb_size + offset; in self_check_write()
1337 if (!ubi_dbg_chk_io(ubi)) in self_check_write()
1346 err = mtd_read(ubi->mtd, addr, len, &read, buf1); in self_check_write()
1394 int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) in ubi_self_check_all_ff() argument
1399 loff_t addr = (loff_t)pnum * ubi->peb_size + offset; in ubi_self_check_all_ff()
1401 if (!ubi_dbg_chk_io(ubi)) in ubi_self_check_all_ff()
1410 err = mtd_read(ubi->mtd, addr, len, &read, buf); in ubi_self_check_all_ff()