summaryrefslogtreecommitdiff
path: root/include/linux/mtd/nand-ecc-sw-bch.h
blob: f0caee3b03d03b4b5ea3959a6291d892b463bf1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com>
 *
 * This file is the header for the NAND BCH ECC implementation.
 */

#ifndef __MTD_NAND_ECC_SW_BCH_H__
#define __MTD_NAND_ECC_SW_BCH_H__

#include <linux/mtd/nand.h>

#if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH)

int nand_ecc_sw_bch_calculate(struct nand_device *nand,
			      const unsigned char *buf, unsigned char *code);
int nand_ecc_sw_bch_correct(struct nand_device *nand, unsigned char *buf,
			    unsigned char *read_ecc, unsigned char *calc_ecc);
int nand_ecc_sw_bch_init(struct nand_device *nand);
void nand_ecc_sw_bch_cleanup(struct nand_device *nand);

#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */

static inline int nand_ecc_sw_bch_calculate(struct nand_device *nand,
					    const unsigned char *buf,
					    unsigned char *code)
{
	return -ENOTSUPP;
}

static inline int nand_ecc_sw_bch_correct(struct nand_device *nand,
					  unsigned char *buf,
					  unsigned char *read_ecc,
					  unsigned char *calc_ecc)
{
	return -ENOTSUPP;
}

static inline int nand_ecc_sw_bch_init(struct nand_device *nand)
{
	return -ENOTSUPP;
}

static inline void nand_ecc_sw_bch_cleanup(struct nand_device *nand) {}

#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */

#endif /* __MTD_NAND_ECC_SW_BCH_H__ */