]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/nand/nand_ecc.c
nand: Remove unused ppc4xx NAND driver and references
[u-boot] / drivers / mtd / nand / nand_ecc.c
index 4c532b0794e17f7a47c1ae2c755f37cc91692392..13a6535bd5a36442fa89cfcde4c7f5b6a957a18e 100644 (file)
@@ -7,21 +7,9 @@
  * Copyright (C) 2000-2004 Steven J. Hill (sjhill@realitydiluted.com)
  *                         Toshiba America Electronics Components, Inc.
  *
- * $Id: nand_ecc.c,v 1.14 2004/06/16 15:34:37 gleixner Exp $
+ * Copyright (C) 2006 Thomas Gleixner <tglx@linutronix.de>
  *
- * This file is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 or (at your option) any
- * later version.
- *
- * This file is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this file; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ * SPDX-License-Identifier:    GPL-2.0+
  *
  * As a special exception, if other files instantiate templates or use
  * macros or inline functions from these files, or you compile these
 
 #include <common.h>
 
-#if defined(CONFIG_CMD_NAND) && !defined(CFG_NAND_LEGACY)
-
-#include<linux/mtd/mtd.h>
+#include <linux/errno.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand_ecc.h>
 
 /*
  * NAND-SPL has no sofware ECC for now, so don't include nand_calculate_ecc(),
  * only nand_correct_data() is needed
  */
 
-#ifndef CONFIG_NAND_SPL
+#if !defined(CONFIG_NAND_SPL) || defined(CONFIG_SPL_NAND_SOFTECC)
 /*
  * Pre-calculated 256-way 1 byte column parity
  */
@@ -117,13 +105,8 @@ int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
        tmp2 |= (reg2 & 0x01) << 0; /* B7 -> B0 */
 
        /* Calculate final ECC code */
-#ifdef CONFIG_MTD_NAND_ECC_SMC
-       ecc_code[0] = ~tmp2;
-       ecc_code[1] = ~tmp1;
-#else
        ecc_code[0] = ~tmp1;
        ecc_code[1] = ~tmp2;
-#endif
        ecc_code[2] = ((~reg1) << 2) | 0x03;
 
        return 0;
@@ -153,15 +136,9 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat,
 {
        uint8_t s0, s1, s2;
 
-#ifdef CONFIG_MTD_NAND_ECC_SMC
-       s0 = calc_ecc[0] ^ read_ecc[0];
-       s1 = calc_ecc[1] ^ read_ecc[1];
-       s2 = calc_ecc[2] ^ read_ecc[2];
-#else
        s1 = calc_ecc[0] ^ read_ecc[0];
        s0 = calc_ecc[1] ^ read_ecc[1];
        s2 = calc_ecc[2] ^ read_ecc[2];
-#endif
        if ((s0 | s1 | s2) == 0)
                return 0;
 
@@ -194,7 +171,5 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat,
        if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1)
                return 1;
 
-       return -1;
+       return -EBADMSG;
 }
-
-#endif