/** * nanddev_bbt_init() - Initialize the BBT (Bad Block Table) * @nand: NAND device * * Initialize the in-memory BBT. * * Return: 0 in case of success, a negative error code otherwise.
*/ int nanddev_bbt_init(struct nand_device *nand)
{ unsignedint bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS); unsignedint nblocks = nanddev_neraseblocks(nand);
nand->bbt.cache = bitmap_zalloc(nblocks * bits_per_block, GFP_KERNEL); if (!nand->bbt.cache) return -ENOMEM;
return 0;
}
EXPORT_SYMBOL_GPL(nanddev_bbt_init);
/** * nanddev_bbt_cleanup() - Cleanup the BBT (Bad Block Table) * @nand: NAND device * * Undoes what has been done in nanddev_bbt_init()
*/ void nanddev_bbt_cleanup(struct nand_device *nand)
{
bitmap_free(nand->bbt.cache);
}
EXPORT_SYMBOL_GPL(nanddev_bbt_cleanup);
/** * nanddev_bbt_update() - Update a BBT * @nand: nand device * * Update the BBT. Currently a NOP function since on-flash bbt is not yet * supported. * * Return: 0 in case of success, a negative error code otherwise.
*/ int nanddev_bbt_update(struct nand_device *nand)
{ return 0;
}
EXPORT_SYMBOL_GPL(nanddev_bbt_update);
/** * nanddev_bbt_get_block_status() - Return the status of an eraseblock * @nand: nand device * @entry: the BBT entry * * Return: a positive number nand_bbt_block_status status or -%ERANGE if @entry * is bigger than the BBT size.
*/ int nanddev_bbt_get_block_status(conststruct nand_device *nand, unsignedint entry)
{ unsignedint bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS); unsignedlong *pos = nand->bbt.cache +
((entry * bits_per_block) / BITS_PER_LONG); unsignedint offs = (entry * bits_per_block) % BITS_PER_LONG; unsignedlong status;
if (entry >= nanddev_neraseblocks(nand)) return -ERANGE;
status = pos[0] >> offs; if (bits_per_block + offs > BITS_PER_LONG)
status |= pos[1] << (BITS_PER_LONG - offs);
return status & GENMASK(bits_per_block - 1, 0);
}
EXPORT_SYMBOL_GPL(nanddev_bbt_get_block_status);
/** * nanddev_bbt_set_block_status() - Update the status of an eraseblock in the * in-memory BBT * @nand: nand device * @entry: the BBT entry to update * @status: the new status * * Update an entry of the in-memory BBT. If you want to push the updated BBT * the NAND you should call nanddev_bbt_update(). * * Return: 0 in case of success or -%ERANGE if @entry is bigger than the BBT * size.
*/ int nanddev_bbt_set_block_status(struct nand_device *nand, unsignedint entry, enum nand_bbt_block_status status)
{ unsignedint bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS); unsignedlong *pos = nand->bbt.cache +
((entry * bits_per_block) / BITS_PER_LONG); unsignedint offs = (entry * bits_per_block) % BITS_PER_LONG; unsignedlong val = status & GENMASK(bits_per_block - 1, 0);
if (entry >= nanddev_neraseblocks(nand)) return -ERANGE;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.