/* Error correction for CAFÉ NAND controller
*
* © 2006 Marvell, Inc.
* Author: Tom Chiou
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/errno.h>
static unsigned short gf4096_mul(unsigned short, unsigned short);
static unsigned short gf64_mul(unsigned short, unsigned short);
static unsigned short gf4096_inv(unsigned short);
static unsigned short err_pos(unsigned short);
static void find_4bit_err_coefs(unsigned short, unsigned short, unsigned short,
unsigned short, unsigned short, unsigned short,
unsigned short, unsigned short, unsigned short *);
static void zero_4x5_col3(unsigned short[4][5]);
static void zero_4x5_col2(unsigned short[4][5]);
static void zero_4x5_col1(unsigned short[4][5]);
static void swap_4x5_rows(unsigned short[4][5], int, int, int);
static void swap_2x3_rows(unsigned short m[2][3]);
static void solve_4x5(unsigned short m[4][5], unsigned short *, int *);
static void sort_coefs(int *, unsigned short *, int);
static void find_4bit_err_pats(unsigned short, unsigned short, unsigned short,
unsigned short, unsigned short, unsigned short,