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]);
451 static int bbt_block_checkbad(struct nand_chip *this, struct nand_bbt_descr *td,
461 if (!(td->options & NAND_BBT_NO_OOB) &&
462 td->offs >= bd->offs && td->offs < bd->offs + bd->len)
541 * @td: descriptor for the bad block table
553 struct nand_bbt_descr *td)
564 if (td->options & NAND_BBT_LASTBLOCK) {
573 if (td->options & NAND_BBT_PERCHIP) {
584 td->version[i] = 0;
585 td->pages[i] = -1;
587 for (block = 0; block < td->maxblocks; block++) {
593 if (bbt_block_checkbad(this, td, offs, buf))
597 scan_read(this, buf, offs, mtd->writesize, td);
598 if (!check_pattern(buf, scanlen, mtd->writesize, td)) {
599 td->pages[i] = actblock << blocktopage;
600 if (td->options & NAND_BBT_VERSION) {
601 offs = bbt_get_ver_offs(this, td);
602 td->version[i] = buf[offs];
611 if (td->pages[i] == -1)
615 td->pages[i], td->version[i]);
624 * @td: descriptor for the bad block table
630 struct nand_bbt_descr *td,
634 search_bbt(this, buf, td);
644 * @td: the BBT description
650 * all blocks are already used of marked bad. If td->pages[chip] was already
654 static int get_bbt_block(struct nand_chip *this, struct nand_bbt_descr *td,
663 * td->pages.
665 if (td->pages[chip] != -1)
666 return td->pages[chip] >>
670 if (!(td->options & NAND_BBT_PERCHIP))
677 if (td->options & NAND_BBT_LASTBLOCK) {
685 for (i = 0; i < td->maxblocks; i++) {
708 * @td: the BBT description
715 * td->pages[] entry.
718 struct nand_bbt_descr *td,
732 td->pages[chip] = -1;
739 * @td: descriptor for the bad block table
746 struct nand_bbt_descr *td, struct nand_bbt_descr *md,
756 uint8_t rcode = td->reserved_block_code;
769 if (td->options & NAND_BBT_PERCHIP) {
787 block = get_bbt_block(this, td, md, chip);
801 bits = td->options & NAND_BBT_NRBITS_MSK;
822 if (td->options & NAND_BBT_SAVECONTENT) {
848 } else if (td->options & NAND_BBT_NO_OOB) {
850 offs = td->len;
852 if (td->options & NAND_BBT_VERSION)
862 memcpy(buf, td->pattern, td->len);
874 memcpy(&buf[ooboffs + td->offs], td->pattern, td->len);
877 if (td->options & NAND_BBT_VERSION)
878 buf[ooboffs + td->veroffs] = td->version[chip];
896 mark_bbt_block_bad(this, td, chip, block);
901 td->options & NAND_BBT_NO_OOB ?
906 mark_bbt_block_bad(this, td, chip, block);
911 (unsigned long long)to, td->version[chip]);
914 td->pages[chip++] = page;
954 struct nand_bbt_descr *td = this->bbt_td;
959 if (td->options & NAND_BBT_PERCHIP)
971 chipsel = (td->options & NAND_BBT_PERCHIP) ? i : -1;
974 if (td->pages[i] == -1 && md->pages[i] == -1) {
977 } else if (td->pages[i] == -1) {
981 rd = td;
983 } else if (td->version[i] == md->version[i]) {
984 rd = td;
985 if (!(td->options & NAND_BBT_VERSION))
987 } else if (((int8_t)(td->version[i] - md->version[i])) > 0) {
988 rd = td;
995 if (td->pages[i] == -1) {
999 rd = td;
1005 if (!(td->options & NAND_BBT_CREATE))
1012 td->version[i] = 1;
1046 td->version[i] = max(td->version[i], md->version[i]);
1047 md->version[i] = td->version[i];
1051 if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) {
1052 res = write_bbt(this, buf, td, md, chipsel);
1059 res = write_bbt(this, buf, md, td, chipsel);
1080 struct nand_bbt_descr *td = this->bbt_td;
1083 if (!this->bbt || !td)
1094 if (td->options & NAND_BBT_PERCHIP) {
1102 td->version[chip]++;
1107 if (td->options & NAND_BBT_WRITE) {
1108 res = write_bbt(this, buf, td, md, chipsel);
1114 res = write_bbt(this, buf, md, td, chipsel);
1125 * @td: bad block table descriptor
1130 static void mark_bbt_region(struct nand_chip *this, struct nand_bbt_descr *td)
1138 if (td->options & NAND_BBT_PERCHIP) {
1147 if ((td->options & NAND_BBT_ABSPAGE) ||
1148 !(td->options & NAND_BBT_WRITE)) {
1149 if (td->pages[i] == -1)
1151 block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift);
1155 td->reserved_block_code)
1161 if (td->options & NAND_BBT_LASTBLOCK)
1162 block = ((i + 1) * nrblocks) - td->maxblocks;
1165 for (j = 0; j < td->maxblocks; j++) {
1177 if (update && td->reserved_block_code)
1249 struct nand_bbt_descr *td = this->bbt_td;
1265 if (!td) {
1272 verify_bbt_descr(this, td);
1285 if (td->options & NAND_BBT_ABSPAGE) {
1286 read_abs_bbts(this, buf, td, md);
1289 search_read_bbts(this, buf, td, md);
1297 mark_bbt_region(this, td);