mtd: nand: ecc-bch: Drop mtd_nand_has_bch()
[linux-2.6-microblaze.git] / include / linux / mtd / nand-ecc-sw-bch.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com>
4  *
5  * This file is the header for the NAND BCH ECC implementation.
6  */
7
8 #ifndef __MTD_NAND_ECC_SW_BCH_H__
9 #define __MTD_NAND_ECC_SW_BCH_H__
10
11 struct mtd_info;
12 struct nand_chip;
13
14 #if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH)
15
16 /*
17  * Calculate BCH ecc code
18  */
19 int nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
20                            u_char *ecc_code);
21
22 /*
23  * Detect and correct bit errors
24  */
25 int nand_bch_correct_data(struct nand_chip *chip, u_char *dat,
26                           u_char *read_ecc, u_char *calc_ecc);
27 /*
28  * Initialize BCH encoder/decoder
29  */
30 int nand_bch_init(struct nand_chip *chip);
31 /*
32  * Release BCH encoder/decoder resources
33  */
34 void nand_bch_free(struct nand_chip *chip);
35
36 #else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
37
38 static inline int
39 nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
40                        u_char *ecc_code)
41 {
42         return -ENOTSUPP;
43 }
44
45 static inline int
46 nand_bch_correct_data(struct nand_chip *chip, unsigned char *buf,
47                       unsigned char *read_ecc, unsigned char *calc_ecc)
48 {
49         return -ENOTSUPP;
50 }
51
52 static inline int nand_bch_init(struct nand_chip *chip)
53 {
54         return -ENOTSUPP;
55 }
56
57 static inline void nand_bch_free(struct nand_chip *chip) {}
58
59 #endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
60
61 #endif /* __MTD_NAND_ECC_SW_BCH_H__ */