梦sui心飞 发表于 2012-07-10 17:18

mtd模块的函数求指导

在nand_bbt.c有个nand_isbad_bbt函数的实现,看解释了解诶函数的作用问题是中间的异味操作完全不看不明白
        block = (int) (offs >> (this->bbt_erase_shift - 1));这里获得了关于传入偏移地址的转换成块个数的2倍,
紧接着后面的位移操作就不怎么明白了
        res = (this->bbt >> (block & 0x06)) & 0x03;
????????????????????????
与运算不就是获得有1位上颚操作吗?但是..........
求大神指导一下,谢谢了颚!

梦sui心飞 发表于 2012-07-10 17:20

int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt)
{
        struct nand_chip *this = mtd->priv;
        int block;
        uint8_t        res;
       
        /* Get block number * 2 */
        block = (int) (offs >> (this->bbt_erase_shift - 1));
        res = (this->bbt >> (block & 0x06)) & 0x03;

        DEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n",
                (unsigned int)offs, block >> 1, res);

        switch ((int)res) {
        case 0x00:        return 0;
        case 0x01:        return 1;
        case 0x02:        return allowbbt ? 0 : 1;
        }
        return 1;
}
这是整段代码
页: [1]
查看完整版本: mtd模块的函数求指导