]> asedeno.scripts.mit.edu Git - linux.git/blob - include/linux/mtd/nand_bch.h
mtd: nand: Clarify Kconfig entry for software BCH ECC algorithm
[linux.git] / include / linux / mtd / nand_bch.h
1 /*
2  * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com>
3  *
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.
7  *
8  * This file is the header for the NAND BCH ECC implementation.
9  */
10
11 #ifndef __MTD_NAND_BCH_H__
12 #define __MTD_NAND_BCH_H__
13
14 struct mtd_info;
15 struct nand_chip;
16 struct nand_bch_control;
17
18 #if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH)
19
20 static inline int mtd_nand_has_bch(void) { return 1; }
21
22 /*
23  * Calculate BCH ecc code
24  */
25 int nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
26                            u_char *ecc_code);
27
28 /*
29  * Detect and correct bit errors
30  */
31 int nand_bch_correct_data(struct nand_chip *chip, u_char *dat,
32                           u_char *read_ecc, u_char *calc_ecc);
33 /*
34  * Initialize BCH encoder/decoder
35  */
36 struct nand_bch_control *nand_bch_init(struct mtd_info *mtd);
37 /*
38  * Release BCH encoder/decoder resources
39  */
40 void nand_bch_free(struct nand_bch_control *nbc);
41
42 #else /* !CONFIG_MTD_NAND_ECC_SW_BCH */
43
44 static inline int mtd_nand_has_bch(void) { return 0; }
45
46 static inline int
47 nand_bch_calculate_ecc(struct nand_chip *chip, const u_char *dat,
48                        u_char *ecc_code)
49 {
50         return -1;
51 }
52
53 static inline int
54 nand_bch_correct_data(struct nand_chip *chip, unsigned char *buf,
55                       unsigned char *read_ecc, unsigned char *calc_ecc)
56 {
57         return -ENOTSUPP;
58 }
59
60 static inline struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
61 {
62         return NULL;
63 }
64
65 static inline void nand_bch_free(struct nand_bch_control *nbc) {}
66
67 #endif /* CONFIG_MTD_NAND_ECC_SW_BCH */
68
69 #endif /* __MTD_NAND_BCH_H__ */