Commit 2c0a2bed authored by Thomas Gleixner's avatar Thomas Gleixner

[MTD] NAND whitespace and formatting cleanup

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent dcb09328
...@@ -25,26 +25,30 @@ ...@@ -25,26 +25,30 @@
* 05-19-2004 tglx: Basic support for Renesas AG-AND chips * 05-19-2004 tglx: Basic support for Renesas AG-AND chips
* *
* 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared
* among multiple independend devices. Suggestions and initial patch * among multiple independend devices. Suggestions and initial
* from Ben Dooks <ben-mtd@fluff.org> * patch from Ben Dooks <ben-mtd@fluff.org>
* *
* 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" issue. * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb"
* Basically, any block not rewritten may lose data when surrounding blocks * issue. Basically, any block not rewritten may lose data when
* are rewritten many times. JFFS2 ensures this doesn't happen for blocks * surrounding blocks are rewritten many times. JFFS2 ensures
* it uses, but the Bad Block Table(s) may not be rewritten. To ensure they * this doesn't happen for blocks it uses, but the Bad Block
* do not lose data, force them to be rewritten when some of the surrounding * Table(s) may not be rewritten. To ensure they do not lose
* blocks are erased. Rather than tracking a specific nearby block (which * data, force them to be rewritten when some of the surrounding
* could itself go bad), use a page address 'mask' to select several blocks * blocks are erased. Rather than tracking a specific nearby
* in the same area, and rewrite the BBT when any of them are erased. * block (which could itself go bad), use a page address 'mask' to
* * select several blocks in the same area, and rewrite the BBT
* 01-03-2005 dmarlin: added support for the device recovery command sequence for Renesas * when any of them are erased.
* AG-AND chips. If there was a sudden loss of power during an erase operation, *
* a "device recovery" operation must be performed when power is restored * 01-03-2005 dmarlin: added support for the device recovery command sequence
* to ensure correct operation. * for Renesas AG-AND chips. If there was a sudden loss of power
* * during an erase operation, a "device recovery" operation must
* 01-20-2005 dmarlin: added support for optional hardware specific callback routine to * be performed when power is restored to ensure correct
* perform extra error status checks on erase and write failures. This required * operation.
* adding a wrapper function for nand_read_ecc. *
* 01-20-2005 dmarlin: added support for optional hardware specific callback
* routine to perform extra error status checks on erase and write
* failures. This required adding a wrapper function for
* nand_read_ecc.
* *
* 08-20-2005 vwool: suspend/resume added * 08-20-2005 vwool: suspend/resume added
* *
...@@ -132,32 +136,43 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len); ...@@ -132,32 +136,43 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len);
static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len);
static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len);
static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf);
static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); size_t *retlen, u_char *buf, u_char *eccbuf,
static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); struct nand_oobinfo *oobsel);
static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf);
static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf);
static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); size_t *retlen, const u_char *buf, u_char *eccbuf,
static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen, u_char *eccbuf,
struct nand_oobinfo *oobsel); struct nand_oobinfo *oobsel);
static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf);
static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen);
static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
unsigned long count, loff_t to, size_t *retlen,
u_char *eccbuf, struct nand_oobinfo *oobsel);
static int nand_erase(struct mtd_info *mtd, struct erase_info *instr); static int nand_erase(struct mtd_info *mtd, struct erase_info *instr);
static void nand_sync(struct mtd_info *mtd); static void nand_sync(struct mtd_info *mtd);
/* Some internal functions */ /* Some internal functions */
static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int page, u_char * oob_buf, static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this,
int page, u_char * oob_buf,
struct nand_oobinfo *oobsel, int mode); struct nand_oobinfo *oobsel, int mode);
#ifdef CONFIG_MTD_NAND_VERIFY_WRITE #ifdef CONFIG_MTD_NAND_VERIFY_WRITE
static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this,
u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); int page, int numpages, u_char *oob_buf,
struct nand_oobinfo *oobsel, int chipnr,
int oobmode);
#else #else
#define nand_verify_pages(...) (0) #define nand_verify_pages(...) (0)
#endif #endif
static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state); static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd,
int new_state);
/** /**
* nand_release_device - [GENERIC] release chip * nand_release_device - [GENERIC] release chip
...@@ -424,14 +439,16 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) ...@@ -424,14 +439,16 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
page = (int)ofs; page = (int)ofs;
if (this->options & NAND_BUSWIDTH_16) { if (this->options & NAND_BUSWIDTH_16) {
this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE,
page & this->pagemask);
bad = cpu_to_le16(this->read_word(mtd)); bad = cpu_to_le16(this->read_word(mtd));
if (this->badblockpos & 0x1) if (this->badblockpos & 0x1)
bad >>= 8; bad >>= 8;
if ((bad & 0xFF) != 0xff) if ((bad & 0xFF) != 0xff)
res = 1; res = 1;
} else { } else {
this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask); this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos,
page & this->pagemask);
if (this->read_byte(mtd) != 0xff) if (this->read_byte(mtd) != 0xff)
res = 1; res = 1;
} }
...@@ -498,7 +515,8 @@ static int nand_check_wp(struct mtd_info *mtd) ...@@ -498,7 +515,8 @@ static int nand_check_wp(struct mtd_info *mtd)
* Check, if the block is bad. Either by reading the bad block table or * Check, if the block is bad. Either by reading the bad block table or
* calling of the scan function. * calling of the scan function.
*/ */
static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
int allowbbt)
{ {
struct nand_chip *this = mtd->priv; struct nand_chip *this = mtd->priv;
...@@ -540,7 +558,8 @@ static void nand_wait_ready(struct mtd_info *mtd) ...@@ -540,7 +558,8 @@ static void nand_wait_ready(struct mtd_info *mtd)
* Send command to NAND device. This function is used for small page * Send command to NAND device. This function is used for small page
* devices (256/512 Bytes per page) * devices (256/512 Bytes per page)
*/ */
static void nand_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) static void nand_command(struct mtd_info *mtd, unsigned command, int column,
int page_addr)
{ {
register struct nand_chip *this = mtd->priv; register struct nand_chip *this = mtd->priv;
...@@ -755,7 +774,8 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column, ...@@ -755,7 +774,8 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column,
* *
* Get the device and lock it for exclusive access * Get the device and lock it for exclusive access
*/ */
static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state) static int
nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state)
{ {
spinlock_t *lock = &this->controller->lock; spinlock_t *lock = &this->controller->lock;
wait_queue_head_t *wq = &this->controller->wq; wait_queue_head_t *wq = &this->controller->wq;
...@@ -2293,8 +2313,8 @@ static void nand_resume(struct mtd_info *mtd) ...@@ -2293,8 +2313,8 @@ static void nand_resume(struct mtd_info *mtd)
if (this->state == FL_PM_SUSPENDED) if (this->state == FL_PM_SUSPENDED)
nand_release_device(mtd); nand_release_device(mtd);
else else
printk(KERN_ERR "resume() called for the chip which is not in suspended state\n"); printk(KERN_ERR "nand_resume() called for a chip which is not "
"in suspended state\n");
} }
/* /*
......
...@@ -15,43 +15,7 @@ ...@@ -15,43 +15,7 @@
* Contains standard defines and IDs for NAND flash devices * Contains standard defines and IDs for NAND flash devices
* *
* Changelog: * Changelog:
* 01-31-2000 DMW Created * See git changelog.
* 09-18-2000 SJH Moved structure out of the Disk-On-Chip drivers
* so it can be used by other NAND flash device
* drivers. I also changed the copyright since none
* of the original contents of this file are specific
* to DoC devices. David can whack me with a baseball
* bat later if I did something naughty.
* 10-11-2000 SJH Added private NAND flash structure for driver
* 10-24-2000 SJH Added prototype for 'nand_scan' function
* 10-29-2001 TG changed nand_chip structure to support
* hardwarespecific function for accessing control lines
* 02-21-2002 TG added support for different read/write adress and
* ready/busy line access function
* 02-26-2002 TG added chip_delay to nand_chip structure to optimize
* command delay times for different chips
* 04-28-2002 TG OOB config defines moved from nand.c to avoid duplicate
* defines in jffs2/wbuf.c
* 08-07-2002 TG forced bad block location to byte 5 of OOB, even if
* CONFIG_MTD_NAND_ECC_JFFS2 is not set
* 08-10-2002 TG extensions to nand_chip structure to support HW-ECC
*
* 08-29-2002 tglx nand_chip structure: data_poi for selecting
* internal / fs-driver buffer
* support for 6byte/512byte hardware ECC
* read_ecc, write_ecc extended for different oob-layout
* oob layout selections: NAND_NONE_OOB, NAND_JFFS2_OOB,
* NAND_YAFFS_OOB
* 11-25-2002 tglx Added Manufacturer code FUJITSU, NATIONAL
* Split manufacturer and device ID structures
*
* 02-08-2004 tglx added option field to nand structure for chip anomalities
* 05-25-2004 tglx added bad block table support, ST-MICRO manufacturer id
* update of nand_chip structure description
* 01-17-2005 dmarlin added extended commands for AG-AND device and added option
* for BBT_AUTO_REFRESH.
* 01-20-2005 dmarlin added optional pointer to hardware specific callback for
* extra error status checks.
*/ */
#ifndef __LINUX_MTD_NAND_H #ifndef __LINUX_MTD_NAND_H
#define __LINUX_MTD_NAND_H #define __LINUX_MTD_NAND_H
...@@ -68,7 +32,8 @@ extern int nand_scan (struct mtd_info *mtd, int max_chips); ...@@ -68,7 +32,8 @@ extern int nand_scan (struct mtd_info *mtd, int max_chips);
extern void nand_release (struct mtd_info *mtd); extern void nand_release (struct mtd_info *mtd);
/* Read raw data from the device without ECC */ /* Read raw data from the device without ECC */
extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen); extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from,
size_t len, size_t ooblen);
/* The maximum number of NAND chips in an array */ /* The maximum number of NAND chips in an array */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment