This source file includes following definitions.
- mtd_nand_has_bch
- mtd_nand_has_bch
- nand_bch_calculate_ecc
- nand_bch_correct_data
- nand_bch_init
- nand_bch_free
1
2
3
4
5
6
7
8 #ifndef __MTD_NAND_BCH_H__
9 #define __MTD_NAND_BCH_H__
10
11 struct mtd_info;
12 struct nand_chip;
13 struct nand_bch_control;
14
15 #if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH)
16
17 static inline int mtd_nand_has_bch(void) { return 1; }
18
19
20
21
22 int nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
23 u_char *ecc_code);
24
25
26
27
28 int nand_bch_correct_data(struct nand_chip *chip, u_char *dat,
29 u_char *read_ecc, u_char *calc_ecc);
30
31
32
33 struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
34
35
36
37 void nand_bch_free(struct nand_bch_control *nbc);
38
39 #else
40
41 static inline int mtd_nand_has_bch(void) { return 0; }
42
43 static inline int
44 nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
45 u_char *ecc_code)
46 {
47 return -1;
48 }
49
50 static inline int
51 nand_bch_correct_data(struct nand_chip *chip, unsigned char *buf,
52 unsigned char *read_ecc, unsigned char *calc_ecc)
53 {
54 return -ENOTSUPP;
55 }
56
57 static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
58 {
59 return NULL;
60 }
61
62 static inline void nand_bch_free(struct nand_bch_control *nbc) {}
63
64 #endif
65
66 #endif