diff mbox

[v3,08/10] mtd: gpmi-nand: utilize oob_requested parameter

Message ID 1335576594-25267-9-git-send-email-computersforpeace@gmail.com
State Accepted
Commit 7725cc85932bd02dd12c23108e0ef748c551ccba
Headers show

Commit Message

Brian Norris April 28, 2012, 1:29 a.m. UTC
Don't read OOB if the caller didn't request it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   35 +++++++++++++++++--------------
 1 files changed, 19 insertions(+), 16 deletions(-)

Comments

Huang Shijie April 28, 2012, 2:32 a.m. UTC | #1
于 2012年04月28日 09:29, Brian Norris 写道:
> Don't read OOB if the caller didn't request it.
>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
>  drivers/mtd/nand/gpmi-nand/gpmi-nand.c |   35 +++++++++++++++++--------------
>  1 files changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> index ec16f2e..805bcf3 100644
> --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
> @@ -907,22 +907,25 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
>  		mtd->ecc_stats.corrected += corrected;
>  	}
>  
> -	/*
> -	 * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob() for
> -	 * details about our policy for delivering the OOB.
> -	 *
> -	 * We fill the caller's buffer with set bits, and then copy the block
> -	 * mark to th caller's buffer. Note that, if block mark swapping was
> -	 * necessary, it has already been done, so we can rely on the first
> -	 * byte of the auxiliary buffer to contain the block mark.
> -	 */
> -	memset(chip->oob_poi, ~0, mtd->oobsize);
> -	chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
> +	if (oob_required) {
> +		/*
> +		 * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob()
> +		 * for details about our policy for delivering the OOB.
> +		 *
> +		 * We fill the caller's buffer with set bits, and then copy the
> +		 * block mark to th caller's buffer. Note that, if block mark
> +		 * swapping was necessary, it has already been done, so we can
> +		 * rely on the first byte of the auxiliary buffer to contain
> +		 * the block mark.
> +		 */
> +		memset(chip->oob_poi, ~0, mtd->oobsize);
> +		chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
>  
> -	read_page_swap_end(this, buf, mtd->writesize,
> -			this->payload_virt, this->payload_phys,
> -			nfc_geo->payload_size,
> -			payload_virt, payload_phys);
> +		read_page_swap_end(this, buf, mtd->writesize,
> +				this->payload_virt, this->payload_phys,
> +				nfc_geo->payload_size,
> +				payload_virt, payload_phys);
> +	}
>  exit_nfc:
>  	return ret;
>  }
it's ok to me.

Acked-by: Huang Shijie <b32955@freescale.com>
diff mbox

Patch

diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index ec16f2e..805bcf3 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -907,22 +907,25 @@  static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
 		mtd->ecc_stats.corrected += corrected;
 	}
 
-	/*
-	 * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob() for
-	 * details about our policy for delivering the OOB.
-	 *
-	 * We fill the caller's buffer with set bits, and then copy the block
-	 * mark to th caller's buffer. Note that, if block mark swapping was
-	 * necessary, it has already been done, so we can rely on the first
-	 * byte of the auxiliary buffer to contain the block mark.
-	 */
-	memset(chip->oob_poi, ~0, mtd->oobsize);
-	chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
+	if (oob_required) {
+		/*
+		 * It's time to deliver the OOB bytes. See gpmi_ecc_read_oob()
+		 * for details about our policy for delivering the OOB.
+		 *
+		 * We fill the caller's buffer with set bits, and then copy the
+		 * block mark to th caller's buffer. Note that, if block mark
+		 * swapping was necessary, it has already been done, so we can
+		 * rely on the first byte of the auxiliary buffer to contain
+		 * the block mark.
+		 */
+		memset(chip->oob_poi, ~0, mtd->oobsize);
+		chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0];
 
-	read_page_swap_end(this, buf, mtd->writesize,
-			this->payload_virt, this->payload_phys,
-			nfc_geo->payload_size,
-			payload_virt, payload_phys);
+		read_page_swap_end(this, buf, mtd->writesize,
+				this->payload_virt, this->payload_phys,
+				nfc_geo->payload_size,
+				payload_virt, payload_phys);
+	}
 exit_nfc:
 	return ret;
 }