All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead
@ 2014-08-08  9:12 Josh Wu
  2014-08-08  9:12 ` [PATCH 2/2] mtd: atmel_nand: remove pmecc_bytes_per_sector, use chip->ecc.bytes instead Josh Wu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josh Wu @ 2014-08-08  9:12 UTC (permalink / raw)
  To: linux-mtd; +Cc: Josh Wu, computersforpeace

For PMECC, the pmecc_sector_number has same meaning as ecc.steps.
So use ecc.steps to replace the pmecc_sector_number.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
 drivers/mtd/nand/atmel_nand.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 9c5f717..1dc3988 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -129,7 +129,6 @@ struct atmel_nand_host {
 	u32			pmecc_lookup_table_offset_1024;
 
 	int			pmecc_bytes_per_sector;
-	int			pmecc_sector_number;
 	int			pmecc_degree;	/* Degree of remainders */
 	int			pmecc_cw_len;	/* Length of codeword */
 
@@ -874,7 +873,7 @@ static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf,
 	return 0;
 
 normal_check:
-	for (i = 0; i < host->pmecc_sector_number; i++) {
+	for (i = 0; i < nand_chip->ecc.steps; i++) {
 		err_nbr = 0;
 		if (pmecc_stat & 0x1) {
 			buf_pos = buf + i * host->pmecc_sector_size;
@@ -984,7 +983,7 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
 		cpu_relax();
 	}
 
-	for (i = 0; i < host->pmecc_sector_number; i++) {
+	for (i = 0; i < chip->ecc.steps; i++) {
 		for (j = 0; j < host->pmecc_bytes_per_sector; j++) {
 			int pos;
 
@@ -1031,7 +1030,7 @@ static void atmel_pmecc_core_init(struct mtd_info *mtd)
 	else if (host->pmecc_sector_size == 1024)
 		val |= PMECC_CFG_SECTOR1024;
 
-	switch (host->pmecc_sector_number) {
+	switch (nand_chip->ecc.steps) {
 	case 1:
 		val |= PMECC_CFG_PAGE_1SECTOR;
 		break;
@@ -1184,18 +1183,17 @@ static int atmel_pmecc_nand_init_params(struct platform_device *pdev,
 		host->pmecc_degree = (sector_size == 512) ?
 			PMECC_GF_DIMENSION_13 : PMECC_GF_DIMENSION_14;
 		host->pmecc_cw_len = (1 << host->pmecc_degree) - 1;
-		host->pmecc_sector_number = mtd->writesize / sector_size;
 		host->pmecc_bytes_per_sector = pmecc_get_ecc_bytes(
 			cap, sector_size);
 		host->pmecc_alpha_to = pmecc_get_alpha_to(host);
 		host->pmecc_index_of = host->pmecc_rom_base +
 			host->pmecc_lookup_table_offset;
 
-		nand_chip->ecc.steps = host->pmecc_sector_number;
 		nand_chip->ecc.strength = cap;
 		nand_chip->ecc.bytes = host->pmecc_bytes_per_sector;
-		nand_chip->ecc.total = host->pmecc_bytes_per_sector *
-				       host->pmecc_sector_number;
+		nand_chip->ecc.steps = mtd->writesize / sector_size;
+		nand_chip->ecc.total = nand_chip->ecc.bytes *
+			nand_chip->ecc.steps;
 		if (nand_chip->ecc.total > mtd->oobsize - 2) {
 			dev_err(host->dev, "No room for ECC bytes\n");
 			err_no = -EINVAL;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] mtd: atmel_nand: remove pmecc_bytes_per_sector, use chip->ecc.bytes instead
  2014-08-08  9:12 [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead Josh Wu
@ 2014-08-08  9:12 ` Josh Wu
  2014-09-17  8:33 ` [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead Josh Wu
  2014-09-18  6:12 ` Brian Norris
  2 siblings, 0 replies; 4+ messages in thread
From: Josh Wu @ 2014-08-08  9:12 UTC (permalink / raw)
  To: linux-mtd; +Cc: Josh Wu, computersforpeace

For PMECC, the pmecc_bytes_per_sector has same meaning as ecc.bytes.
So remove pmecc_bytes_per_sector and use ecc.bytes instead.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
 drivers/mtd/nand/atmel_nand.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 1dc3988..effa7a29 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -128,7 +128,6 @@ struct atmel_nand_host {
 	u32			pmecc_lookup_table_offset_512;
 	u32			pmecc_lookup_table_offset_1024;
 
-	int			pmecc_bytes_per_sector;
 	int			pmecc_degree;	/* Degree of remainders */
 	int			pmecc_cw_len;	/* Length of codeword */
 
@@ -840,7 +839,7 @@ static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc,
 				pos, bit_pos, err_byte, *(buf + byte_pos));
 		} else {
 			/* Bit flip in OOB area */
-			tmp = sector_num * host->pmecc_bytes_per_sector
+			tmp = sector_num * nand_chip->ecc.bytes
 					+ (byte_pos - sector_size);
 			err_byte = ecc[tmp];
 			ecc[tmp] ^= (1 << bit_pos);
@@ -889,7 +888,7 @@ normal_check:
 				return -EIO;
 			} else {
 				pmecc_correct_data(mtd, buf_pos, ecc, i,
-					host->pmecc_bytes_per_sector, err_nbr);
+					nand_chip->ecc.bytes, err_nbr);
 				mtd->ecc_stats.corrected += err_nbr;
 				total_err += err_nbr;
 			}
@@ -984,10 +983,10 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
 	}
 
 	for (i = 0; i < chip->ecc.steps; i++) {
-		for (j = 0; j < host->pmecc_bytes_per_sector; j++) {
+		for (j = 0; j < chip->ecc.bytes; j++) {
 			int pos;
 
-			pos = i * host->pmecc_bytes_per_sector + j;
+			pos = i * chip->ecc.bytes + j;
 			chip->oob_poi[eccpos[pos]] =
 				pmecc_readb_ecc_relaxed(host->ecc, i, j);
 		}
@@ -1183,14 +1182,12 @@ static int atmel_pmecc_nand_init_params(struct platform_device *pdev,
 		host->pmecc_degree = (sector_size == 512) ?
 			PMECC_GF_DIMENSION_13 : PMECC_GF_DIMENSION_14;
 		host->pmecc_cw_len = (1 << host->pmecc_degree) - 1;
-		host->pmecc_bytes_per_sector = pmecc_get_ecc_bytes(
-			cap, sector_size);
 		host->pmecc_alpha_to = pmecc_get_alpha_to(host);
 		host->pmecc_index_of = host->pmecc_rom_base +
 			host->pmecc_lookup_table_offset;
 
 		nand_chip->ecc.strength = cap;
-		nand_chip->ecc.bytes = host->pmecc_bytes_per_sector;
+		nand_chip->ecc.bytes = pmecc_get_ecc_bytes(cap, sector_size);
 		nand_chip->ecc.steps = mtd->writesize / sector_size;
 		nand_chip->ecc.total = nand_chip->ecc.bytes *
 			nand_chip->ecc.steps;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead
  2014-08-08  9:12 [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead Josh Wu
  2014-08-08  9:12 ` [PATCH 2/2] mtd: atmel_nand: remove pmecc_bytes_per_sector, use chip->ecc.bytes instead Josh Wu
@ 2014-09-17  8:33 ` Josh Wu
  2014-09-18  6:12 ` Brian Norris
  2 siblings, 0 replies; 4+ messages in thread
From: Josh Wu @ 2014-09-17  8:33 UTC (permalink / raw)
  To: linux-mtd; +Cc: computersforpeace

Hi, Brian

Any feedback for this patch series?

Best Regards,
Josh Wu

On 8/8/2014 5:12 PM, Josh Wu wrote:
> For PMECC, the pmecc_sector_number has same meaning as ecc.steps.
> So use ecc.steps to replace the pmecc_sector_number.
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> ---
>   drivers/mtd/nand/atmel_nand.c | 14 ++++++--------
>   1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 9c5f717..1dc3988 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -129,7 +129,6 @@ struct atmel_nand_host {
>   	u32			pmecc_lookup_table_offset_1024;
>   
>   	int			pmecc_bytes_per_sector;
> -	int			pmecc_sector_number;
>   	int			pmecc_degree;	/* Degree of remainders */
>   	int			pmecc_cw_len;	/* Length of codeword */
>   
> @@ -874,7 +873,7 @@ static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf,
>   	return 0;
>   
>   normal_check:
> -	for (i = 0; i < host->pmecc_sector_number; i++) {
> +	for (i = 0; i < nand_chip->ecc.steps; i++) {
>   		err_nbr = 0;
>   		if (pmecc_stat & 0x1) {
>   			buf_pos = buf + i * host->pmecc_sector_size;
> @@ -984,7 +983,7 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
>   		cpu_relax();
>   	}
>   
> -	for (i = 0; i < host->pmecc_sector_number; i++) {
> +	for (i = 0; i < chip->ecc.steps; i++) {
>   		for (j = 0; j < host->pmecc_bytes_per_sector; j++) {
>   			int pos;
>   
> @@ -1031,7 +1030,7 @@ static void atmel_pmecc_core_init(struct mtd_info *mtd)
>   	else if (host->pmecc_sector_size == 1024)
>   		val |= PMECC_CFG_SECTOR1024;
>   
> -	switch (host->pmecc_sector_number) {
> +	switch (nand_chip->ecc.steps) {
>   	case 1:
>   		val |= PMECC_CFG_PAGE_1SECTOR;
>   		break;
> @@ -1184,18 +1183,17 @@ static int atmel_pmecc_nand_init_params(struct platform_device *pdev,
>   		host->pmecc_degree = (sector_size == 512) ?
>   			PMECC_GF_DIMENSION_13 : PMECC_GF_DIMENSION_14;
>   		host->pmecc_cw_len = (1 << host->pmecc_degree) - 1;
> -		host->pmecc_sector_number = mtd->writesize / sector_size;
>   		host->pmecc_bytes_per_sector = pmecc_get_ecc_bytes(
>   			cap, sector_size);
>   		host->pmecc_alpha_to = pmecc_get_alpha_to(host);
>   		host->pmecc_index_of = host->pmecc_rom_base +
>   			host->pmecc_lookup_table_offset;
>   
> -		nand_chip->ecc.steps = host->pmecc_sector_number;
>   		nand_chip->ecc.strength = cap;
>   		nand_chip->ecc.bytes = host->pmecc_bytes_per_sector;
> -		nand_chip->ecc.total = host->pmecc_bytes_per_sector *
> -				       host->pmecc_sector_number;
> +		nand_chip->ecc.steps = mtd->writesize / sector_size;
> +		nand_chip->ecc.total = nand_chip->ecc.bytes *
> +			nand_chip->ecc.steps;
>   		if (nand_chip->ecc.total > mtd->oobsize - 2) {
>   			dev_err(host->dev, "No room for ECC bytes\n");
>   			err_no = -EINVAL;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead
  2014-08-08  9:12 [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead Josh Wu
  2014-08-08  9:12 ` [PATCH 2/2] mtd: atmel_nand: remove pmecc_bytes_per_sector, use chip->ecc.bytes instead Josh Wu
  2014-09-17  8:33 ` [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead Josh Wu
@ 2014-09-18  6:12 ` Brian Norris
  2 siblings, 0 replies; 4+ messages in thread
From: Brian Norris @ 2014-09-18  6:12 UTC (permalink / raw)
  To: Josh Wu; +Cc: linux-mtd

On Fri, Aug 08, 2014 at 05:12:34PM +0800, Josh Wu wrote:
> For PMECC, the pmecc_sector_number has same meaning as ecc.steps.
> So use ecc.steps to replace the pmecc_sector_number.
> 
> Signed-off-by: Josh Wu <josh.wu@atmel.com>

Pushed both to l2-mtd.git. Thanks!

One comment below.

> ---
>  drivers/mtd/nand/atmel_nand.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
> index 9c5f717..1dc3988 100644
> --- a/drivers/mtd/nand/atmel_nand.c
> +++ b/drivers/mtd/nand/atmel_nand.c
> @@ -129,7 +129,6 @@ struct atmel_nand_host {
>  	u32			pmecc_lookup_table_offset_1024;
>  
>  	int			pmecc_bytes_per_sector;
> -	int			pmecc_sector_number;
>  	int			pmecc_degree;	/* Degree of remainders */
>  	int			pmecc_cw_len;	/* Length of codeword */
>  
> @@ -874,7 +873,7 @@ static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf,
>  	return 0;
>  
>  normal_check:
> -	for (i = 0; i < host->pmecc_sector_number; i++) {
> +	for (i = 0; i < nand_chip->ecc.steps; i++) {
>  		err_nbr = 0;
>  		if (pmecc_stat & 0x1) {
>  			buf_pos = buf + i * host->pmecc_sector_size;
> @@ -984,7 +983,7 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
>  		cpu_relax();
>  	}
>  
> -	for (i = 0; i < host->pmecc_sector_number; i++) {
> +	for (i = 0; i < chip->ecc.steps; i++) {
>  		for (j = 0; j < host->pmecc_bytes_per_sector; j++) {
>  			int pos;
>  
> @@ -1031,7 +1030,7 @@ static void atmel_pmecc_core_init(struct mtd_info *mtd)
>  	else if (host->pmecc_sector_size == 1024)
>  		val |= PMECC_CFG_SECTOR1024;
>  
> -	switch (host->pmecc_sector_number) {
> +	switch (nand_chip->ecc.steps) {
>  	case 1:
>  		val |= PMECC_CFG_PAGE_1SECTOR;
>  		break;
> @@ -1184,18 +1183,17 @@ static int atmel_pmecc_nand_init_params(struct platform_device *pdev,
>  		host->pmecc_degree = (sector_size == 512) ?
>  			PMECC_GF_DIMENSION_13 : PMECC_GF_DIMENSION_14;
>  		host->pmecc_cw_len = (1 << host->pmecc_degree) - 1;
> -		host->pmecc_sector_number = mtd->writesize / sector_size;
>  		host->pmecc_bytes_per_sector = pmecc_get_ecc_bytes(
>  			cap, sector_size);
>  		host->pmecc_alpha_to = pmecc_get_alpha_to(host);
>  		host->pmecc_index_of = host->pmecc_rom_base +
>  			host->pmecc_lookup_table_offset;
>  
> -		nand_chip->ecc.steps = host->pmecc_sector_number;
>  		nand_chip->ecc.strength = cap;
>  		nand_chip->ecc.bytes = host->pmecc_bytes_per_sector;
> -		nand_chip->ecc.total = host->pmecc_bytes_per_sector *
> -				       host->pmecc_sector_number;
> +		nand_chip->ecc.steps = mtd->writesize / sector_size;
> +		nand_chip->ecc.total = nand_chip->ecc.bytes *
> +			nand_chip->ecc.steps;

Do you really need to do all this initialization here? nand_scan_tail()
would do most of this for you.

>  		if (nand_chip->ecc.total > mtd->oobsize - 2) {
>  			dev_err(host->dev, "No room for ECC bytes\n");
>  			err_no = -EINVAL;

Brian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-18  6:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-08  9:12 [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead Josh Wu
2014-08-08  9:12 ` [PATCH 2/2] mtd: atmel_nand: remove pmecc_bytes_per_sector, use chip->ecc.bytes instead Josh Wu
2014-09-17  8:33 ` [PATCH 1/2] mtd: atmel_nand: remove pmecc_sector_number, use ecc.steps instead Josh Wu
2014-09-18  6:12 ` Brian Norris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.