mtd/drivers/mtd/nand nand.c,1.48,1.49

David Woodhouse dwmw2 at infradead.org
Wed Jul 2 07:00:26 EDT 2003


Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv13876/drivers/mtd/nand

Modified Files:
	nand.c 
Log Message:
select_chip() takes an int argument so we can handle more than one...


Index: nand.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- nand.c	2 Jul 2003 00:06:20 -0000	1.48
+++ nand.c	2 Jul 2003 11:00:24 -0000	1.49
@@ -152,12 +152,6 @@
 #include <asm/io.h>
 
 /*
- * Macros for low-level register control
- */
-#define nand_select()	this->hwcontrol(mtd, NAND_CTL_SETNCE);
-#define nand_deselect() this->hwcontrol(mtd, NAND_CTL_CLRNCE);
-
-/*
  * NAND low-level MTD interface functions
  */
 static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len);
@@ -180,6 +174,15 @@
 static void nand_sync (struct mtd_info *mtd);
 static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf,  struct nand_oobinfo *oobsel);
 
+static void nand_select_chip(struct mtd_info *mtd, int chip)
+{
+	struct nand_chip *this = mtd->priv;
+	if (chip)
+		this->hwcontrol(mtd, NAND_CTL_SETNCE);
+	else 
+		this->hwcontrol(mtd, NAND_CTL_CLRNCE);	
+
+}
 static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
 {
 	int i;
@@ -331,7 +334,7 @@
 		if (new_state != FL_ERASING) {
 			this->state = new_state;
 			spin_unlock_bh (&this->chip_lock);
-			nand_select ();	/* select in any case */
+			this->select_chip(mtd, 0);	/* select in any case */
 			this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
 			return;
 		}
@@ -543,8 +546,8 @@
 	 * applying a 20us delay before issuing the next programm sequence.
 	 * This is not a problem for all chips, but I have found a bunch of them.
 	 */
-	nand_deselect();
-	nand_select();
+	this->select_chip(mtd, -1);
+	this->select_chip(mtd, 0);
 #endif
 	return 0;
 }
@@ -594,7 +597,7 @@
 	nand_get_chip (this, mtd ,FL_READING, &erase_state);
 
 	/* Select the NAND device */
-	nand_select ();
+	this->select_chip(mtd, 0);
 
 	/* First we calculate the starting page */
 	page = from >> this->page_shift;
@@ -721,7 +724,7 @@
 	}
 
 	/* De-select the NAND device */
-	nand_deselect ();
+	this->select_chip(mtd, -1);
 
 	/* Wake up anyone waiting on the device */
 	spin_lock_bh (&this->chip_lock);
@@ -769,7 +772,7 @@
 	nand_get_chip (this, mtd , FL_READING, &erase_state);
 
 	/* Select the NAND device */
-	nand_select ();
+	this->select_chip(mtd, 0);
 
 	/* Send the read command */
 	this->cmdfunc (mtd, NAND_CMD_READOOB, col, page);
@@ -788,7 +791,7 @@
 		udelay (this->chip_delay);
 	}
 	/* De-select the NAND device */
-	nand_deselect ();
+	this->select_chip(mtd, -1);
 
 	/* Wake up anyone waiting on the device */
 	spin_lock_bh (&this->chip_lock);
@@ -844,7 +847,7 @@
 	nand_get_chip (this, mtd, FL_WRITING, NULL);
 
 	/* Select the NAND device */
-	nand_select ();
+	this->select_chip(mtd, 0);
 
 	/* Check the WP bit */
 	this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
@@ -876,7 +879,7 @@
 
 out:
 	/* De-select the NAND device */
-	nand_deselect ();
+	this->select_chip(mtd, -1);
 
 	/* Wake up anyone waiting on the device */
 	spin_lock_bh (&this->chip_lock);
@@ -922,7 +925,7 @@
 	nand_get_chip (this, mtd, FL_WRITING, NULL);
 
 	/* Select the NAND device */
-	nand_select ();
+	this->select_chip(mtd, 0);
 
 	/* Check the WP bit */
 	this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
@@ -971,7 +974,7 @@
 
 out:
 	/* De-select the NAND device */
-	nand_deselect ();
+	this->select_chip(mtd, -1);
 
 	/* Wake up anyone waiting on the device */
 	spin_lock_bh (&this->chip_lock);
@@ -1029,7 +1032,7 @@
 	nand_get_chip (this, mtd, FL_WRITING, NULL);
 
 	/* Select the NAND device */
-	nand_select ();
+	this->select_chip(mtd, 0);
 
 	/* Check the WP bit */
 	this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
@@ -1091,7 +1094,7 @@
 
 out:
 	/* De-select the NAND device */
-	nand_deselect ();
+	this->select_chip(mtd, -1);
 
 	/* Wake up anyone waiting on the device */
 	spin_lock_bh (&this->chip_lock);
@@ -1143,7 +1146,7 @@
 	pages_per_block = mtd->erasesize / mtd->oobblock;
 
 	/* Select the NAND device */
-	nand_select ();
+	this->select_chip(mtd, 0);
 
 	/* Check the WP bit */
 	this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1);
@@ -1197,7 +1200,7 @@
 		if (this->state == FL_ERASING || this->state == FL_READY) {
 			/* Select the NAND device again, if we were interrupted */
 			this->state = FL_ERASING;
-			nand_select ();
+			this->select_chip(mtd, 0);
 			continue;
 		} else {
 			set_current_state (TASK_UNINTERRUPTIBLE);
@@ -1212,7 +1215,7 @@
 
 erase_exit:
 	/* De-select the NAND device */
-	nand_deselect ();
+	this->select_chip(mtd, -1);
 	spin_unlock_bh (&this->chip_lock);
 
 	ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;;
@@ -1294,15 +1297,17 @@
 	if (this->waitfunc == NULL)
 		this->waitfunc = nand_wait;
 
-	if (this->write_buf == NULL)
+	if (!this->select_chip)
+		this->select_chip = nand_select_chip;
+	if (!this->write_buf)
 		this->write_buf = nand_write_buf;
-	if (this->read_buf == NULL)
+	if (!this->read_buf)
 		this->read_buf = nand_read_buf;
-	if (this->verify_buf == NULL)
+	if (!this->verify_buf)
 		this->verify_buf = nand_verify_buf;
 
 	/* Select the device */
-	nand_select ();
+	this->select_chip(mtd, 0);
 
 	/* Send the command for reading device ID */
 	this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);
@@ -1385,7 +1390,7 @@
 	spin_lock_init (&this->chip_lock);
 
 	/* De-select the device */
-	nand_deselect ();
+	this->select_chip(mtd, -1);
 
 	/* Print warning message for no device */
 	if (!mtd->size) {




More information about the linux-mtd-cvs mailing list