1
2
3
4
5
6
7
8
9
10#ifndef __MTD_NAND_ECC_SW_HAMMING_H__
11#define __MTD_NAND_ECC_SW_HAMMING_H__
12
13#include <linux/mtd/nand.h>
14
15
16
17
18
19
20
21
22
23
24struct nand_ecc_sw_hamming_conf {
25 struct nand_ecc_req_tweak_ctx req_ctx;
26 unsigned int code_size;
27 u8 *calc_buf;
28 u8 *code_buf;
29 unsigned int sm_order;
30};
31
32#if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_HAMMING)
33
34int nand_ecc_sw_hamming_init_ctx(struct nand_device *nand);
35void nand_ecc_sw_hamming_cleanup_ctx(struct nand_device *nand);
36int ecc_sw_hamming_calculate(const unsigned char *buf, unsigned int step_size,
37 unsigned char *code, bool sm_order);
38int nand_ecc_sw_hamming_calculate(struct nand_device *nand,
39 const unsigned char *buf,
40 unsigned char *code);
41int ecc_sw_hamming_correct(unsigned char *buf, unsigned char *read_ecc,
42 unsigned char *calc_ecc, unsigned int step_size,
43 bool sm_order);
44int nand_ecc_sw_hamming_correct(struct nand_device *nand, unsigned char *buf,
45 unsigned char *read_ecc,
46 unsigned char *calc_ecc);
47
48#else
49
50static inline int nand_ecc_sw_hamming_init_ctx(struct nand_device *nand)
51{
52 return -ENOTSUPP;
53}
54
55static inline void nand_ecc_sw_hamming_cleanup_ctx(struct nand_device *nand) {}
56
57static inline int ecc_sw_hamming_calculate(const unsigned char *buf,
58 unsigned int step_size,
59 unsigned char *code, bool sm_order)
60{
61 return -ENOTSUPP;
62}
63
64static inline int nand_ecc_sw_hamming_calculate(struct nand_device *nand,
65 const unsigned char *buf,
66 unsigned char *code)
67{
68 return -ENOTSUPP;
69}
70
71static inline int ecc_sw_hamming_correct(unsigned char *buf,
72 unsigned char *read_ecc,
73 unsigned char *calc_ecc,
74 unsigned int step_size, bool sm_order)
75{
76 return -ENOTSUPP;
77}
78
79static inline int nand_ecc_sw_hamming_correct(struct nand_device *nand,
80 unsigned char *buf,
81 unsigned char *read_ecc,
82 unsigned char *calc_ecc)
83{
84 return -ENOTSUPP;
85}
86
87#endif
88
89#endif
90