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