Lines Matching refs:td

90 static int check_pattern_no_oob(uint8_t *buf, struct nand_bbt_descr *td)
92 if (memcmp(buf, td->pattern, td->len))
102 * @td: search pattern descriptor
107 static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
109 if (td->options & NAND_BBT_NO_OOB)
110 return check_pattern_no_oob(buf, td);
113 if (memcmp(buf + paglen + td->offs, td->pattern, td->len))
122 * @td: search pattern descriptor
128 static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
131 if (memcmp(buf + td->offs, td->pattern, td->len))
138 * @td: BBT descriptor used for computation
142 static u32 add_marker_len(struct nand_bbt_descr *td)
146 if (!(td->options & NAND_BBT_NO_OOB))
149 len = td->len;
150 if (td->options & NAND_BBT_VERSION)
161 * @td: the bbt describtion table
167 struct nand_bbt_descr *td, int offs)
173 int bits = td->options & NAND_BBT_NRBITS_MSK;
176 int reserved_block_code = td->reserved_block_code;
179 marker_len = add_marker_len(td);
252 * @td: descriptor for the bad block table
260 struct nand_bbt_descr *td, int chip)
266 if (td->options & NAND_BBT_PERCHIP) {
270 res = read_bbt(this, buf, td->pages[i],
272 td, offs);
278 res = read_bbt(this, buf, td->pages[0],
279 mtd->size >> this->bbt_erase_shift, td, 0);
288 struct nand_bbt_descr *td)
294 len = td->len;
295 if (td->options & NAND_BBT_VERSION)
344 size_t len, struct nand_bbt_descr *td)
346 if (td->options & NAND_BBT_NO_OOB)
347 return scan_read_data(this, buf, offs, td);
369 static u32 bbt_get_ver_offs(struct nand_chip *this, struct nand_bbt_descr *td)
372 u32 ver_offs = td->veroffs;
374 if (!(td->options & NAND_BBT_NO_OOB))
383 * @td: descriptor for the bad block table
390 struct nand_bbt_descr *td, struct nand_bbt_descr *md)
395 if (td->options & NAND_BBT_VERSION) {
396 scan_read(this, buf, (loff_t)td->pages[0] << this->page_shift,
397 mtd->writesize, td);
398 td->version[0] = buf[bbt_get_ver_offs(this, td)];
400 td->pages[0], td->version[0]);
512 * @td: descriptor for the bad block table
524 struct nand_bbt_descr *td)
535 if (td->options & NAND_BBT_LASTBLOCK) {
544 if (td->options & NAND_BBT_PERCHIP) {
555 td->version[i] = 0;
556 td->pages[i] = -1;
558 for (block = 0; block < td->maxblocks; block++) {
564 scan_read(this, buf, offs, mtd->writesize, td);
565 if (!check_pattern(buf, scanlen, mtd->writesize, td)) {
566 td->pages[i] = actblock << blocktopage;
567 if (td->options & NAND_BBT_VERSION) {
568 offs = bbt_get_ver_offs(this, td);
569 td->version[i] = buf[offs];
578 if (td->pages[i] == -1)
582 td->pages[i], td->version[i]);
591 * @td: descriptor for the bad block table
597 struct nand_bbt_descr *td,
601 search_bbt(this, buf, td);
611 * @td: the BBT description
617 * all blocks are already used of marked bad. If td->pages[chip] was already
621 static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td,
630 * td->pages.
632 if (td->pages[chip] != -1)
633 return td->pages[chip] >>
637 if (!(td->options & NAND_BBT_PERCHIP))
644 if (td->options & NAND_BBT_LASTBLOCK) {
652 for (i = 0; i < td->maxblocks; i++) {
675 * @td: the BBT description
682 * td->pages[] entry.
685 struct nand_bbt_descr *td,
699 td->pages[chip] = -1;
706 * @td: descriptor for the bad block table
713 struct nand_bbt_descr *td, struct nand_bbt_descr *md,
723 uint8_t rcode = td->reserved_block_code;
736 if (td->options & NAND_BBT_PERCHIP) {
754 block = get_bbt_block(this, td, md, chip);
768 bits = td->options & NAND_BBT_NRBITS_MSK;
789 if (td->options & NAND_BBT_SAVECONTENT) {
815 } else if (td->options & NAND_BBT_NO_OOB) {
817 offs = td->len;
819 if (td->options & NAND_BBT_VERSION)
829 memcpy(buf, td->pattern, td->len);
841 memcpy(&buf[ooboffs + td->offs], td->pattern, td->len);
844 if (td->options & NAND_BBT_VERSION)
845 buf[ooboffs + td->veroffs] = td->version[chip];
863 mark_bbt_block_bad(this, td, chip, block);
868 td->options & NAND_BBT_NO_OOB ?
873 mark_bbt_block_bad(this, td, chip, block);
878 (unsigned long long)to, td->version[chip]);
881 td->pages[chip++] = page;
921 struct nand_bbt_descr *td = this->bbt_td;
926 if (td->options & NAND_BBT_PERCHIP)
938 chipsel = (td->options & NAND_BBT_PERCHIP) ? i : -1;
941 if (td->pages[i] == -1 && md->pages[i] == -1) {
944 } else if (td->pages[i] == -1) {
948 rd = td;
950 } else if (td->version[i] == md->version[i]) {
951 rd = td;
952 if (!(td->options & NAND_BBT_VERSION))
954 } else if (((int8_t)(td->version[i] - md->version[i])) > 0) {
955 rd = td;
962 if (td->pages[i] == -1) {
966 rd = td;
972 if (!(td->options & NAND_BBT_CREATE))
979 td->version[i] = 1;
1013 td->version[i] = max(td->version[i], md->version[i]);
1014 md->version[i] = td->version[i];
1018 if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) {
1019 res = write_bbt(this, buf, td, md, chipsel);
1026 res = write_bbt(this, buf, md, td, chipsel);
1047 struct nand_bbt_descr *td = this->bbt_td;
1050 if (!this->bbt || !td)
1061 if (td->options & NAND_BBT_PERCHIP) {
1069 td->version[chip]++;
1074 if (td->options & NAND_BBT_WRITE) {
1075 res = write_bbt(this, buf, td, md, chipsel);
1081 res = write_bbt(this, buf, md, td, chipsel);
1092 * @td: bad block table descriptor
1097 static void mark_bbt_region(struct nand_chip *this, struct nand_bbt_descr *td)
1105 if (td->options & NAND_BBT_PERCHIP) {
1114 if ((td->options & NAND_BBT_ABSPAGE) ||
1115 !(td->options & NAND_BBT_WRITE)) {
1116 if (td->pages[i] == -1)
1118 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift);
1122 td->reserved_block_code)
1128 if (td->options & NAND_BBT_LASTBLOCK)
1129 block = ((i + 1) * nrblocks) - td->maxblocks;
1132 for (j = 0; j < td->maxblocks; j++) {
1144 if (update && td->reserved_block_code)
1216 struct nand_bbt_descr *td = this->bbt_td;
1232 if (!td) {
1239 verify_bbt_descr(this, td);
1252 if (td->options & NAND_BBT_ABSPAGE) {
1253 read_abs_bbts(this, buf, td, md);
1256 search_read_bbts(this, buf, td, md);
1264 mark_bbt_region(this, td);