0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef __MTD_NAND_ECC_SW_HAMMING_H__
0011 #define __MTD_NAND_ECC_SW_HAMMING_H__
0012
0013 #include <linux/mtd/nand.h>
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 struct nand_ecc_sw_hamming_conf {
0025 struct nand_ecc_req_tweak_ctx req_ctx;
0026 unsigned int code_size;
0027 u8 *calc_buf;
0028 u8 *code_buf;
0029 unsigned int sm_order;
0030 };
0031
0032 #if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_HAMMING)
0033
0034 int nand_ecc_sw_hamming_init_ctx(struct nand_device *nand);
0035 void nand_ecc_sw_hamming_cleanup_ctx(struct nand_device *nand);
0036 int ecc_sw_hamming_calculate(const unsigned char *buf, unsigned int step_size,
0037 unsigned char *code, bool sm_order);
0038 int nand_ecc_sw_hamming_calculate(struct nand_device *nand,
0039 const unsigned char *buf,
0040 unsigned char *code);
0041 int ecc_sw_hamming_correct(unsigned char *buf, unsigned char *read_ecc,
0042 unsigned char *calc_ecc, unsigned int step_size,
0043 bool sm_order);
0044 int nand_ecc_sw_hamming_correct(struct nand_device *nand, unsigned char *buf,
0045 unsigned char *read_ecc,
0046 unsigned char *calc_ecc);
0047
0048 #else
0049
0050 static inline int nand_ecc_sw_hamming_init_ctx(struct nand_device *nand)
0051 {
0052 return -ENOTSUPP;
0053 }
0054
0055 static inline void nand_ecc_sw_hamming_cleanup_ctx(struct nand_device *nand) {}
0056
0057 static inline int ecc_sw_hamming_calculate(const unsigned char *buf,
0058 unsigned int step_size,
0059 unsigned char *code, bool sm_order)
0060 {
0061 return -ENOTSUPP;
0062 }
0063
0064 static inline int nand_ecc_sw_hamming_calculate(struct nand_device *nand,
0065 const unsigned char *buf,
0066 unsigned char *code)
0067 {
0068 return -ENOTSUPP;
0069 }
0070
0071 static inline int ecc_sw_hamming_correct(unsigned char *buf,
0072 unsigned char *read_ecc,
0073 unsigned char *calc_ecc,
0074 unsigned int step_size, bool sm_order)
0075 {
0076 return -ENOTSUPP;
0077 }
0078
0079 static inline int nand_ecc_sw_hamming_correct(struct nand_device *nand,
0080 unsigned char *buf,
0081 unsigned char *read_ecc,
0082 unsigned char *calc_ecc)
0083 {
0084 return -ENOTSUPP;
0085 }
0086
0087 #endif
0088
0089 #endif