mtd: nand: multi-line comment style fixups
Artem: while on it, do other commentaries clean-ups: 1. Start one-line comments with capital letter and no dot at the end 2. Turn sparse multi-line comments into one-line comments 3. Change "phrase ?" to "phrase?" and the same with "!". 4. Remove tabs from the kerneldoc parameters comments - they are mixed with tabs often, and inconsistent. 5. Put dot at the end of descriptions in kerneldoc comments. 6. Some other small commentaries clean-ups Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
parent
18f8eb1b23
commit
8b6e50c9eb
File diff suppressed because it is too large
Load diff
|
@ -80,17 +80,15 @@ static int check_pattern_no_oob(uint8_t *buf, struct nand_bbt_descr *td)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check_pattern - [GENERIC] check if a pattern is in the buffer
|
* check_pattern - [GENERIC] check if a pattern is in the buffer
|
||||||
* @buf: the buffer to search
|
* @buf: the buffer to search
|
||||||
* @len: the length of buffer to search
|
* @len: the length of buffer to search
|
||||||
* @paglen: the pagelength
|
* @paglen: the pagelength
|
||||||
* @td: search pattern descriptor
|
* @td: search pattern descriptor
|
||||||
*
|
*
|
||||||
* Check for a pattern at the given place. Used to search bad block
|
* Check for a pattern at the given place. Used to search bad block tables and
|
||||||
* tables and good / bad block identifiers.
|
* good / bad block identifiers. If the SCAN_EMPTY option is set then check, if
|
||||||
* If the SCAN_EMPTY option is set then check, if all bytes except the
|
* all bytes except the pattern area contain 0xff.
|
||||||
* pattern area contain 0xff
|
*/
|
||||||
*
|
|
||||||
*/
|
|
||||||
static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
|
static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
|
||||||
{
|
{
|
||||||
int i, end = 0;
|
int i, end = 0;
|
||||||
|
@ -127,14 +125,13 @@ static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_desc
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check_short_pattern - [GENERIC] check if a pattern is in the buffer
|
* check_short_pattern - [GENERIC] check if a pattern is in the buffer
|
||||||
* @buf: the buffer to search
|
* @buf: the buffer to search
|
||||||
* @td: search pattern descriptor
|
* @td: search pattern descriptor
|
||||||
*
|
*
|
||||||
* Check for a pattern at the given place. Used to search bad block
|
* Check for a pattern at the given place. Used to search bad block tables and
|
||||||
* tables and good / bad block identifiers. Same as check_pattern, but
|
* good / bad block identifiers. Same as check_pattern, but no optional empty
|
||||||
* no optional empty check
|
* check.
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
|
static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -150,7 +147,7 @@ static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add_marker_len - compute the length of the marker in data area
|
* add_marker_len - compute the length of the marker in data area
|
||||||
* @td: BBT descriptor used for computation
|
* @td: BBT descriptor used for computation
|
||||||
*
|
*
|
||||||
* The length will be 0 if the markeris located in OOB area.
|
* The length will be 0 if the markeris located in OOB area.
|
||||||
*/
|
*/
|
||||||
|
@ -169,15 +166,14 @@ static u32 add_marker_len(struct nand_bbt_descr *td)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read_bbt - [GENERIC] Read the bad block table starting from page
|
* read_bbt - [GENERIC] Read the bad block table starting from page
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @buf: temporary buffer
|
* @buf: temporary buffer
|
||||||
* @page: the starting page
|
* @page: the starting page
|
||||||
* @num: the number of bbt descriptors to read
|
* @num: the number of bbt descriptors to read
|
||||||
* @td: the bbt describtion table
|
* @td: the bbt describtion table
|
||||||
* @offs: offset in the memory table
|
* @offs: offset in the memory table
|
||||||
*
|
*
|
||||||
* Read the bad block table starting from page.
|
* Read the bad block table starting from page.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
|
static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
|
||||||
struct nand_bbt_descr *td, int offs)
|
struct nand_bbt_descr *td, int offs)
|
||||||
|
@ -229,11 +225,13 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
|
||||||
mtd->ecc_stats.bbtblocks++;
|
mtd->ecc_stats.bbtblocks++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Leave it for now, if its matured we can move this
|
/*
|
||||||
* message to MTD_DEBUG_LEVEL0 */
|
* Leave it for now, if it's matured we can
|
||||||
|
* move this message to MTD_DEBUG_LEVEL0.
|
||||||
|
*/
|
||||||
printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%012llx\n",
|
printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%012llx\n",
|
||||||
(loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
|
(loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
|
||||||
/* Factory marked bad or worn out ? */
|
/* Factory marked bad or worn out? */
|
||||||
if (tmp == 0)
|
if (tmp == 0)
|
||||||
this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06);
|
this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06);
|
||||||
else
|
else
|
||||||
|
@ -249,15 +247,15 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read_abs_bbt - [GENERIC] Read the bad block table starting at a given page
|
* read_abs_bbt - [GENERIC] Read the bad block table starting at a given page
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @buf: temporary buffer
|
* @buf: temporary buffer
|
||||||
* @td: descriptor for the bad block table
|
* @td: descriptor for the bad block table
|
||||||
* @chip: read the table for a specific chip, -1 read all chips.
|
* @chip: read the table for a specific chip, -1 read all chips; aplies only if
|
||||||
* Applies only if NAND_BBT_PERCHIP option is set
|
* NAND_BBT_PERCHIP option is set
|
||||||
*
|
*
|
||||||
* Read the bad block table for all chips starting at a given page
|
* Read the bad block table for all chips starting at a given page. We assume
|
||||||
* We assume that the bbt bits are in consecutive order.
|
* that the bbt bits are in consecutive order.
|
||||||
*/
|
*/
|
||||||
static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip)
|
static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
|
@ -283,9 +281,7 @@ static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* BBT marker is in the first page, no OOB */
|
||||||
* BBT marker is in the first page, no OOB.
|
|
||||||
*/
|
|
||||||
static int scan_read_raw_data(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
|
static int scan_read_raw_data(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
|
||||||
struct nand_bbt_descr *td)
|
struct nand_bbt_descr *td)
|
||||||
{
|
{
|
||||||
|
@ -299,9 +295,7 @@ static int scan_read_raw_data(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
|
||||||
return mtd->read(mtd, offs, len, &retlen, buf);
|
return mtd->read(mtd, offs, len, &retlen, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Scan read raw data from flash */
|
||||||
* Scan read raw data from flash
|
|
||||||
*/
|
|
||||||
static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
|
static int scan_read_raw_oob(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
|
@ -344,9 +338,7 @@ static int scan_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t offs,
|
||||||
return scan_read_raw_oob(mtd, buf, offs, len);
|
return scan_read_raw_oob(mtd, buf, offs, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Scan write data with oob to flash */
|
||||||
* Scan write data with oob to flash
|
|
||||||
*/
|
|
||||||
static int scan_write_bbt(struct mtd_info *mtd, loff_t offs, size_t len,
|
static int scan_write_bbt(struct mtd_info *mtd, loff_t offs, size_t len,
|
||||||
uint8_t *buf, uint8_t *oob)
|
uint8_t *buf, uint8_t *oob)
|
||||||
{
|
{
|
||||||
|
@ -373,15 +365,14 @@ static u32 bbt_get_ver_offs(struct mtd_info *mtd, struct nand_bbt_descr *td)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read_abs_bbts - [GENERIC] Read the bad block table(s) for all chips starting at a given page
|
* read_abs_bbts - [GENERIC] Read the bad block table(s) for all chips starting at a given page
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @buf: temporary buffer
|
* @buf: temporary buffer
|
||||||
* @td: descriptor for the bad block table
|
* @td: descriptor for the bad block table
|
||||||
* @md: descriptor for the bad block table mirror
|
* @md: descriptor for the bad block table mirror
|
||||||
*
|
*
|
||||||
* Read the bad block table(s) for all chips starting at a given page
|
* Read the bad block table(s) for all chips starting at a given page. We
|
||||||
* We assume that the bbt bits are in consecutive order.
|
* assume that the bbt bits are in consecutive order.
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
|
static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
|
||||||
struct nand_bbt_descr *td, struct nand_bbt_descr *md)
|
struct nand_bbt_descr *td, struct nand_bbt_descr *md)
|
||||||
{
|
{
|
||||||
|
@ -407,9 +398,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Scan a given block full */
|
||||||
* Scan a given block full
|
|
||||||
*/
|
|
||||||
static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
||||||
loff_t offs, uint8_t *buf, size_t readlen,
|
loff_t offs, uint8_t *buf, size_t readlen,
|
||||||
int scanlen, int len)
|
int scanlen, int len)
|
||||||
|
@ -427,9 +416,7 @@ static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Scan a given block partially */
|
||||||
* Scan a given block partially
|
|
||||||
*/
|
|
||||||
static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
||||||
loff_t offs, uint8_t *buf, int len)
|
loff_t offs, uint8_t *buf, int len)
|
||||||
{
|
{
|
||||||
|
@ -444,9 +431,8 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
||||||
|
|
||||||
for (j = 0; j < len; j++) {
|
for (j = 0; j < len; j++) {
|
||||||
/*
|
/*
|
||||||
* Read the full oob until read_oob is fixed to
|
* Read the full oob until read_oob is fixed to handle single
|
||||||
* handle single byte reads for 16 bit
|
* byte reads for 16 bit buswidth.
|
||||||
* buswidth
|
|
||||||
*/
|
*/
|
||||||
ret = mtd->read_oob(mtd, offs, &ops);
|
ret = mtd->read_oob(mtd, offs, &ops);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -462,14 +448,14 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create_bbt - [GENERIC] Create a bad block table by scanning the device
|
* create_bbt - [GENERIC] Create a bad block table by scanning the device
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @buf: temporary buffer
|
* @buf: temporary buffer
|
||||||
* @bd: descriptor for the good/bad block search pattern
|
* @bd: descriptor for the good/bad block search pattern
|
||||||
* @chip: create the table for a specific chip, -1 read all chips.
|
* @chip: create the table for a specific chip, -1 read all chips; applies only
|
||||||
* Applies only if NAND_BBT_PERCHIP option is set
|
* if NAND_BBT_PERCHIP option is set
|
||||||
*
|
*
|
||||||
* Create a bad block table by scanning the device
|
* Create a bad block table by scanning the device for the given good/bad block
|
||||||
* for the given good/bad block identify pattern
|
* identify pattern.
|
||||||
*/
|
*/
|
||||||
static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
struct nand_bbt_descr *bd, int chip)
|
struct nand_bbt_descr *bd, int chip)
|
||||||
|
@ -500,8 +486,10 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chip == -1) {
|
if (chip == -1) {
|
||||||
/* Note that numblocks is 2 * (real numblocks) here, see i+=2
|
/*
|
||||||
* below as it makes shifting and masking less painful */
|
* Note that numblocks is 2 * (real numblocks) here, see i+=2
|
||||||
|
* below as it makes shifting and masking less painful
|
||||||
|
*/
|
||||||
numblocks = mtd->size >> (this->bbt_erase_shift - 1);
|
numblocks = mtd->size >> (this->bbt_erase_shift - 1);
|
||||||
startblock = 0;
|
startblock = 0;
|
||||||
from = 0;
|
from = 0;
|
||||||
|
@ -549,20 +537,18 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* search_bbt - [GENERIC] scan the device for a specific bad block table
|
* search_bbt - [GENERIC] scan the device for a specific bad block table
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @buf: temporary buffer
|
* @buf: temporary buffer
|
||||||
* @td: descriptor for the bad block table
|
* @td: descriptor for the bad block table
|
||||||
*
|
*
|
||||||
* Read the bad block table by searching for a given ident pattern.
|
* Read the bad block table by searching for a given ident pattern. Search is
|
||||||
* Search is preformed either from the beginning up or from the end of
|
* preformed either from the beginning up or from the end of the device
|
||||||
* the device downwards. The search starts always at the start of a
|
* downwards. The search starts always at the start of a block. If the option
|
||||||
* block.
|
* NAND_BBT_PERCHIP is given, each chip is searched for a bbt, which contains
|
||||||
* If the option NAND_BBT_PERCHIP is given, each chip is searched
|
* the bad block information of this chip. This is necessary to provide support
|
||||||
* for a bbt, which contains the bad block information of this chip.
|
* for certain DOC devices.
|
||||||
* This is necessary to provide support for certain DOC devices.
|
|
||||||
*
|
*
|
||||||
* The bbt ident pattern resides in the oob area of the first page
|
* The bbt ident pattern resides in the oob area of the first page in a block.
|
||||||
* in a block.
|
|
||||||
*/
|
*/
|
||||||
static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td)
|
static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td)
|
||||||
{
|
{
|
||||||
|
@ -573,7 +559,7 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
|
||||||
int bbtblocks;
|
int bbtblocks;
|
||||||
int blocktopage = this->bbt_erase_shift - this->page_shift;
|
int blocktopage = this->bbt_erase_shift - this->page_shift;
|
||||||
|
|
||||||
/* Search direction top -> down ? */
|
/* Search direction top -> down? */
|
||||||
if (td->options & NAND_BBT_LASTBLOCK) {
|
if (td->options & NAND_BBT_LASTBLOCK) {
|
||||||
startblock = (mtd->size >> this->bbt_erase_shift) - 1;
|
startblock = (mtd->size >> this->bbt_erase_shift) - 1;
|
||||||
dir = -1;
|
dir = -1;
|
||||||
|
@ -582,7 +568,7 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
|
||||||
dir = 1;
|
dir = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do we have a bbt per chip ? */
|
/* Do we have a bbt per chip? */
|
||||||
if (td->options & NAND_BBT_PERCHIP) {
|
if (td->options & NAND_BBT_PERCHIP) {
|
||||||
chips = this->numchips;
|
chips = this->numchips;
|
||||||
bbtblocks = this->chipsize >> this->bbt_erase_shift;
|
bbtblocks = this->chipsize >> this->bbt_erase_shift;
|
||||||
|
@ -631,13 +617,13 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* search_read_bbts - [GENERIC] scan the device for bad block table(s)
|
* search_read_bbts - [GENERIC] scan the device for bad block table(s)
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @buf: temporary buffer
|
* @buf: temporary buffer
|
||||||
* @td: descriptor for the bad block table
|
* @td: descriptor for the bad block table
|
||||||
* @md: descriptor for the bad block table mirror
|
* @md: descriptor for the bad block table mirror
|
||||||
*
|
*
|
||||||
* Search and read the bad block table(s)
|
* Search and read the bad block table(s).
|
||||||
*/
|
*/
|
||||||
static int search_read_bbts(struct mtd_info *mtd, uint8_t * buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md)
|
static int search_read_bbts(struct mtd_info *mtd, uint8_t * buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md)
|
||||||
{
|
{
|
||||||
/* Search the primary table */
|
/* Search the primary table */
|
||||||
|
@ -653,16 +639,14 @@ static int search_read_bbts(struct mtd_info *mtd, uint8_t * buf, struct nand_bbt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* write_bbt - [GENERIC] (Re)write the bad block table
|
* write_bbt - [GENERIC] (Re)write the bad block table
|
||||||
|
* @mtd: MTD device structure
|
||||||
|
* @buf: temporary buffer
|
||||||
|
* @td: descriptor for the bad block table
|
||||||
|
* @md: descriptor for the bad block table mirror
|
||||||
|
* @chipsel: selector for a specific chip, -1 for all
|
||||||
*
|
*
|
||||||
* @mtd: MTD device structure
|
* (Re)write the bad block table.
|
||||||
* @buf: temporary buffer
|
*/
|
||||||
* @td: descriptor for the bad block table
|
|
||||||
* @md: descriptor for the bad block table mirror
|
|
||||||
* @chipsel: selector for a specific chip, -1 for all
|
|
||||||
*
|
|
||||||
* (Re)write the bad block table
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
struct nand_bbt_descr *td, struct nand_bbt_descr *md,
|
struct nand_bbt_descr *td, struct nand_bbt_descr *md,
|
||||||
int chipsel)
|
int chipsel)
|
||||||
|
@ -685,10 +669,10 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
|
|
||||||
if (!rcode)
|
if (!rcode)
|
||||||
rcode = 0xff;
|
rcode = 0xff;
|
||||||
/* Write bad block table per chip rather than per device ? */
|
/* Write bad block table per chip rather than per device? */
|
||||||
if (td->options & NAND_BBT_PERCHIP) {
|
if (td->options & NAND_BBT_PERCHIP) {
|
||||||
numblocks = (int)(this->chipsize >> this->bbt_erase_shift);
|
numblocks = (int)(this->chipsize >> this->bbt_erase_shift);
|
||||||
/* Full device write or specific chip ? */
|
/* Full device write or specific chip? */
|
||||||
if (chipsel == -1) {
|
if (chipsel == -1) {
|
||||||
nrchips = this->numchips;
|
nrchips = this->numchips;
|
||||||
} else {
|
} else {
|
||||||
|
@ -702,8 +686,8 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
|
|
||||||
/* Loop through the chips */
|
/* Loop through the chips */
|
||||||
for (; chip < nrchips; chip++) {
|
for (; chip < nrchips; chip++) {
|
||||||
|
/*
|
||||||
/* There was already a version of the table, reuse the page
|
* There was already a version of the table, reuse the page
|
||||||
* This applies for absolute placement too, as we have the
|
* This applies for absolute placement too, as we have the
|
||||||
* page nr. in td->pages.
|
* page nr. in td->pages.
|
||||||
*/
|
*/
|
||||||
|
@ -712,8 +696,10 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
goto write;
|
goto write;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Automatic placement of the bad block table */
|
/*
|
||||||
/* Search direction top -> down ? */
|
* Automatic placement of the bad block table. Search direction
|
||||||
|
* top -> down?
|
||||||
|
*/
|
||||||
if (td->options & NAND_BBT_LASTBLOCK) {
|
if (td->options & NAND_BBT_LASTBLOCK) {
|
||||||
startblock = numblocks * (chip + 1) - 1;
|
startblock = numblocks * (chip + 1) - 1;
|
||||||
dir = -1;
|
dir = -1;
|
||||||
|
@ -764,7 +750,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
|
|
||||||
to = ((loff_t) page) << this->page_shift;
|
to = ((loff_t) page) << this->page_shift;
|
||||||
|
|
||||||
/* Must we save the block contents ? */
|
/* Must we save the block contents? */
|
||||||
if (td->options & NAND_BBT_SAVECONTENT) {
|
if (td->options & NAND_BBT_SAVECONTENT) {
|
||||||
/* Make it block aligned */
|
/* Make it block aligned */
|
||||||
to &= ~((loff_t) ((1 << this->bbt_erase_shift) - 1));
|
to &= ~((loff_t) ((1 << this->bbt_erase_shift) - 1));
|
||||||
|
@ -798,13 +784,13 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
} else if (td->options & NAND_BBT_NO_OOB) {
|
} else if (td->options & NAND_BBT_NO_OOB) {
|
||||||
ooboffs = 0;
|
ooboffs = 0;
|
||||||
offs = td->len;
|
offs = td->len;
|
||||||
/* the version byte */
|
/* The version byte */
|
||||||
if (td->options & NAND_BBT_VERSION)
|
if (td->options & NAND_BBT_VERSION)
|
||||||
offs++;
|
offs++;
|
||||||
/* Calc length */
|
/* Calc length */
|
||||||
len = (size_t) (numblocks >> sft);
|
len = (size_t) (numblocks >> sft);
|
||||||
len += offs;
|
len += offs;
|
||||||
/* Make it page aligned ! */
|
/* Make it page aligned! */
|
||||||
len = ALIGN(len, mtd->writesize);
|
len = ALIGN(len, mtd->writesize);
|
||||||
/* Preset the buffer with 0xff */
|
/* Preset the buffer with 0xff */
|
||||||
memset(buf, 0xff, len);
|
memset(buf, 0xff, len);
|
||||||
|
@ -813,7 +799,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
} else {
|
} else {
|
||||||
/* Calc length */
|
/* Calc length */
|
||||||
len = (size_t) (numblocks >> sft);
|
len = (size_t) (numblocks >> sft);
|
||||||
/* Make it page aligned ! */
|
/* Make it page aligned! */
|
||||||
len = ALIGN(len, mtd->writesize);
|
len = ALIGN(len, mtd->writesize);
|
||||||
/* Preset the buffer with 0xff */
|
/* Preset the buffer with 0xff */
|
||||||
memset(buf, 0xff, len +
|
memset(buf, 0xff, len +
|
||||||
|
@ -827,13 +813,13 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
if (td->options & NAND_BBT_VERSION)
|
if (td->options & NAND_BBT_VERSION)
|
||||||
buf[ooboffs + td->veroffs] = td->version[chip];
|
buf[ooboffs + td->veroffs] = td->version[chip];
|
||||||
|
|
||||||
/* walk through the memory table */
|
/* Walk through the memory table */
|
||||||
for (i = 0; i < numblocks;) {
|
for (i = 0; i < numblocks;) {
|
||||||
uint8_t dat;
|
uint8_t dat;
|
||||||
dat = this->bbt[bbtoffs + (i >> 2)];
|
dat = this->bbt[bbtoffs + (i >> 2)];
|
||||||
for (j = 0; j < 4; j++, i++) {
|
for (j = 0; j < 4; j++, i++) {
|
||||||
int sftcnt = (i << (3 - sft)) & sftmsk;
|
int sftcnt = (i << (3 - sft)) & sftmsk;
|
||||||
/* Do not store the reserved bbt blocks ! */
|
/* Do not store the reserved bbt blocks! */
|
||||||
buf[offs + (i >> sft)] &=
|
buf[offs + (i >> sft)] &=
|
||||||
~(msk[dat & 0x03] << sftcnt);
|
~(msk[dat & 0x03] << sftcnt);
|
||||||
dat >>= 2;
|
dat >>= 2;
|
||||||
|
@ -870,12 +856,12 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_memory_bbt - [GENERIC] create a memory based bad block table
|
* nand_memory_bbt - [GENERIC] create a memory based bad block table
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @bd: descriptor for the good/bad block search pattern
|
* @bd: descriptor for the good/bad block search pattern
|
||||||
*
|
*
|
||||||
* The function creates a memory based bbt by scanning the device
|
* The function creates a memory based bbt by scanning the device for
|
||||||
* for manufacturer / software marked good / bad blocks
|
* manufacturer / software marked good / bad blocks.
|
||||||
*/
|
*/
|
||||||
static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
|
@ -886,16 +872,15 @@ static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *b
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check_create - [GENERIC] create and write bbt(s) if necessary
|
* check_create - [GENERIC] create and write bbt(s) if necessary
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @buf: temporary buffer
|
* @buf: temporary buffer
|
||||||
* @bd: descriptor for the good/bad block search pattern
|
* @bd: descriptor for the good/bad block search pattern
|
||||||
*
|
*
|
||||||
* The function checks the results of the previous call to read_bbt
|
* The function checks the results of the previous call to read_bbt and creates
|
||||||
* and creates / updates the bbt(s) if necessary
|
* / updates the bbt(s) if necessary. Creation is necessary if no bbt was found
|
||||||
* Creation is necessary if no bbt was found for the chip/device
|
* for the chip/device. Update is necessary if one of the tables is missing or
|
||||||
* Update is necessary if one of the tables is missing or the
|
* the version nr. of one table is less than the other.
|
||||||
* version nr. of one table is less than the other
|
*/
|
||||||
*/
|
|
||||||
static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd)
|
static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd)
|
||||||
{
|
{
|
||||||
int i, chips, writeops, chipsel, res;
|
int i, chips, writeops, chipsel, res;
|
||||||
|
@ -904,7 +889,7 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
|
||||||
struct nand_bbt_descr *md = this->bbt_md;
|
struct nand_bbt_descr *md = this->bbt_md;
|
||||||
struct nand_bbt_descr *rd, *rd2;
|
struct nand_bbt_descr *rd, *rd2;
|
||||||
|
|
||||||
/* Do we have a bbt per chip ? */
|
/* Do we have a bbt per chip? */
|
||||||
if (td->options & NAND_BBT_PERCHIP)
|
if (td->options & NAND_BBT_PERCHIP)
|
||||||
chips = this->numchips;
|
chips = this->numchips;
|
||||||
else
|
else
|
||||||
|
@ -914,9 +899,9 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
|
||||||
writeops = 0;
|
writeops = 0;
|
||||||
rd = NULL;
|
rd = NULL;
|
||||||
rd2 = NULL;
|
rd2 = NULL;
|
||||||
/* Per chip or per device ? */
|
/* Per chip or per device? */
|
||||||
chipsel = (td->options & NAND_BBT_PERCHIP) ? i : -1;
|
chipsel = (td->options & NAND_BBT_PERCHIP) ? i : -1;
|
||||||
/* Mirrored table available ? */
|
/* Mirrored table available? */
|
||||||
if (md) {
|
if (md) {
|
||||||
if (td->pages[i] == -1 && md->pages[i] == -1) {
|
if (td->pages[i] == -1 && md->pages[i] == -1) {
|
||||||
writeops = 0x03;
|
writeops = 0x03;
|
||||||
|
@ -965,7 +950,7 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
|
||||||
goto writecheck;
|
goto writecheck;
|
||||||
}
|
}
|
||||||
create:
|
create:
|
||||||
/* Create the bad block table by scanning the device ? */
|
/* Create the bad block table by scanning the device? */
|
||||||
if (!(td->options & NAND_BBT_CREATE))
|
if (!(td->options & NAND_BBT_CREATE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -977,21 +962,21 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
|
||||||
if (md)
|
if (md)
|
||||||
md->version[i] = 1;
|
md->version[i] = 1;
|
||||||
writecheck:
|
writecheck:
|
||||||
/* read back first ? */
|
/* Read back first? */
|
||||||
if (rd)
|
if (rd)
|
||||||
read_abs_bbt(mtd, buf, rd, chipsel);
|
read_abs_bbt(mtd, buf, rd, chipsel);
|
||||||
/* If they weren't versioned, read both. */
|
/* If they weren't versioned, read both */
|
||||||
if (rd2)
|
if (rd2)
|
||||||
read_abs_bbt(mtd, buf, rd2, chipsel);
|
read_abs_bbt(mtd, buf, rd2, chipsel);
|
||||||
|
|
||||||
/* Write the bad block table to the device ? */
|
/* Write the bad block table to the device? */
|
||||||
if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) {
|
if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) {
|
||||||
res = write_bbt(mtd, buf, td, md, chipsel);
|
res = write_bbt(mtd, buf, td, md, chipsel);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the mirror bad block table to the device ? */
|
/* Write the mirror bad block table to the device? */
|
||||||
if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) {
|
if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) {
|
||||||
res = write_bbt(mtd, buf, md, td, chipsel);
|
res = write_bbt(mtd, buf, md, td, chipsel);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
|
@ -1003,20 +988,19 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mark_bbt_regions - [GENERIC] mark the bad block table regions
|
* mark_bbt_regions - [GENERIC] mark the bad block table regions
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @td: bad block table descriptor
|
* @td: bad block table descriptor
|
||||||
*
|
*
|
||||||
* The bad block table regions are marked as "bad" to prevent
|
* The bad block table regions are marked as "bad" to prevent accidental
|
||||||
* accidental erasures / writes. The regions are identified by
|
* erasures / writes. The regions are identified by the mark 0x02.
|
||||||
* the mark 0x02.
|
*/
|
||||||
*/
|
|
||||||
static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)
|
static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
int i, j, chips, block, nrblocks, update;
|
int i, j, chips, block, nrblocks, update;
|
||||||
uint8_t oldval, newval;
|
uint8_t oldval, newval;
|
||||||
|
|
||||||
/* Do we have a bbt per chip ? */
|
/* Do we have a bbt per chip? */
|
||||||
if (td->options & NAND_BBT_PERCHIP) {
|
if (td->options & NAND_BBT_PERCHIP) {
|
||||||
chips = this->numchips;
|
chips = this->numchips;
|
||||||
nrblocks = (int)(this->chipsize >> this->bbt_erase_shift);
|
nrblocks = (int)(this->chipsize >> this->bbt_erase_shift);
|
||||||
|
@ -1053,9 +1037,11 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)
|
||||||
update = 1;
|
update = 1;
|
||||||
block += 2;
|
block += 2;
|
||||||
}
|
}
|
||||||
/* If we want reserved blocks to be recorded to flash, and some
|
/*
|
||||||
new ones have been marked, then we need to update the stored
|
* If we want reserved blocks to be recorded to flash, and some
|
||||||
bbts. This should only happen once. */
|
* new ones have been marked, then we need to update the stored
|
||||||
|
* bbts. This should only happen once.
|
||||||
|
*/
|
||||||
if (update && td->reserved_block_code)
|
if (update && td->reserved_block_code)
|
||||||
nand_update_bbt(mtd, (loff_t)(block - 2) << (this->bbt_erase_shift - 1));
|
nand_update_bbt(mtd, (loff_t)(block - 2) << (this->bbt_erase_shift - 1));
|
||||||
}
|
}
|
||||||
|
@ -1063,8 +1049,8 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* verify_bbt_descr - verify the bad block description
|
* verify_bbt_descr - verify the bad block description
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @bd: the table to verify
|
* @bd: the table to verify
|
||||||
*
|
*
|
||||||
* This functions performs a few sanity checks on the bad block description
|
* This functions performs a few sanity checks on the bad block description
|
||||||
* table.
|
* table.
|
||||||
|
@ -1111,18 +1097,16 @@ static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_scan_bbt - [NAND Interface] scan, find, read and maybe create bad block table(s)
|
* nand_scan_bbt - [NAND Interface] scan, find, read and maybe create bad block table(s)
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @bd: descriptor for the good/bad block search pattern
|
* @bd: descriptor for the good/bad block search pattern
|
||||||
*
|
*
|
||||||
* The function checks, if a bad block table(s) is/are already
|
* The function checks, if a bad block table(s) is/are already available. If
|
||||||
* available. If not it scans the device for manufacturer
|
* not it scans the device for manufacturer marked good / bad blocks and writes
|
||||||
* marked good / bad blocks and writes the bad block table(s) to
|
* the bad block table(s) to the selected place.
|
||||||
* the selected place.
|
|
||||||
*
|
*
|
||||||
* The bad block table memory is allocated here. It must be freed
|
* The bad block table memory is allocated here. It must be freed by calling
|
||||||
* by calling the nand_free_bbt function.
|
* the nand_free_bbt function.
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
|
@ -1132,15 +1116,19 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
||||||
struct nand_bbt_descr *md = this->bbt_md;
|
struct nand_bbt_descr *md = this->bbt_md;
|
||||||
|
|
||||||
len = mtd->size >> (this->bbt_erase_shift + 2);
|
len = mtd->size >> (this->bbt_erase_shift + 2);
|
||||||
/* Allocate memory (2bit per block) and clear the memory bad block table */
|
/*
|
||||||
|
* Allocate memory (2bit per block) and clear the memory bad block
|
||||||
|
* table.
|
||||||
|
*/
|
||||||
this->bbt = kzalloc(len, GFP_KERNEL);
|
this->bbt = kzalloc(len, GFP_KERNEL);
|
||||||
if (!this->bbt) {
|
if (!this->bbt) {
|
||||||
printk(KERN_ERR "nand_scan_bbt: Out of memory\n");
|
printk(KERN_ERR "nand_scan_bbt: Out of memory\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no primary table decriptor is given, scan the device
|
/*
|
||||||
* to build a memory based bad block table
|
* If no primary table decriptor is given, scan the device to build a
|
||||||
|
* memory based bad block table.
|
||||||
*/
|
*/
|
||||||
if (!td) {
|
if (!td) {
|
||||||
if ((res = nand_memory_bbt(mtd, bd))) {
|
if ((res = nand_memory_bbt(mtd, bd))) {
|
||||||
|
@ -1164,7 +1152,7 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is the bbt at a given page ? */
|
/* Is the bbt at a given page? */
|
||||||
if (td->options & NAND_BBT_ABSPAGE) {
|
if (td->options & NAND_BBT_ABSPAGE) {
|
||||||
res = read_abs_bbts(mtd, buf, td, md);
|
res = read_abs_bbts(mtd, buf, td, md);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1186,11 +1174,11 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_update_bbt - [NAND Interface] update bad block table(s)
|
* nand_update_bbt - [NAND Interface] update bad block table(s)
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @offs: the offset of the newly marked block
|
* @offs: the offset of the newly marked block
|
||||||
*
|
*
|
||||||
* The function updates the bad block table(s)
|
* The function updates the bad block table(s).
|
||||||
*/
|
*/
|
||||||
int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
|
int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
|
@ -1214,7 +1202,7 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
|
||||||
|
|
||||||
writeops = md != NULL ? 0x03 : 0x01;
|
writeops = md != NULL ? 0x03 : 0x01;
|
||||||
|
|
||||||
/* Do we have a bbt per chip ? */
|
/* Do we have a bbt per chip? */
|
||||||
if (td->options & NAND_BBT_PERCHIP) {
|
if (td->options & NAND_BBT_PERCHIP) {
|
||||||
chip = (int)(offs >> this->chip_shift);
|
chip = (int)(offs >> this->chip_shift);
|
||||||
chipsel = chip;
|
chipsel = chip;
|
||||||
|
@ -1227,13 +1215,13 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
|
||||||
if (md)
|
if (md)
|
||||||
md->version[chip]++;
|
md->version[chip]++;
|
||||||
|
|
||||||
/* Write the bad block table to the device ? */
|
/* Write the bad block table to the device? */
|
||||||
if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) {
|
if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) {
|
||||||
res = write_bbt(mtd, buf, td, md, chipsel);
|
res = write_bbt(mtd, buf, td, md, chipsel);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/* Write the mirror bad block table to the device ? */
|
/* Write the mirror bad block table to the device? */
|
||||||
if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) {
|
if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) {
|
||||||
res = write_bbt(mtd, buf, md, td, chipsel);
|
res = write_bbt(mtd, buf, md, td, chipsel);
|
||||||
}
|
}
|
||||||
|
@ -1243,8 +1231,10 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define some generic bad / good block scan pattern which are used
|
/*
|
||||||
* while scanning a device for factory marked good / bad blocks. */
|
* Define some generic bad / good block scan pattern which are used
|
||||||
|
* while scanning a device for factory marked good / bad blocks.
|
||||||
|
*/
|
||||||
static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
|
static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
|
||||||
|
|
||||||
static uint8_t scan_agand_pattern[] = { 0x1C, 0x71, 0xC7, 0x1C, 0x71, 0xC7 };
|
static uint8_t scan_agand_pattern[] = { 0x1C, 0x71, 0xC7, 0x1C, 0x71, 0xC7 };
|
||||||
|
@ -1256,8 +1246,7 @@ static struct nand_bbt_descr agand_flashbased = {
|
||||||
.pattern = scan_agand_pattern
|
.pattern = scan_agand_pattern
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Generic flash bbt decriptors
|
/* Generic flash bbt decriptors */
|
||||||
*/
|
|
||||||
static uint8_t bbt_pattern[] = {'B', 'b', 't', '0' };
|
static uint8_t bbt_pattern[] = {'B', 'b', 't', '0' };
|
||||||
static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' };
|
static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' };
|
||||||
|
|
||||||
|
@ -1303,13 +1292,12 @@ static struct nand_bbt_descr bbt_mirror_no_bbt_descr = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_create_default_bbt_descr - [Internal] Creates a BBT descriptor structure
|
* nand_create_default_bbt_descr - [Internal] Creates a BBT descriptor structure
|
||||||
* @this: NAND chip to create descriptor for
|
* @this: NAND chip to create descriptor for
|
||||||
*
|
*
|
||||||
* This function allocates and initializes a nand_bbt_descr for BBM detection
|
* This function allocates and initializes a nand_bbt_descr for BBM detection
|
||||||
* based on the properties of "this". The new descriptor is stored in
|
* based on the properties of "this". The new descriptor is stored in
|
||||||
* this->badblock_pattern. Thus, this->badblock_pattern should be NULL when
|
* this->badblock_pattern. Thus, this->badblock_pattern should be NULL when
|
||||||
* passed to this function.
|
* passed to this function.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
static int nand_create_default_bbt_descr(struct nand_chip *this)
|
static int nand_create_default_bbt_descr(struct nand_chip *this)
|
||||||
{
|
{
|
||||||
|
@ -1334,22 +1322,20 @@ static int nand_create_default_bbt_descr(struct nand_chip *this)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_default_bbt - [NAND Interface] Select a default bad block table for the device
|
* nand_default_bbt - [NAND Interface] Select a default bad block table for the device
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
*
|
*
|
||||||
* This function selects the default bad block table
|
* This function selects the default bad block table support for the device and
|
||||||
* support for the device and calls the nand_scan_bbt function
|
* calls the nand_scan_bbt function.
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
int nand_default_bbt(struct mtd_info *mtd)
|
int nand_default_bbt(struct mtd_info *mtd)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
|
|
||||||
/* Default for AG-AND. We must use a flash based
|
/*
|
||||||
* bad block table as the devices have factory marked
|
* Default for AG-AND. We must use a flash based bad block table as the
|
||||||
* _good_ blocks. Erasing those blocks leads to loss
|
* devices have factory marked _good_ blocks. Erasing those blocks
|
||||||
* of the good / bad information, so we _must_ store
|
* leads to loss of the good / bad information, so we _must_ store this
|
||||||
* this information in a good / bad table during
|
* information in a good / bad table during startup.
|
||||||
* startup
|
|
||||||
*/
|
*/
|
||||||
if (this->options & NAND_IS_AND) {
|
if (this->options & NAND_IS_AND) {
|
||||||
/* Use the default pattern descriptors */
|
/* Use the default pattern descriptors */
|
||||||
|
@ -1361,7 +1347,7 @@ int nand_default_bbt(struct mtd_info *mtd)
|
||||||
return nand_scan_bbt(mtd, &agand_flashbased);
|
return nand_scan_bbt(mtd, &agand_flashbased);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is a flash based bad block table requested ? */
|
/* Is a flash based bad block table requested? */
|
||||||
if (this->bbt_options & NAND_BBT_USE_FLASH) {
|
if (this->bbt_options & NAND_BBT_USE_FLASH) {
|
||||||
/* Use the default pattern descriptors */
|
/* Use the default pattern descriptors */
|
||||||
if (!this->bbt_td) {
|
if (!this->bbt_td) {
|
||||||
|
@ -1386,11 +1372,10 @@ int nand_default_bbt(struct mtd_info *mtd)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nand_isbad_bbt - [NAND Interface] Check if a block is bad
|
* nand_isbad_bbt - [NAND Interface] Check if a block is bad
|
||||||
* @mtd: MTD device structure
|
* @mtd: MTD device structure
|
||||||
* @offs: offset in the device
|
* @offs: offset in the device
|
||||||
* @allowbbt: allow access to bad block table region
|
* @allowbbt: allow access to bad block table region
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
|
int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
|
|
Loading…
Reference in a new issue