[U-Boot] [PATCH 3/6] jffs2: rewrite jffs2 scanning code based on Linux one
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Thu Nov 13 19:06:05 CET 2008
>
> /* start at the beginning of the partition */
> - while (offset < max) {
> - if ((oldoffset >> SPIN_BLKSIZE) != (offset >> SPIN_BLKSIZE)) {
> - printf("\b\b%c ", spinner[counter++ % sizeof(spinner)]);
> - oldoffset = offset;
> - }
> + for (i = 0; i < nr_sectors; i++) {
> + uint32_t sector_ofs = i * part->sector_size;
> + uint32_t buf_ofs = sector_ofs;
> + uint32_t buf_len = EMPTY_SCAN_SIZE(part->sector_size);
> + uint32_t ofs, prevofs;
>
> WATCHDOG_RESET();
> + get_fl_mem((u32)part->offset + buf_ofs, buf_len, buf);
>
> - node = (struct jffs2_unknown_node *) get_node_mem((u32)part->offset + offset);
> - if (node->magic == JFFS2_MAGIC_BITMASK && hdr_crc(node)) {
> + /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
> + ofs = 0;
> +
> + /* Scan only 4KiB of 0xFF before declaring it's empty */
> + while (ofs < EMPTY_SCAN_SIZE(part->sector_size) &&
> + *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF)
please use readx/writex
> + ofs += 4;
> +
> + if (ofs == EMPTY_SCAN_SIZE(part->sector_size))
> + continue;
> +
> + ofs += sector_ofs;
> + prevofs = ofs - 1;
> +
> + scan_more:
> + while (ofs < sector_ofs + part->sector_size) {
> + if (ofs == prevofs) {
> + printf("offset %08x already seen, skip\n", ofs);
> + ofs += 4;
> + counter4++;
> + continue;
> + }
> + prevofs = ofs;
> + if (sector_ofs + part->sector_size <
> + ofs + sizeof(*node))
> + break;
> + if (buf_ofs + buf_len < ofs + sizeof(*node)) {
> + buf_len = min_t(uint32_t, buf_size, sector_ofs
> + + part->sector_size - ofs);
> + get_fl_mem((u32)part->offset + ofs, buf_len,
> + buf);
> + buf_ofs = ofs;
> + }
> +
> + node = (struct jffs2_unknown_node *)&buf[ofs-buf_ofs];
> +
> + if (*(uint32_t *)(&buf[ofs-buf_ofs]) == 0xffffffff) {
please use readx/writex
> + uint32_t inbuf_ofs;
> + uint32_t empty_start, scan_end;
> +
> + empty_start = ofs;
> + ofs += 4;
> + scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(
> + part->sector_size)/8,
> + buf_len);
> + more_empty:
> + inbuf_ofs = ofs - buf_ofs;
> + while (inbuf_ofs < scan_end) {
> + if (*(uint32_t *)(&buf[inbuf_ofs]) !=
> + 0xffffffff)
please use readx/writex and so on
Best Regards,
J.
More information about the U-Boot
mailing list