Skip to content

Commit 548f87e

Browse files
richard-bootlinmiquelraynal
authored andcommitted
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>
1 parent e3fd963 commit 548f87e

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

drivers/mtd/nand/raw/sunxi_nand.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,8 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct nand_chip *nand,
963963
u32 pattern_found;
964964
bool erased;
965965
int ret;
966+
/* From the controller point of view, we are at step 0 */
967+
const int nfc_step = 0;
966968

967969
if (*cur_off != data_off)
968970
nand_change_read_column_op(nand, data_off, NULL, 0, false);
@@ -977,7 +979,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct nand_chip *nand,
977979
return ret;
978980

979981
sunxi_nfc_reset_user_data_len(nfc);
980-
sunxi_nfc_set_user_data_len(nfc, USER_DATA_SZ, 0);
982+
sunxi_nfc_set_user_data_len(nfc, USER_DATA_SZ, nfc_step);
981983
sunxi_nfc_randomizer_config(nand, page, false);
982984
sunxi_nfc_randomizer_enable(nand);
983985
writel(NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD | NFC_ECC_OP,
@@ -993,10 +995,9 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct nand_chip *nand,
993995
pattern_found = readl(nfc->regs + nfc->caps->reg_pat_found);
994996
pattern_found = field_get(NFC_ECC_PAT_FOUND_MSK(nfc), pattern_found);
995997

996-
ret = sunxi_nfc_hw_ecc_correct(nand, data, oob_required ? oob : NULL, 0,
997-
readl(nfc->regs + NFC_REG_ECC_ST),
998-
pattern_found,
999-
&erased);
998+
ret = sunxi_nfc_hw_ecc_correct(nand, data, oob_required ? oob : NULL,
999+
nfc_step, readl(nfc->regs + NFC_REG_ECC_ST),
1000+
pattern_found, &erased);
10001001
if (erased)
10011002
return 1;
10021003

@@ -1029,7 +1030,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct nand_chip *nand,
10291030
sunxi_nfc_randomizer_read_buf(nand, oob, ecc->bytes + USER_DATA_SZ,
10301031
true, page);
10311032

1032-
sunxi_nfc_hw_ecc_get_prot_oob_bytes(nand, oob, 0,
1033+
sunxi_nfc_hw_ecc_get_prot_oob_bytes(nand, oob, nfc_step,
10331034
bbm, page);
10341035
}
10351036
}
@@ -1207,6 +1208,8 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct nand_chip *nand,
12071208
struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
12081209
struct nand_ecc_ctrl *ecc = &nand->ecc;
12091210
int ret;
1211+
/* From the controller point of view, we are at step 0 */
1212+
const int nfc_step = 0;
12101213

12111214
if (data_off != *cur_off)
12121215
nand_change_write_column_op(nand, data_off, NULL, 0, false);
@@ -1223,8 +1226,8 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct nand_chip *nand,
12231226
sunxi_nfc_randomizer_config(nand, page, false);
12241227
sunxi_nfc_randomizer_enable(nand);
12251228
sunxi_nfc_reset_user_data_len(nfc);
1226-
sunxi_nfc_set_user_data_len(nfc, USER_DATA_SZ, 0);
1227-
sunxi_nfc_hw_ecc_set_prot_oob_bytes(nand, oob, 0, bbm, page);
1229+
sunxi_nfc_set_user_data_len(nfc, USER_DATA_SZ, nfc_step);
1230+
sunxi_nfc_hw_ecc_set_prot_oob_bytes(nand, oob, nfc_step, bbm, page);
12281231

12291232
writel(NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD |
12301233
NFC_ACCESS_DIR | NFC_ECC_OP,

0 commit comments

Comments
 (0)