nand_ecc.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (C) 2000-2010 Steven J. Hill <sjhill@realitydiluted.com>
  3. * David Woodhouse <dwmw2@infradead.org>
  4. * Thomas Gleixner <tglx@linutronix.de>
  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 nand_chip;
  15. /*
  16. * Calculate 3 byte ECC code for eccsize byte block
  17. */
  18. void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize,
  19. u_char *ecc_code, bool sm_order);
  20. /*
  21. * Calculate 3 byte ECC code for 256/512 byte block
  22. */
  23. int nand_calculate_ecc(struct nand_chip *chip, const u_char *dat,
  24. u_char *ecc_code);
  25. /*
  26. * Detect and correct a 1 bit error for eccsize byte block
  27. */
  28. int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc,
  29. unsigned int eccsize, bool sm_order);
  30. /*
  31. * Detect and correct a 1 bit error for 256/512 byte block
  32. */
  33. int nand_correct_data(struct nand_chip *chip, u_char *dat, u_char *read_ecc,
  34. u_char *calc_ecc);
  35. #endif /* __MTD_NAND_ECC_H__ */