This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

擦除块bit位翻转处理如何修改到3.2内核中



各位好。

       最近在看4.x的内核与我们现在使用的3.2内核代码差异,发现4.x内核中增加了一个擦除块bit位翻转的处理函数,尝试将这部分代码改到3.2内核中后(由于内核代码差异比较大,完全靠自己的感觉来修改的)启动系统总是报告错误启动失败,这里想请TI的工程师们看看这个功能如何修改到3.2内核中去?因为我们现在产品使用的是3.2版本的内核,升级内核暂时没有能力去做。先谢谢了。

下面贴出来的是比较新的内核代码中的处理擦除块bit位翻转的函数:

/**
* erased_sector_bitflips - count bit flips
* @data: data sector buffer
* @oob: oob buffer
* @info: omap_nand_info
*
* Check the bit flips in erased page falls below correctable level.
* If falls below, report the page as erased with correctable bit
* flip, else report as uncorrectable page.
*/
static int erased_sector_bitflips(u_char *data, u_char *oob,
struct omap_nand_info *info)
{
int flip_bits = 0, i;

for (i = 0; i < info->nand.ecc.size; i++) {
flip_bits += hweight8(~data[i]);
if (flip_bits > info->nand.ecc.strength)
return 0;
}

for (i = 0; i < info->nand.ecc.bytes - 1; i++) {
flip_bits += hweight8(~oob[i]);
if (flip_bits > info->nand.ecc.strength)
return 0;
}

/*
* Bit flips falls in correctable level.
* Fill data area with 0xFF
*/
if (flip_bits) {
memset(data, 0xFF, info->nand.ecc.size);
memset(oob, 0xFF, info->nand.ecc.bytes);
}

return flip_bits;
}