4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This file is the header for the NAND BCH ECC implementation.
11 #ifndef __MTD_NAND_BCH_H__
12 #define __MTD_NAND_BCH_H__
16 struct nand_bch_control;
18 #if defined(CONFIG_MTD_NAND_ECC_BCH)
20 static inline int mtd_nand_has_bch(void) { return 1; }
23 * Calculate BCH ecc code
25 int nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
29 * Detect and correct bit errors
31 int nand_bch_correct_data(struct nand_chip *chip, u_char *dat,
32 u_char *read_ecc, u_char *calc_ecc);
34 * Initialize BCH encoder/decoder
36 struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
38 * Release BCH encoder/decoder resources
40 void nand_bch_free(struct nand_bch_control *nbc);
42 #else /* !CONFIG_MTD_NAND_ECC_BCH */
44 static inline int mtd_nand_has_bch(void) { return 0; }
47 nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
54 nand_bch_correct_data(struct nand_chip *chip, unsigned char *buf,
55 unsigned char *read_ecc, unsigned char *calc_ecc)
60 static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
65 static inline void nand_bch_free(struct nand_bch_control *nbc) {}
67 #endif /* CONFIG_MTD_NAND_ECC_BCH */
69 #endif /* __MTD_NAND_BCH_H__ */