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