Lines Matching refs:pnum
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
133 dbg_io("read %d bytes from PEB %d:%d", len, pnum, offset); in ubi_io_read()
135 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); 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()
181 pnum); in ubi_io_read()
188 err, errstr, len, pnum, offset, read); in ubi_io_read()
194 err, errstr, len, pnum, offset, read); in ubi_io_read()
235 int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, in ubi_io_write() argument
242 dbg_io("write %d bytes to PEB %d:%d", len, pnum, offset); in ubi_io_write()
244 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_write()
254 err = self_check_not_bad(ubi, pnum); in ubi_io_write()
259 err = ubi_self_check_all_ff(ubi, pnum, offset, len); in ubi_io_write()
268 err = self_check_peb_ec_hdr(ubi, pnum); in ubi_io_write()
271 err = self_check_peb_vid_hdr(ubi, pnum); in ubi_io_write()
278 len, pnum, offset); in ubi_io_write()
283 addr = (loff_t)pnum * ubi->peb_size + offset; in ubi_io_write()
287 err, len, pnum, offset, written); in ubi_io_write()
289 ubi_dump_flash(ubi, pnum, offset, len); in ubi_io_write()
294 err = self_check_write(ubi, buf, pnum, offset, len); in ubi_io_write()
305 err = ubi_self_check_all_ff(ubi, pnum, offset, len); in ubi_io_write()
332 static int do_sync_erase(struct ubi_device *ubi, int pnum) in do_sync_erase() argument
338 dbg_io("erase PEB %d", pnum); in do_sync_erase()
339 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in do_sync_erase()
351 ei.addr = (loff_t)pnum * ubi->peb_size; in do_sync_erase()
360 err, pnum); in do_sync_erase()
364 ubi_err(ubi, "cannot erase PEB %d, error %d", pnum, err); in do_sync_erase()
372 ubi_err(ubi, "interrupted PEB %d erasure", pnum); in do_sync_erase()
379 pnum); in do_sync_erase()
383 ubi_err(ubi, "cannot erase PEB %d", pnum); in do_sync_erase()
388 err = ubi_self_check_all_ff(ubi, pnum, 0, ubi->peb_size); in do_sync_erase()
393 ubi_err(ubi, "cannot erase PEB %d (emulated)", pnum); in do_sync_erase()
412 static int torture_peb(struct ubi_device *ubi, int pnum) in torture_peb() argument
416 ubi_msg(ubi, "run torture test for PEB %d", pnum); in torture_peb()
422 err = do_sync_erase(ubi, pnum); in torture_peb()
427 err = ubi_io_read(ubi, ubi->peb_buf, pnum, 0, ubi->peb_size); in torture_peb()
434 pnum); in torture_peb()
441 err = ubi_io_write(ubi, ubi->peb_buf, pnum, 0, ubi->peb_size); in torture_peb()
446 err = ubi_io_read(ubi, ubi->peb_buf, pnum, 0, ubi->peb_size); in torture_peb()
454 patterns[i], pnum); in torture_peb()
461 ubi_msg(ubi, "PEB %d passed torture test, do not mark it as bad", pnum); in torture_peb()
472 pnum); in torture_peb()
498 static int nor_erase_prepare(struct ubi_device *ubi, int pnum) in nor_erase_prepare() argument
523 addr = (loff_t)pnum * ubi->peb_size; in nor_erase_prepare()
524 err = ubi_io_read_ec_hdr(ubi, pnum, &ec_hdr, 0); in nor_erase_prepare()
535 err = ubi_io_read_vid_hdr(ubi, pnum, &vidb, 0); in nor_erase_prepare()
551 ubi_err(ubi, "cannot invalidate PEB %d, write returned %d", pnum, err); in nor_erase_prepare()
552 ubi_dump_flash(ubi, pnum, 0, ubi->peb_size); in nor_erase_prepare()
572 int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture) in ubi_io_sync_erase() argument
576 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_sync_erase()
578 err = self_check_not_bad(ubi, pnum); in ubi_io_sync_erase()
588 err = nor_erase_prepare(ubi, pnum); in ubi_io_sync_erase()
594 ret = torture_peb(ubi, pnum); in ubi_io_sync_erase()
599 err = do_sync_erase(ubi, pnum); in ubi_io_sync_erase()
614 int ubi_io_is_bad(const struct ubi_device *ubi, int pnum) in ubi_io_is_bad() argument
618 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_is_bad()
623 ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size); in ubi_io_is_bad()
626 ret, pnum); in ubi_io_is_bad()
628 dbg_io("PEB %d is bad", pnum); in ubi_io_is_bad()
643 int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum) in ubi_io_mark_bad() argument
648 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_mark_bad()
658 err = mtd_block_markbad(mtd, (loff_t)pnum * ubi->peb_size); in ubi_io_mark_bad()
660 ubi_err(ubi, "cannot mark PEB %d bad, error %d", pnum, err); in ubi_io_mark_bad()
736 int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, in ubi_io_read_ec_hdr() argument
742 dbg_io("read EC header from PEB %d", pnum); in ubi_io_read_ec_hdr()
743 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_read_ec_hdr()
745 read_err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); in ubi_io_read_ec_hdr()
775 pnum); in ubi_io_read_ec_hdr()
777 pnum); in ubi_io_read_ec_hdr()
790 pnum, magic, UBI_EC_HDR_MAGIC); in ubi_io_read_ec_hdr()
794 pnum, magic, UBI_EC_HDR_MAGIC); in ubi_io_read_ec_hdr()
804 pnum, crc, hdr_crc); in ubi_io_read_ec_hdr()
808 pnum, crc, hdr_crc); in ubi_io_read_ec_hdr()
819 ubi_err(ubi, "validation failed for PEB %d", pnum); in ubi_io_read_ec_hdr()
845 int ubi_io_write_ec_hdr(struct ubi_device *ubi, int pnum, in ubi_io_write_ec_hdr() argument
851 dbg_io("write EC header to PEB %d", pnum); in ubi_io_write_ec_hdr()
852 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_write_ec_hdr()
862 err = self_check_ec_hdr(ubi, pnum, ec_hdr); in ubi_io_write_ec_hdr()
869 err = ubi_io_write(ubi, ec_hdr, pnum, 0, ubi->ec_hdr_alsize); in ubi_io_write_ec_hdr()
1013 int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, in ubi_io_read_vid_hdr() argument
1021 dbg_io("read VID header from PEB %d", pnum); in ubi_io_read_vid_hdr()
1022 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_read_vid_hdr()
1024 read_err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, in ubi_io_read_vid_hdr()
1037 pnum); in ubi_io_read_vid_hdr()
1039 pnum); in ubi_io_read_vid_hdr()
1048 pnum, magic, UBI_VID_HDR_MAGIC); in ubi_io_read_vid_hdr()
1052 pnum, magic, UBI_VID_HDR_MAGIC); in ubi_io_read_vid_hdr()
1062 pnum, crc, hdr_crc); in ubi_io_read_vid_hdr()
1066 pnum, crc, hdr_crc); in ubi_io_read_vid_hdr()
1075 ubi_err(ubi, "validation failed for PEB %d", pnum); in ubi_io_read_vid_hdr()
1097 int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum, in ubi_io_write_vid_hdr() argument
1105 dbg_io("write VID header to PEB %d", pnum); in ubi_io_write_vid_hdr()
1106 ubi_assert(pnum >= 0 && pnum < ubi->peb_count); in ubi_io_write_vid_hdr()
1108 err = self_check_peb_ec_hdr(ubi, pnum); in ubi_io_write_vid_hdr()
1117 err = self_check_vid_hdr(ubi, pnum, vid_hdr); in ubi_io_write_vid_hdr()
1124 err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset, in ubi_io_write_vid_hdr()
1137 static int self_check_not_bad(const struct ubi_device *ubi, int pnum) in self_check_not_bad() argument
1144 err = ubi_io_is_bad(ubi, pnum); in self_check_not_bad()
1148 ubi_err(ubi, "self-check failed for PEB %d", pnum); in self_check_not_bad()
1162 static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum, in self_check_ec_hdr() argument
1180 ubi_err(ubi, "self-check failed for PEB %d", pnum); in self_check_ec_hdr()
1200 static int self_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum) in self_check_peb_ec_hdr() argument
1213 err = ubi_io_read(ubi, ec_hdr, pnum, 0, UBI_EC_HDR_SIZE); in self_check_peb_ec_hdr()
1222 ubi_err(ubi, "self-check failed for PEB %d", pnum); in self_check_peb_ec_hdr()
1229 err = self_check_ec_hdr(ubi, pnum, ec_hdr); in self_check_peb_ec_hdr()
1245 static int self_check_vid_hdr(const struct ubi_device *ubi, int pnum, in self_check_vid_hdr() argument
1257 magic, pnum, UBI_VID_HDR_MAGIC); in self_check_vid_hdr()
1263 ubi_err(ubi, "self-check failed for PEB %d", pnum); in self_check_vid_hdr()
1270 ubi_err(ubi, "self-check failed for PEB %d", pnum); in self_check_vid_hdr()
1285 static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) in self_check_peb_vid_hdr() argument
1302 err = ubi_io_read(ubi, p, pnum, ubi->vid_hdr_aloffset, in self_check_peb_vid_hdr()
1311 pnum, crc, hdr_crc); in self_check_peb_vid_hdr()
1312 ubi_err(ubi, "self-check failed for PEB %d", pnum); in self_check_peb_vid_hdr()
1319 err = self_check_vid_hdr(ubi, pnum, vid_hdr); in self_check_peb_vid_hdr()
1338 static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, in self_check_write() argument
1344 loff_t addr = (loff_t)pnum * ubi->peb_size + offset; in self_check_write()
1368 pnum, offset, len); in self_check_write()
1403 int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) in ubi_self_check_all_ff() argument
1408 loff_t addr = (loff_t)pnum * ubi->peb_size + offset; in ubi_self_check_all_ff()
1422 err, len, pnum, offset, read); in ubi_self_check_all_ff()
1429 pnum, offset, len); in ubi_self_check_all_ff()
1437 ubi_err(ubi, "self-check failed for PEB %d", pnum); in ubi_self_check_all_ff()