[MTD] [NAND] Minor cleanup of nand_ecc.c
Make the standalone stuff a little cleaner, fix some checkpatch warnings. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
e6cf5df183
commit
ccbcd6cba5
|
@ -4,15 +4,15 @@
|
||||||
*
|
*
|
||||||
* drivers/mtd/nand/nand_ecc.c
|
* drivers/mtd/nand/nand_ecc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008 Koninklijke Philips Electronics NV.
|
* Copyright © 2008 Koninklijke Philips Electronics NV.
|
||||||
* Author: Frans Meulenbroeks
|
* Author: Frans Meulenbroeks
|
||||||
*
|
*
|
||||||
* Completely replaces the previous ECC implementation which was written by:
|
* Completely replaces the previous ECC implementation which was written by:
|
||||||
* Steven J. Hill (sjhill@realitydiluted.com)
|
* Steven J. Hill (sjhill@realitydiluted.com)
|
||||||
* Thomas Gleixner (tglx@linutronix.de)
|
* Thomas Gleixner (tglx@linutronix.de)
|
||||||
*
|
*
|
||||||
* Information on how this algorithm works and how it was developed
|
* Information on how this algorithm works and how it was developed
|
||||||
* can be found in Documentation/nand/ecc.txt
|
* can be found in Documentation/mtd/nand_ecc.txt
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify it
|
* 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
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
* e.g. when running the code in a testbed or a benchmark program.
|
* e.g. when running the code in a testbed or a benchmark program.
|
||||||
* When STANDALONE is used, the module related macros are commented out
|
* When STANDALONE is used, the module related macros are commented out
|
||||||
* as well as the linux include files.
|
* as well as the linux include files.
|
||||||
* Instead a private definition of mtd_into is given to satisfy the compiler
|
* Instead a private definition of mtd_info is given to satisfy the compiler
|
||||||
* (the code does not use mtd_info, so the code does not care)
|
* (the code does not use mtd_info, so the code does not care)
|
||||||
*/
|
*/
|
||||||
#ifndef STANDALONE
|
#ifndef STANDALONE
|
||||||
|
@ -44,10 +44,8 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/mtd/nand_ecc.h>
|
#include <linux/mtd/nand_ecc.h>
|
||||||
#else
|
#else
|
||||||
typedef uint32_t unsigned long
|
#include <stdint.h>
|
||||||
struct mtd_info {
|
struct mtd_info;
|
||||||
int dummy;
|
|
||||||
};
|
|
||||||
#define EXPORT_SYMBOL(x) /* x */
|
#define EXPORT_SYMBOL(x) /* x */
|
||||||
|
|
||||||
#define MODULE_LICENSE(x) /* x */
|
#define MODULE_LICENSE(x) /* x */
|
||||||
|
@ -409,7 +407,7 @@ int nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
|
||||||
/* repeated if statements are slightly more efficient than switch ... */
|
/* repeated if statements are slightly more efficient than switch ... */
|
||||||
/* ordered in order of likelihood */
|
/* ordered in order of likelihood */
|
||||||
if (nr_bits == 0)
|
if (nr_bits == 0)
|
||||||
return (0); /* no error */
|
return 0; /* no error */
|
||||||
if (nr_bits == 11) { /* correctable error */
|
if (nr_bits == 11) { /* correctable error */
|
||||||
/*
|
/*
|
||||||
* rp15/13/11/9/7/5/3/1 indicate which byte is the faulty byte
|
* rp15/13/11/9/7/5/3/1 indicate which byte is the faulty byte
|
||||||
|
@ -431,10 +429,10 @@ int nand_correct_data(struct mtd_info *mtd, unsigned char *buf,
|
||||||
bit_addr = addressbits[b2 >> 2];
|
bit_addr = addressbits[b2 >> 2];
|
||||||
/* flip the bit */
|
/* flip the bit */
|
||||||
buf[byte_addr] ^= (1 << bit_addr);
|
buf[byte_addr] ^= (1 << bit_addr);
|
||||||
return (1);
|
return 1;
|
||||||
}
|
}
|
||||||
if (nr_bits == 1)
|
if (nr_bits == 1)
|
||||||
return (1); /* error in ecc data; no action needed */
|
return 1; /* error in ecc data; no action needed */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(nand_correct_data);
|
EXPORT_SYMBOL(nand_correct_data);
|
||||||
|
|
Loading…
Reference in New Issue