Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mtd: rawnand: sunxi: make the code more self-explanatory

In sunxi_nfc_hw_ecc_{read,write}_chunk(), the ECC step was forced to 0,
the reason is not trivial to get when reading the code.

The explanation is that, from the NAND flash controller perspective, we
are indeed at step 0 for user data length and ECC errors.

Just add a const value with an explanation to clarify things.

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

authored by

Richard Genoud and committed by
Miquel Raynal
548f87ed e3fd963d

+11 -8
+11 -8
drivers/mtd/nand/raw/sunxi_nand.c
··· 963 963 u32 pattern_found; 964 964 bool erased; 965 965 int ret; 966 + /* From the controller point of view, we are at step 0 */ 967 + const int nfc_step = 0; 966 968 967 969 if (*cur_off != data_off) 968 970 nand_change_read_column_op(nand, data_off, NULL, 0, false); ··· 979 977 return ret; 980 978 981 979 sunxi_nfc_reset_user_data_len(nfc); 982 - sunxi_nfc_set_user_data_len(nfc, USER_DATA_SZ, 0); 980 + sunxi_nfc_set_user_data_len(nfc, USER_DATA_SZ, nfc_step); 983 981 sunxi_nfc_randomizer_config(nand, page, false); 984 982 sunxi_nfc_randomizer_enable(nand); 985 983 writel(NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD | NFC_ECC_OP, ··· 995 993 pattern_found = readl(nfc->regs + nfc->caps->reg_pat_found); 996 994 pattern_found = field_get(NFC_ECC_PAT_FOUND_MSK(nfc), pattern_found); 997 995 998 - ret = sunxi_nfc_hw_ecc_correct(nand, data, oob_required ? oob : NULL, 0, 999 - readl(nfc->regs + NFC_REG_ECC_ST), 1000 - pattern_found, 1001 - &erased); 996 + ret = sunxi_nfc_hw_ecc_correct(nand, data, oob_required ? oob : NULL, 997 + nfc_step, readl(nfc->regs + NFC_REG_ECC_ST), 998 + pattern_found, &erased); 1002 999 if (erased) 1003 1000 return 1; 1004 1001 ··· 1030 1029 sunxi_nfc_randomizer_read_buf(nand, oob, ecc->bytes + USER_DATA_SZ, 1031 1030 true, page); 1032 1031 1033 - sunxi_nfc_hw_ecc_get_prot_oob_bytes(nand, oob, 0, 1032 + sunxi_nfc_hw_ecc_get_prot_oob_bytes(nand, oob, nfc_step, 1034 1033 bbm, page); 1035 1034 } 1036 1035 } ··· 1208 1207 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); 1209 1208 struct nand_ecc_ctrl *ecc = &nand->ecc; 1210 1209 int ret; 1210 + /* From the controller point of view, we are at step 0 */ 1211 + const int nfc_step = 0; 1211 1212 1212 1213 if (data_off != *cur_off) 1213 1214 nand_change_write_column_op(nand, data_off, NULL, 0, false); ··· 1226 1223 sunxi_nfc_randomizer_config(nand, page, false); 1227 1224 sunxi_nfc_randomizer_enable(nand); 1228 1225 sunxi_nfc_reset_user_data_len(nfc); 1229 - sunxi_nfc_set_user_data_len(nfc, USER_DATA_SZ, 0); 1230 - sunxi_nfc_hw_ecc_set_prot_oob_bytes(nand, oob, 0, bbm, page); 1226 + sunxi_nfc_set_user_data_len(nfc, USER_DATA_SZ, nfc_step); 1227 + sunxi_nfc_hw_ecc_set_prot_oob_bytes(nand, oob, nfc_step, bbm, page); 1231 1228 1232 1229 writel(NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD | 1233 1230 NFC_ACCESS_DIR | NFC_ECC_OP,