diff mbox

[v5,09/14] mtd: nand: pxa3xx: Move the data buffer clean to prepare_start_command()

Message ID 1384464339-6817-10-git-send-email-ezequiel.garcia@free-electrons.com
State Superseded
Headers show

Commit Message

Ezequiel Garcia Nov. 14, 2013, 9:25 p.m. UTC
To allow future support of multiple page reading/writing, move the data
buffer clean out of prepare_set_command().

This is done to prevent the data buffer from being cleaned on every command
preparation, when a multiple command sequence is implemented to read/write
pages larger than the FIFO size (2 KiB).

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/mtd/nand/pxa3xx_nand.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

Comments

Ezequiel Garcia Nov. 14, 2013, 10:45 p.m. UTC | #1
On Thu, Nov 14, 2013 at 02:25:54PM -0800, Brian Norris wrote:
> On Thu, Nov 14, 2013 at 06:25:34PM -0300, Ezequiel Garcia wrote:
> > --- a/drivers/mtd/nand/pxa3xx_nand.c
> > +++ b/drivers/mtd/nand/pxa3xx_nand.c
> > @@ -633,6 +636,19 @@ static void prepare_start_command(struct pxa3xx_nand_info *info, int command)
> >  		info->ndcb2 = 0;
> >  		break;
> >  	}
> > +
> > +	/*
> > +	 * If we are about to isse a read command, or about to set
> 
> s/isse/issue/
> 

Ack.

> > +	 * the write address, then clean the data buffer.
> > +	 */
> > +	if (command == NAND_CMD_READ0 ||
> > +	    command == NAND_CMD_READOOB ||
> > +	    command == NAND_CMD_SEQIN) {
> > +
> 
> Superfluous blank line?
> 

No, I find blank lines increase readability. I know others might
disagree. Feel free to chop it.

> > +		info->buf_count = mtd->writesize + mtd->oobsize;
> > +		memset(info->data_buff, 0xFF, info->buf_count);
> > +	}
> > +
> >  }
> >  
> >  static int prepare_set_command(struct pxa3xx_nand_info *info, int command,
> 
> I'll make these changes myself, if I take the series. The rest of the
> series is looking good so far (up to this point), so it's not worth a
> respin.
> 

OK.
diff mbox

Patch

diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index b66f32b..1a9849f 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -609,6 +609,9 @@  static void set_command_address(struct pxa3xx_nand_info *info,
 
 static void prepare_start_command(struct pxa3xx_nand_info *info, int command)
 {
+	struct pxa3xx_nand_host *host = info->host[info->cs];
+	struct mtd_info *mtd = host->mtd;
+
 	/* reset data and oob column point to handle data */
 	info->buf_start		= 0;
 	info->buf_count		= 0;
@@ -633,6 +636,19 @@  static void prepare_start_command(struct pxa3xx_nand_info *info, int command)
 		info->ndcb2 = 0;
 		break;
 	}
+
+	/*
+	 * If we are about to isse a read command, or about to set
+	 * the write address, then clean the data buffer.
+	 */
+	if (command == NAND_CMD_READ0 ||
+	    command == NAND_CMD_READOOB ||
+	    command == NAND_CMD_SEQIN) {
+
+		info->buf_count = mtd->writesize + mtd->oobsize;
+		memset(info->data_buff, 0xFF, info->buf_count);
+	}
+
 }
 
 static int prepare_set_command(struct pxa3xx_nand_info *info, int command,
@@ -674,16 +690,11 @@  static int prepare_set_command(struct pxa3xx_nand_info *info, int command,
 			info->ndcb0 |= NDCB0_DBC | (NAND_CMD_READSTART << 8);
 
 		set_command_address(info, mtd->writesize, column, page_addr);
-		info->buf_count = mtd->writesize + mtd->oobsize;
-		memset(info->data_buff, 0xFF, info->buf_count);
 		break;
 
 	case NAND_CMD_SEQIN:
 
 		set_command_address(info, mtd->writesize, column, page_addr);
-		info->buf_count = mtd->writesize + mtd->oobsize;
-		memset(info->data_buff, 0xFF, info->buf_count);
-
 		break;
 
 	case NAND_CMD_PAGEPROG: