1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com>
5 * This file is the header for the NAND BCH ECC implementation.
8 #ifndef __MTD_NAND_ECC_SW_BCH_H__
9 #define __MTD_NAND_ECC_SW_BCH_H__
14 #if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH)
17 * Calculate BCH ecc code
19 int nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
23 * Detect and correct bit errors
25 int nand_bch_correct_data(struct nand_chip *chip, u_char *dat,
26 u_char *read_ecc, u_char *calc_ecc);
28 * Initialize BCH encoder/decoder
30 int nand_bch_init(struct nand_chip *chip);
32 * Release BCH encoder/decoder resources
34 void nand_bch_free(struct nand_chip *chip);
36 #else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
39 nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
46 nand_bch_correct_data(struct nand_chip *chip, unsigned char *buf,
47 unsigned char *read_ecc, unsigned char *calc_ecc)
52 static inline int nand_bch_init(struct nand_chip *chip)
57 static inline void nand_bch_free(struct nand_chip *chip) {}
59 #endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
61 #endif /* __MTD_NAND_ECC_SW_BCH_H__ */