Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.11-rc3 73 lines 2.2 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright © 2011 Ivan Djelic <ivan.djelic@parrot.com> 4 * 5 * This file is the header for the NAND BCH ECC implementation. 6 */ 7 8#ifndef __MTD_NAND_ECC_SW_BCH_H__ 9#define __MTD_NAND_ECC_SW_BCH_H__ 10 11#include <linux/mtd/nand.h> 12#include <linux/bch.h> 13 14/** 15 * struct nand_ecc_sw_bch_conf - private software BCH ECC engine structure 16 * @req_ctx: Save request context and tweak the original request to fit the 17 * engine needs 18 * @code_size: Number of bytes needed to store a code (one code per step) 19 * @nsteps: Number of steps 20 * @calc_buf: Buffer to use when calculating ECC bytes 21 * @code_buf: Buffer to use when reading (raw) ECC bytes from the chip 22 * @bch: BCH control structure 23 * @errloc: error location array 24 * @eccmask: XOR ecc mask, allows erased pages to be decoded as valid 25 */ 26struct nand_ecc_sw_bch_conf { 27 struct nand_ecc_req_tweak_ctx req_ctx; 28 unsigned int code_size; 29 unsigned int nsteps; 30 u8 *calc_buf; 31 u8 *code_buf; 32 struct bch_control *bch; 33 unsigned int *errloc; 34 unsigned char *eccmask; 35}; 36 37#if IS_ENABLED(CONFIG_MTD_NAND_ECC_SW_BCH) 38 39int nand_ecc_sw_bch_calculate(struct nand_device *nand, 40 const unsigned char *buf, unsigned char *code); 41int nand_ecc_sw_bch_correct(struct nand_device *nand, unsigned char *buf, 42 unsigned char *read_ecc, unsigned char *calc_ecc); 43int nand_ecc_sw_bch_init_ctx(struct nand_device *nand); 44void nand_ecc_sw_bch_cleanup_ctx(struct nand_device *nand); 45struct nand_ecc_engine *nand_ecc_sw_bch_get_engine(void); 46 47#else /* !CONFIG_MTD_NAND_ECC_SW_BCH */ 48 49static inline int nand_ecc_sw_bch_calculate(struct nand_device *nand, 50 const unsigned char *buf, 51 unsigned char *code) 52{ 53 return -ENOTSUPP; 54} 55 56static inline int nand_ecc_sw_bch_correct(struct nand_device *nand, 57 unsigned char *buf, 58 unsigned char *read_ecc, 59 unsigned char *calc_ecc) 60{ 61 return -ENOTSUPP; 62} 63 64static inline int nand_ecc_sw_bch_init_ctx(struct nand_device *nand) 65{ 66 return -ENOTSUPP; 67} 68 69static inline void nand_ecc_sw_bch_cleanup_ctx(struct nand_device *nand) {} 70 71#endif /* CONFIG_MTD_NAND_ECC_SW_BCH */ 72 73#endif /* __MTD_NAND_ECC_SW_BCH_H__ */