0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __MTD_NAND_ECC_SW_BCH_H__
0009 #define __MTD_NAND_ECC_SW_BCH_H__
0010
0011 #include <linux/mtd/nand.h>
0012 #include <linux/bch.h>
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 struct nand_ecc_sw_bch_conf {
0026 struct nand_ecc_req_tweak_ctx req_ctx;
0027 unsigned int code_size;
0028 u8 *calc_buf;
0029 u8 *code_buf;
0030 struct bch_control *bch;
0031 unsigned int *errloc;
0032 unsigned char *eccmask;
0033 };
0034
0035 #if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH)
0036
0037 int nand_ecc_sw_bch_calculate(struct nand_device *nand,
0038 const unsigned char *buf, unsigned char *code);
0039 int nand_ecc_sw_bch_correct(struct nand_device *nand, unsigned char *buf,
0040 unsigned char *read_ecc, unsigned char *calc_ecc);
0041 int nand_ecc_sw_bch_init_ctx(struct nand_device *nand);
0042 void nand_ecc_sw_bch_cleanup_ctx(struct nand_device *nand);
0043 struct nand_ecc_engine *nand_ecc_sw_bch_get_engine(void);
0044
0045 #else
0046
0047 static inline int nand_ecc_sw_bch_calculate(struct nand_device *nand,
0048 const unsigned char *buf,
0049 unsigned char *code)
0050 {
0051 return -ENOTSUPP;
0052 }
0053
0054 static inline int nand_ecc_sw_bch_correct(struct nand_device *nand,
0055 unsigned char *buf,
0056 unsigned char *read_ecc,
0057 unsigned char *calc_ecc)
0058 {
0059 return -ENOTSUPP;
0060 }
0061
0062 static inline int nand_ecc_sw_bch_init_ctx(struct nand_device *nand)
0063 {
0064 return -ENOTSUPP;
0065 }
0066
0067 static inline void nand_ecc_sw_bch_cleanup_ctx(struct nand_device *nand) {}
0068
0069 #endif
0070
0071 #endif