/* Return: 0 in case of success, a negative error code otherwise.  */
int nanddev_bbt_init(struct nand_device *nand)
/* Return: 0 in case of success, a negative error code otherwise.  */
int nanddev_bbt_init(struct nand_device *nand)
{
	unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
	unsigned int nblocks = nanddev_neraseblocks(nand);
	unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block,
					   BITS_PER_LONG);
	nand->bbt.cache = kzalloc(nwords, GFP_KERNEL);
	if (!nand->bbt.cache)
		return -ENOMEM;
	return 0;
}