aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 05:50:56 -0400
committerThomas Gleixner <tglx@cruncher.tec.linutronix.de>2006-05-23 05:50:56 -0400
commit2c0a2bed9276ebbec5794edc07f66e21e9a1735c (patch)
treead0fb96624fd92f270d9e5d1cbbff14ffd7921f0 /drivers/mtd/nand
parentdcb0932884b801290efd80fbc37630297b98181f (diff)
[MTD] NAND whitespace and formatting cleanup
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/nand_base.c104
1 files changed, 62 insertions, 42 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 7933ca273c95..6ef1893996ce 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -10,7 +10,7 @@
10 * http://www.linux-mtd.infradead.org/tech/nand.html 10 * http://www.linux-mtd.infradead.org/tech/nand.html
11 * 11 *
12 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) 12 * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
13 * 2002 Thomas Gleixner (tglx@linutronix.de) 13 * 2002 Thomas Gleixner (tglx@linutronix.de)
14 * 14 *
15 * 02-08-2004 tglx: support for strange chips, which cannot auto increment 15 * 02-08-2004 tglx: support for strange chips, which cannot auto increment
16 * pages on read / read_oob 16 * pages on read / read_oob
@@ -25,26 +25,30 @@
25 * 05-19-2004 tglx: Basic support for Renesas AG-AND chips 25 * 05-19-2004 tglx: Basic support for Renesas AG-AND chips
26 * 26 *
27 * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared 27 * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared
28 * among multiple independend devices. Suggestions and initial patch 28 * among multiple independend devices. Suggestions and initial
29 * from Ben Dooks <ben-mtd@fluff.org> 29 * patch from Ben Dooks <ben-mtd@fluff.org>
30 * 30 *
31 * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" issue. 31 * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb"
32 * Basically, any block not rewritten may lose data when surrounding blocks 32 * issue. Basically, any block not rewritten may lose data when
33 * are rewritten many times. JFFS2 ensures this doesn't happen for blocks 33 * surrounding blocks are rewritten many times. JFFS2 ensures
34 * it uses, but the Bad Block Table(s) may not be rewritten. To ensure they 34 * this doesn't happen for blocks it uses, but the Bad Block
35 * do not lose data, force them to be rewritten when some of the surrounding 35 * Table(s) may not be rewritten. To ensure they do not lose
36 * blocks are erased. Rather than tracking a specific nearby block (which 36 * data, force them to be rewritten when some of the surrounding
37 * could itself go bad), use a page address 'mask' to select several blocks 37 * blocks are erased. Rather than tracking a specific nearby
38 * in the same area, and rewrite the BBT when any of them are erased. 38 * block (which could itself go bad), use a page address 'mask' to
39 * 39 * select several blocks in the same area, and rewrite the BBT
40 * 01-03-2005 dmarlin: added support for the device recovery command sequence for Renesas 40 * when any of them are erased.
41 * AG-AND chips. If there was a sudden loss of power during an erase operation, 41 *
42 * a "device recovery" operation must be performed when power is restored 42 * 01-03-2005 dmarlin: added support for the device recovery command sequence
43 * to ensure correct operation. 43 * for Renesas AG-AND chips. If there was a sudden loss of power
44 * 44 * during an erase operation, a "device recovery" operation must
45 * 01-20-2005 dmarlin: added support for optional hardware specific callback routine to 45 * be performed when power is restored to ensure correct
46 * perform extra error status checks on erase and write failures. This required 46 * operation.
47 * adding a wrapper function for nand_read_ecc. 47 *
48 * 01-20-2005 dmarlin: added support for optional hardware specific callback
49 * routine to perform extra error status checks on erase and write
50 * failures. This required adding a wrapper function for
51 * nand_read_ecc.
48 * 52 *
49 * 08-20-2005 vwool: suspend/resume added 53 * 08-20-2005 vwool: suspend/resume added
50 * 54 *
@@ -132,32 +136,43 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len);
132static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); 136static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len);
133static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); 137static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len);
134 138
135static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); 139static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
140 size_t *retlen, u_char *buf);
136static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, 141static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
137 size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); 142 size_t *retlen, u_char *buf, u_char *eccbuf,
138static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); 143 struct nand_oobinfo *oobsel);
139static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); 144static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len,
145 size_t *retlen, u_char *buf);
146static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
147 size_t *retlen, const u_char *buf);
140static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, 148static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
141 size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); 149 size_t *retlen, const u_char *buf, u_char *eccbuf,
142static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); 150 struct nand_oobinfo *oobsel);
143static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen); 151static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len,
152 size_t *retlen, const u_char *buf);
153static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs,
154 unsigned long count, loff_t to, size_t *retlen);
144static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, 155static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
145 unsigned long count, loff_t to, size_t *retlen, u_char *eccbuf, 156 unsigned long count, loff_t to, size_t *retlen,
146 struct nand_oobinfo *oobsel); 157 u_char *eccbuf, struct nand_oobinfo *oobsel);
147static int nand_erase(struct mtd_info *mtd, struct erase_info *instr); 158static int nand_erase(struct mtd_info *mtd, struct erase_info *instr);
148static void nand_sync(struct mtd_info *mtd); 159static void nand_sync(struct mtd_info *mtd);
149 160
150/* Some internal functions */ 161/* Some internal functions */
151static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int page, u_char * oob_buf, 162static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this,
163 int page, u_char * oob_buf,
152 struct nand_oobinfo *oobsel, int mode); 164 struct nand_oobinfo *oobsel, int mode);
153#ifdef CONFIG_MTD_NAND_VERIFY_WRITE 165#ifdef CONFIG_MTD_NAND_VERIFY_WRITE
154static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, 166static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this,
155 u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); 167 int page, int numpages, u_char *oob_buf,
168 struct nand_oobinfo *oobsel, int chipnr,
169 int oobmode);
156#else 170#else
157#define nand_verify_pages(...) (0) 171#define nand_verify_pages(...) (0)
158#endif 172#endif
159 173
160static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state); 174static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd,
175 int new_state);
161 176
162/** 177/**
163 * nand_release_device - [GENERIC] release chip 178 * 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 page = (int)ofs; 439 page = (int)ofs;
425 440
426 if (this->options & NAND_BUSWIDTH_16) { 441 if (this->options & NAND_BUSWIDTH_16) {
427 this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); 442 this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE,
443 page & this->pagemask);
428 bad = cpu_to_le16(this->read_word(mtd)); 444 bad = cpu_to_le16(this->read_word(mtd));
429 if (this->badblockpos & 0x1) 445 if (this->badblockpos & 0x1)
430 bad >>= 8; 446 bad >>= 8;
431 if ((bad & 0xFF) != 0xff) 447 if ((bad & 0xFF) != 0xff)
432 res = 1; 448 res = 1;
433 } else { 449 } else {
434 this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask); 450 this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos,
451 page & this->pagemask);
435 if (this->read_byte(mtd) != 0xff) 452 if (this->read_byte(mtd) != 0xff)
436 res = 1; 453 res = 1;
437 } 454 }
@@ -498,7 +515,8 @@ static int nand_check_wp(struct mtd_info *mtd)
498 * Check, if the block is bad. Either by reading the bad block table or 515 * Check, if the block is bad. Either by reading the bad block table or
499 * calling of the scan function. 516 * calling of the scan function.
500 */ 517 */
501static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) 518static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
519 int allowbbt)
502{ 520{
503 struct nand_chip *this = mtd->priv; 521 struct nand_chip *this = mtd->priv;
504 522
@@ -540,7 +558,8 @@ static void nand_wait_ready(struct mtd_info *mtd)
540 * Send command to NAND device. This function is used for small page 558 * Send command to NAND device. This function is used for small page
541 * devices (256/512 Bytes per page) 559 * devices (256/512 Bytes per page)
542 */ 560 */
543static void nand_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) 561static void nand_command(struct mtd_info *mtd, unsigned command, int column,
562 int page_addr)
544{ 563{
545 register struct nand_chip *this = mtd->priv; 564 register struct nand_chip *this = mtd->priv;
546 565
@@ -755,7 +774,8 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column,
755 * 774 *
756 * Get the device and lock it for exclusive access 775 * Get the device and lock it for exclusive access
757 */ 776 */
758static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state) 777static int
778nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state)
759{ 779{
760 spinlock_t *lock = &this->controller->lock; 780 spinlock_t *lock = &this->controller->lock;
761 wait_queue_head_t *wq = &this->controller->wq; 781 wait_queue_head_t *wq = &this->controller->wq;
@@ -942,7 +962,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag
942 * nand_verify_pages - [GENERIC] verify the chip contents after a write 962 * nand_verify_pages - [GENERIC] verify the chip contents after a write
943 * @mtd: MTD device structure 963 * @mtd: MTD device structure
944 * @this: NAND chip structure 964 * @this: NAND chip structure
945 * @page: startpage inside the chip, must be called with (page & this->pagemask) 965 * @page: startpage inside the chip, must be called with (page & this->pagemask)
946 * @numpages: number of pages to verify 966 * @numpages: number of pages to verify
947 * @oob_buf: out of band data buffer 967 * @oob_buf: out of band data buffer
948 * @oobsel: out of band selecttion structre 968 * @oobsel: out of band selecttion structre
@@ -2293,8 +2313,8 @@ static void nand_resume(struct mtd_info *mtd)
2293 if (this->state == FL_PM_SUSPENDED) 2313 if (this->state == FL_PM_SUSPENDED)
2294 nand_release_device(mtd); 2314 nand_release_device(mtd);
2295 else 2315 else
2296 printk(KERN_ERR "resume() called for the chip which is not in suspended state\n"); 2316 printk(KERN_ERR "nand_resume() called for a chip which is not "
2297 2317 "in suspended state\n");
2298} 2318}
2299 2319
2300/* 2320/*