/* This function allocates and initializes a nand_bbt_descr for BBM detection based on the properties of "this". The new descriptor is stored in this->badblock_pattern. Thus, this->badblock_pattern should be NULL when passed to this function.  */
static int nand_create_default_bbt_descr(struct nand_chip *this)
/* This function allocates and initializes a nand_bbt_descr for BBM detection based on the properties of "this". The new descriptor is stored in this->badblock_pattern. Thus, this->badblock_pattern should be NULL when passed to this function.  */
static int nand_create_default_bbt_descr(struct nand_chip *this)
{
	struct nand_bbt_descr *bd;
	if (this->badblock_pattern) {
		printk(KERN_WARNING "BBT descr already allocated; not replacing.\n");
		return -EINVAL;
	}
	bd = kzalloc(sizeof(*bd), GFP_KERNEL);
	if (!bd) {
		printk(KERN_ERR "nand_create_default_bbt_descr: Out of memory\n");
		return -ENOMEM;
	}
	bd->options = this->options & BBT_SCAN_OPTIONS;
	bd->offs = this->badblockpos;
	bd->len = (this->options & NAND_BUSWIDTH_16) ? 2 : 1;
	bd->pattern = scan_ff_pattern;
	bd->options |= NAND_BBT_DYNAMICSTRUCT;
	this->badblock_pattern = bd;
	return 0;
}