ramips: correct page read return value of the mt7621 nand driver
read_page() need to return maximum number of bitflips instead of the
accumulated number. Change takes from upstream mt7621 u-boot [1].
 * @read_page:  function to read a page according to the ECC generator
 *              requirements; returns maximum number of bitflips
 *              corrected in any single ECC step, -EIO hw error
[1] https://lore.kernel.org/all/cover.1653015383.git.weijie.gao@mediatek.com/
Signed-off-by: Shiji Yang <yangshiji66@qq.com>
(cherry picked from commit 2fbb91d73f)
			
			
This commit is contained in:
		 Shiji Yang
					Shiji Yang
				
			
				
					committed by
					
						 Christian Lamparter
						Christian Lamparter
					
				
			
			
				
	
			
			
			 Christian Lamparter
						Christian Lamparter
					
				
			
						parent
						
							80a99d9cf7
						
					
				
				
					commit
					80fbad19ef
				
			| @@ -1006,7 +1006,7 @@ static int mt7621_nfc_read_page_hwecc(struct nand_chip *nand, uint8_t *buf, | |||||||
| { | { | ||||||
| 	struct mt7621_nfc *nfc = nand_get_controller_data(nand); | 	struct mt7621_nfc *nfc = nand_get_controller_data(nand); | ||||||
| 	struct mtd_info *mtd = nand_to_mtd(nand); | 	struct mtd_info *mtd = nand_to_mtd(nand); | ||||||
| 	int bitflips = 0; | 	int bitflips = 0, ret = 0; | ||||||
| 	int rc, i; | 	int rc, i; | ||||||
|  |  | ||||||
| 	nand_read_page_op(nand, page, 0, NULL, 0); | 	nand_read_page_op(nand, page, 0, NULL, 0); | ||||||
| @@ -1031,7 +1031,7 @@ static int mt7621_nfc_read_page_hwecc(struct nand_chip *nand, uint8_t *buf, | |||||||
| 		mt7621_nfc_read_sector_fdm(nfc, i); | 		mt7621_nfc_read_sector_fdm(nfc, i); | ||||||
|  |  | ||||||
| 		if (rc < 0) { | 		if (rc < 0) { | ||||||
| 			bitflips = -EIO; | 			ret = -EIO; | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -1043,10 +1043,11 @@ static int mt7621_nfc_read_page_hwecc(struct nand_chip *nand, uint8_t *buf, | |||||||
| 			dev_dbg(nfc->dev, | 			dev_dbg(nfc->dev, | ||||||
| 				 "Uncorrectable ECC error at page %d.%d\n", | 				 "Uncorrectable ECC error at page %d.%d\n", | ||||||
| 				 page, i); | 				 page, i); | ||||||
| 			bitflips = -EBADMSG; | 			bitflips = nand->ecc.strength + 1; | ||||||
| 			mtd->ecc_stats.failed++; | 			mtd->ecc_stats.failed++; | ||||||
| 		} else if (bitflips >= 0) { | 		} else { | ||||||
| 			bitflips += rc; | 			if (rc > bitflips) | ||||||
|  | 				bitflips = rc; | ||||||
| 			mtd->ecc_stats.corrected += rc; | 			mtd->ecc_stats.corrected += rc; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -1055,6 +1056,9 @@ static int mt7621_nfc_read_page_hwecc(struct nand_chip *nand, uint8_t *buf, | |||||||
|  |  | ||||||
| 	nfi_write16(nfc, NFI_CON, 0); | 	nfi_write16(nfc, NFI_CON, 0); | ||||||
|  |  | ||||||
|  | 	if (ret < 0) | ||||||
|  | 		return ret; | ||||||
|  |  | ||||||
| 	return bitflips; | 	return bitflips; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user