nand_ecc.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * drivers/mtd/nand_ecc.h
  3. *
  4. * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com)
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This file is the header for the ECC algorithm.
  11. */
  12. #ifndef __MTD_NAND_ECC_H__
  13. #define __MTD_NAND_ECC_H__
  14. struct mtd_info;
  15. #if defined(CONFIG_MTD_ECC_SOFT)
  16. static inline int mtd_nand_has_ecc_soft(void) { return 1; }
  17. /*
  18. * Calculate 3 byte ECC code for 256 byte block
  19. */
  20. int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code);
  21. /*
  22. * Detect and correct a 1 bit error for 256 byte block
  23. */
  24. int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc);
  25. #else
  26. static inline int mtd_nand_has_ecc_soft(void) { return 0; }
  27. static inline int
  28. nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
  29. {
  30. return -1;
  31. }
  32. static inline int
  33. nand_correct_data(struct mtd_info *mtd,
  34. u_char *dat,
  35. u_char *read_ecc,
  36. u_char *calc_ecc)
  37. {
  38. return -1;
  39. }
  40. #endif
  41. #endif /* __MTD_NAND_ECC_H__ */