mtd/lib/reed_solomon decode_rs.c, 1.4, 1.5 encode_rs.c, 1.2,
1.3 rslib.c, 1.3, 1.4
gleixner at infradead.org
gleixner at infradead.org
Tue Oct 5 18:07:55 EDT 2004
Update of /home/cvs/mtd/lib/reed_solomon
In directory phoenix.infradead.org:/tmp/cvs-serv24186
Modified Files:
decode_rs.c encode_rs.c rslib.c
Log Message:
prepare for kernel inclusion. Make akpm happy
Index: decode_rs.c
===================================================================
RCS file: /home/cvs/mtd/lib/reed_solomon/decode_rs.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- decode_rs.c 1 Oct 2004 21:44:39 -0000 1.4
+++ decode_rs.c 5 Oct 2004 22:07:53 -0000 1.5
@@ -18,44 +18,61 @@
*/
{
int deg_lambda, el, deg_omega;
- int i, j, r, k, PAD;
+ int i, j, r, k, pad;
+ int nn = rs->nn;
+ int nroots = rs->nroots;
+ int fcr = rs->fcr;
+ int prim = rs->prim;
+ int iprim = rs->iprim;
+ uint16_t *alpha_to = rs->alpha_to;
+ uint16_t *index_of = rs->index_of;
uint16_t u, q, tmp, num1, num2, den, discr_r, syn_error;
- /* Err+Eras Locator poly and syndrome poly */
- uint16_t lambda[NROOTS + 1], syn[NROOTS];
- uint16_t b[NROOTS + 1], t[NROOTS + 1], omega[NROOTS + 1];
- uint16_t root[NROOTS], reg[NROOTS + 1], loc[NROOTS];
+ /* Err+Eras Locator poly and syndrome poly The maximum value
+ * of nroots is 8. So the neccecary stacksize will be about
+ * 220 bytes max.
+ */
+ uint16_t lambda[nroots + 1], syn[nroots];
+ uint16_t b[nroots + 1], t[nroots + 1], omega[nroots + 1];
+ uint16_t root[nroots], reg[nroots + 1], loc[nroots];
int count = 0;
uint16_t msk = (uint16_t) rs->nn;
/* Check length parameter for validity */
- PAD = NN - NROOTS - len;
- if (PAD < 0 || PAD >= NN)
+ pad = nn - nroots - len;
+ if (pad < 0 || pad >= nn)
return -ERANGE;
/* Deos the caller provide the syndrome ? */
if (s != NULL)
goto decode;
- /* form the syndromes; i.e., evaluate data(x) at roots of g(x) */
- for (i = 0; i < NROOTS; i++)
+ /* form the syndromes; i.e., evaluate data(x) at roots of
+ * g(x) */
+ for (i = 0; i < nroots; i++)
syn[i] = (((uint16_t) data[0]) ^ invmsk) & msk;
for (j = 1; j < len; j++) {
- for (i = 0; i < NROOTS; i++) {
+ for (i = 0; i < nroots; i++) {
if (syn[i] == 0) {
- syn[i] = (((uint16_t) data[j]) ^ invmsk) & msk;
+ syn[i] = (((uint16_t) data[j]) ^
+ invmsk) & msk;
} else {
- syn[i] = ((((uint16_t) data[j]) ^ invmsk) & msk) ^ ALPHA_TO[MODNN(INDEX_OF[syn[i]] + (FCR+i)*PRIM)];
+ syn[i] = ((((uint16_t) data[j]) ^
+ invmsk) & msk) ^
+ alpha_to[rs_modnn(rs, index_of[syn[i]] +
+ (fcr + i) * prim)];
}
}
}
- for (j = 0; j < NROOTS; j++) {
- for (i = 0; i < NROOTS; i++) {
+ for (j = 0; j < nroots; j++) {
+ for (i = 0; i < nroots; i++) {
if (syn[i] == 0) {
syn[i] = ((uint16_t) par[j]) & msk;
} else {
- syn[i] = (((uint16_t) par[j]) & msk) ^ ALPHA_TO[MODNN(INDEX_OF[syn[i]] + (FCR+i)*PRIM)];
+ syn[i] = (((uint16_t) par[j]) & msk) ^
+ alpha_to[rs_modnn(rs, index_of[syn[i]] +
+ (fcr+i)*prim)];
}
}
}
@@ -63,9 +80,9 @@
/* Convert syndromes to index form, checking for nonzero condition */
syn_error = 0;
- for (i = 0; i < NROOTS; i++) {
+ for (i = 0; i < nroots; i++) {
syn_error |= s[i];
- s[i] = INDEX_OF[s[i]];
+ s[i] = index_of[s[i]];
}
if (!syn_error) {
@@ -77,24 +94,27 @@
}
decode:
- memset (&lambda[1], 0, NROOTS * sizeof (lambda[0]));
+ memset(&lambda[1], 0, nroots * sizeof(lambda[0]));
lambda[0] = 1;
if (no_eras > 0) {
/* Init lambda to be the erasure locator polynomial */
- lambda[1] = ALPHA_TO[MODNN (PRIM * (NN - 1 - eras_pos[0]))];
+ lambda[1] = alpha_to[rs_modnn(rs,
+ prim * (nn - 1 - eras_pos[0]))];
for (i = 1; i < no_eras; i++) {
- u = MODNN (PRIM * (NN - 1 - eras_pos[i]));
+ u = rs_modnn(rs, prim * (nn - 1 - eras_pos[i]));
for (j = i + 1; j > 0; j--) {
- tmp = INDEX_OF[lambda[j - 1]];
- if (tmp != A0)
- lambda[j] ^= ALPHA_TO[MODNN (u + tmp)];
+ tmp = index_of[lambda[j - 1]];
+ if (tmp != nn) {
+ lambda[j] ^=
+ alpha_to[rs_modnn(rs, u + tmp)];
+ }
}
}
}
- for (i = 0; i < NROOTS + 1; i++)
- b[i] = INDEX_OF[lambda[i]];
+ for (i = 0; i < nroots + 1; i++)
+ b[i] = index_of[lambda[i]];
/*
* Begin Berlekamp-Massey algorithm to determine error+erasure
@@ -102,26 +122,31 @@
*/
r = no_eras;
el = no_eras;
- while (++r <= NROOTS) { /* r is the step number */
+ while (++r <= nroots) { /* r is the step number */
/* Compute discrepancy at the r-th step in poly-form */
discr_r = 0;
for (i = 0; i < r; i++) {
- if ((lambda[i] != 0) && (s[r - i - 1] != A0)) {
- discr_r ^= ALPHA_TO[MODNN (INDEX_OF[lambda[i]] + s[r - i - 1])];
+ if ((lambda[i] != 0) && (s[r - i - 1] != nn)) {
+ discr_r ^=
+ alpha_to[rs_modnn(rs,
+ index_of[lambda[i]] +
+ s[r - i - 1])];
}
}
- discr_r = INDEX_OF[discr_r]; /* Index form */
- if (discr_r == A0) {
+ discr_r = index_of[discr_r]; /* Index form */
+ if (discr_r == nn) {
/* 2 lines below: B(x) <-- x*B(x) */
- memmove (&b[1], b, NROOTS * sizeof (b[0]));
- b[0] = A0;
+ memmove (&b[1], b, nroots * sizeof (b[0]));
+ b[0] = nn;
} else {
- /* 7 lines below: T(x) <-- lambda(x) - discr_r*x*b(x) */
+ /* 7 lines below: T(x) <-- lambda(x)-discr_r*x*b(x) */
t[0] = lambda[0];
- for (i = 0; i < NROOTS; i++) {
- if (b[i] != A0)
- t[i + 1] = lambda[i + 1] ^ ALPHA_TO[MODNN (discr_r + b[i])];
- else
+ for (i = 0; i < nroots; i++) {
+ if (b[i] != nn) {
+ t[i + 1] = lambda[i + 1] ^
+ alpha_to[rs_modnn(rs, discr_r +
+ b[i])];
+ } else
t[i + 1] = lambda[i + 1];
}
if (2 * el <= r + no_eras - 1) {
@@ -130,33 +155,36 @@
* 2 lines below: B(x) <-- inv(discr_r) *
* lambda(x)
*/
- for (i = 0; i <= NROOTS; i++)
- b[i] = (lambda[i] == 0) ? A0 : MODNN (INDEX_OF[lambda[i]] - discr_r + NN);
+ for (i = 0; i <= nroots; i++) {
+ b[i] = (lambda[i] == 0) ? nn :
+ rs_modnn(rs, index_of[lambda[i]]
+ - discr_r + nn);
+ }
} else {
/* 2 lines below: B(x) <-- x*B(x) */
- memmove (&b[1], b, NROOTS * sizeof (b[0]));
- b[0] = A0;
+ memmove(&b[1], b, nroots * sizeof(b[0]));
+ b[0] = nn;
}
- memcpy (lambda, t, (NROOTS + 1) * sizeof (t[0]));
+ memcpy(lambda, t, (nroots + 1) * sizeof(t[0]));
}
}
/* Convert lambda to index form and compute deg(lambda(x)) */
deg_lambda = 0;
- for (i = 0; i < NROOTS + 1; i++) {
- lambda[i] = INDEX_OF[lambda[i]];
- if (lambda[i] != A0)
+ for (i = 0; i < nroots + 1; i++) {
+ lambda[i] = index_of[lambda[i]];
+ if (lambda[i] != nn)
deg_lambda = i;
}
- /* Find roots of the error+erasure locator polynomial by Chien search */
- memcpy (®[1], &lambda[1], NROOTS * sizeof (reg[0]));
+ /* Find roots of error+erasure locator polynomial by Chien search */
+ memcpy(®[1], &lambda[1], nroots * sizeof(reg[0]));
count = 0; /* Number of roots of lambda(x) */
- for (i = 1, k = IPRIM - 1; i <= NN; i++, k = MODNN (k + IPRIM)) {
+ for (i = 1, k = iprim - 1; i <= nn; i++, k = rs_modnn(rs, k + iprim)) {
q = 1; /* lambda[0] is always 0 */
for (j = deg_lambda; j > 0; j--) {
- if (reg[j] != A0) {
- reg[j] = MODNN (reg[j] + j);
- q ^= ALPHA_TO[reg[j]];
+ if (reg[j] != nn) {
+ reg[j] = rs_modnn(rs, reg[j] + j);
+ q ^= alpha_to[reg[j]];
}
}
if (q != 0)
@@ -180,47 +208,56 @@
}
/*
* Compute err+eras evaluator poly omega(x) = s(x)*lambda(x) (modulo
- * x**NROOTS). in index form. Also find deg(omega).
+ * x**nroots). in index form. Also find deg(omega).
*/
deg_omega = deg_lambda - 1;
for (i = 0; i <= deg_omega; i++) {
tmp = 0;
for (j = i; j >= 0; j--) {
- if ((s[i - j] != A0) && (lambda[j] != A0))
+ if ((s[i - j] != nn) && (lambda[j] != nn))
tmp ^=
- ALPHA_TO[MODNN (s[i - j] + lambda[j])];
+ alpha_to[rs_modnn(rs, s[i - j] + lambda[j])];
}
- omega[i] = INDEX_OF[tmp];
+ omega[i] = index_of[tmp];
}
/*
* Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
- * inv(X(l))**(FCR-1) and den = lambda_pr(inv(X(l))) all in poly-form
+ * inv(X(l))**(fcr-1) and den = lambda_pr(inv(X(l))) all in poly-form
*/
for (j = count - 1; j >= 0; j--) {
num1 = 0;
for (i = deg_omega; i >= 0; i--) {
- if (omega[i] != A0)
- num1 ^= ALPHA_TO[MODNN (omega[i] + i * root[j])];
+ if (omega[i] != nn)
+ num1 ^= alpha_to[rs_modnn(rs, omega[i] +
+ i * root[j])];
}
- num2 = ALPHA_TO[MODNN (root[j] * (FCR - 1) + NN)];
+ num2 = alpha_to[rs_modnn(rs, root[j] * (fcr - 1) + nn)];
den = 0;
- /* lambda[i+1] for i even is the formal derivative lambda_pr of lambda[i] */
- for (i = min (deg_lambda, NROOTS - 1) & ~1; i >= 0; i -= 2) {
- if (lambda[i + 1] != A0)
- den ^= ALPHA_TO[MODNN (lambda[i + 1] + i * root[j])];
+ /* lambda[i+1] for i even is the formal derivative
+ * lambda_pr of lambda[i] */
+ for (i = min(deg_lambda, nroots - 1) & ~1; i >= 0; i -= 2) {
+ if (lambda[i + 1] != nn) {
+ den ^= alpha_to[rs_modnn(rs, lambda[i + 1] +
+ i * root[j])];
+ }
}
/* Apply error to data */
- if (num1 != 0 && loc[j] >= PAD) {
- uint16_t cor = ALPHA_TO[MODNN (INDEX_OF[num1] + INDEX_OF[num2] + NN - INDEX_OF[den])];
- /* Store the error correction pattern, if a correction buffer is available */
+ if (num1 != 0 && loc[j] >= pad) {
+ uint16_t cor = alpha_to[rs_modnn(rs,index_of[num1] +
+ index_of[num2] +
+ nn - index_of[den])];
+ /* Store the error correction pattern, if a
+ * correction buffer is available */
if (corr) {
corr[j] = cor;
} else {
- /* If a data buffer is given and the error is inside the message, correct it */
- if (data && (loc[j] < (NN - NROOTS)))
- data[loc[j] - PAD] ^= cor;
+ /* If a data buffer is given and the
+ * error is inside the message,
+ * correct it */
+ if (data && (loc[j] < (nn - nroots)))
+ data[loc[j] - pad] ^= cor;
}
}
}
@@ -228,7 +265,7 @@
finish:
if (eras_pos != NULL) {
for (i = 0; i < count; i++)
- eras_pos[i] = loc[i] - PAD;
+ eras_pos[i] = loc[i] - pad;
}
return count;
Index: encode_rs.c
===================================================================
RCS file: /home/cvs/mtd/lib/reed_solomon/encode_rs.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- encode_rs.c 19 Sep 2004 12:09:40 -0000 1.2
+++ encode_rs.c 5 Oct 2004 22:07:53 -0000 1.3
@@ -19,27 +19,36 @@
*/
{
int i, j, pad;
- uint16_t feedback;
- uint16_t msk = (uint16_t) NN;
+ int nn = rs->nn;
+ int nroots = rs->nroots;
+ uint16_t *alpha_to = rs->alpha_to;
+ uint16_t *index_of = rs->index_of;
+ uint16_t *genpoly = rs->genpoly;
+ uint16_t fb;
+ uint16_t msk = (uint16_t) rs->nn;
/* Check length parameter for validity */
- pad = NN - NROOTS - len;
- if (pad < 0 || pad >= NN)
+ pad = nn - nroots - len;
+ if (pad < 0 || pad >= nn)
return -ERANGE;
for (i = 0; i < len; i++) {
- feedback = INDEX_OF[((((uint16_t) data[i])^invmsk) & msk) ^ par[0]];
+ fb = index_of[((((uint16_t) data[i])^invmsk) & msk) ^ par[0]];
/* feedback term is non-zero */
- if (feedback != A0) {
- for (j = 1; j < NROOTS; j++)
- par[j] ^= ALPHA_TO[MODNN (feedback + GENPOLY[NROOTS - j])];
+ if (fb != nn) {
+ for (j = 1; j < nroots; j++) {
+ par[j] ^= alpha_to[rs_modnn(rs, fb +
+ genpoly[nroots - j])];
+ }
}
/* Shift */
- memmove (&par[0], &par[1], sizeof (uint16_t) * (NROOTS - 1));
- if (feedback != A0)
- par[NROOTS - 1] = ALPHA_TO[MODNN (feedback + GENPOLY[0])];
- else
- par[NROOTS - 1] = 0;
+ memmove(&par[0], &par[1], sizeof(uint16_t) * (nroots - 1));
+ if (fb != nn) {
+ par[nroots - 1] = alpha_to[rs_modnn(rs,
+ fb + genpoly[0])];
+ } else {
+ par[nroots - 1] = 0;
+ }
}
return 0;
}
Index: rslib.c
===================================================================
RCS file: /home/cvs/mtd/lib/reed_solomon/rslib.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- rslib.c 1 Oct 2004 21:44:39 -0000 1.3
+++ rslib.c 5 Oct 2004 22:07:53 -0000 1.4
@@ -63,13 +63,14 @@
* Allocate a control structure and the polynom arrays for faster
* en/decoding. Fill the arrays according to the given parameters
*/
-static struct rs_control *rs_init (int symsize, int gfpoly, int fcr, int prim, int nroots)
+static struct rs_control *rs_init(int symsize, int gfpoly, int fcr,
+ int prim, int nroots)
{
struct rs_control *rs;
int i, j, sr, root, iprim;
/* Allocate the control structure */
- rs = (struct rs_control *) kmalloc (sizeof (struct rs_control), GFP_KERNEL);
+ rs = kmalloc(sizeof (struct rs_control), GFP_KERNEL);
if (rs == NULL)
return NULL;
@@ -83,16 +84,16 @@
rs->gfpoly = gfpoly;
/* Allocate the arrays */
- rs->alpha_to = (uint16_t *) kmalloc (sizeof (uint16_t) * (rs->nn + 1), GFP_KERNEL);
+ rs->alpha_to = kmalloc(sizeof(uint16_t) * (rs->nn + 1), GFP_KERNEL);
if (rs->alpha_to == NULL)
goto errrs;
- rs->index_of = (uint16_t *) kmalloc (sizeof (uint16_t) * (rs->nn + 1), GFP_KERNEL);
+ rs->index_of = kmalloc(sizeof(uint16_t) * (rs->nn + 1), GFP_KERNEL);
if (rs->index_of == NULL)
goto erralp;
- rs->genpoly = (uint16_t *) kmalloc (sizeof (uint16_t) * (rs->nroots + 1), GFP_KERNEL);
- if (rs->genpoly == NULL)
+ rs->genpoly = kmalloc(sizeof(uint16_t) * (rs->nroots + 1), GFP_KERNEL);
+ if(rs->genpoly == NULL)
goto erridx;
/* Generate Galois field lookup tables */
@@ -108,11 +109,11 @@
sr &= rs->nn;
}
/* If it's not primitive, exit */
- if (sr != 1)
+ if(sr != 1)
goto errpol;
/* Find prim-th root of 1, used in decoding */
- for (iprim = 1; (iprim % prim) != 0; iprim += rs->nn);
+ for(iprim = 1; (iprim % prim) != 0; iprim += rs->nn);
/* prim-th root of 1, index form */
rs->iprim = iprim / prim;
@@ -120,16 +121,19 @@
rs->genpoly[0] = 1;
for (i = 0, root = fcr * prim; i < nroots; i++, root += prim) {
rs->genpoly[i + 1] = 1;
-
/* Multiply rs->genpoly[] by @**(root + x) */
for (j = i; j > 0; j--) {
- if (rs->genpoly[j] != 0)
- rs->genpoly[j] = rs->genpoly[j -1] ^ rs->alpha_to[(rs->index_of[rs->genpoly[j]] + root) % rs->nn];
- else
+ if (rs->genpoly[j] != 0) {
+ rs->genpoly[j] = rs->genpoly[j -1] ^
+ rs->alpha_to[rs_modnn(rs,
+ rs->index_of[rs->genpoly[j]] + root)];
+ } else
rs->genpoly[j] = rs->genpoly[j - 1];
}
/* rs->genpoly[0] can never be zero */
- rs->genpoly[0] = rs->alpha_to[(rs->index_of[rs->genpoly[0]] + root) % rs->nn];
+ rs->genpoly[0] =
+ rs->alpha_to[rs_modnn(rs,
+ rs->index_of[rs->genpoly[0]] + root)];
}
/* convert rs->genpoly[] to index form for quicker encoding */
for (i = 0; i <= nroots; i++)
@@ -138,13 +142,13 @@
/* Error exit */
errpol:
- kfree (rs->genpoly);
+ kfree(rs->genpoly);
erridx:
- kfree (rs->index_of);
+ kfree(rs->index_of);
erralp:
- kfree (rs->alpha_to);
+ kfree(rs->alpha_to);
errrs:
- kfree (rs);
+ kfree(rs);
return NULL;
}
@@ -155,18 +159,18 @@
* @rs: the control structure which is not longer used by the
* caller
*/
-void free_rs (struct rs_control *rs)
+void free_rs(struct rs_control *rs)
{
- down (&rslistlock);
+ down(&rslistlock);
rs->users--;
- if (!rs->users) {
- list_del (&rs->list);
- kfree (rs->alpha_to);
- kfree (rs->index_of);
- kfree (rs->genpoly);
- kfree (rs);
+ if(!rs->users) {
+ list_del(&rs->list);
+ kfree(rs->alpha_to);
+ kfree(rs->index_of);
+ kfree(rs->genpoly);
+ kfree(rs);
}
- up (&rslistlock);
+ up(&rslistlock);
}
/**
@@ -181,7 +185,8 @@
* @prim: primitive element to generate polynomial roots
* @nroots: RS code generator polynomial degree (number of roots)
*/
-struct rs_control *init_rs (int symsize, int gfpoly, int fcr, int prim, int nroots)
+struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
+ int nroots)
{
struct list_head *tmp;
struct rs_control *rs;
@@ -193,14 +198,14 @@
return NULL;
if (prim <= 0 || prim >= (1<<symsize))
return NULL;
- if (nroots < 0 || nroots >= (1<<symsize))
+ if (nroots < 0 || nroots >= (1<<symsize) || nroots > 8)
return NULL;
- down (&rslistlock);
+ down(&rslistlock);
/* Walk through the list and look for a matching entry */
- list_for_each (tmp, &rslist) {
- rs = list_entry (tmp, struct rs_control, list);
+ list_for_each(tmp, &rslist) {
+ rs = list_entry(tmp, struct rs_control, list);
if (symsize != rs->mm)
continue;
if (gfpoly != rs->gfpoly)
@@ -217,34 +222,39 @@
}
/* Create a new one */
- rs = rs_init (symsize, gfpoly, fcr, prim, nroots);
+ rs = rs_init(symsize, gfpoly, fcr, prim, nroots);
if (rs) {
rs->users = 1;
- list_add (&rs->list, &rslist);
+ list_add(&rs->list, &rslist);
}
out:
- up (&rslistlock);
+ up(&rslistlock);
return rs;
}
+#ifdef CONFIG_REED_SOLOMON_ENC8
/**
* encode_rs8 - Calculate the parity for data values (8bit data width)
*
* @rs: the rs control structure
* @data: data field of a given type
* @len: data length
- * @par: parity data field, must be initialized by caller (usually all 0)
+ * @par: parity data, must be initialized by caller (usually all 0)
* @invmsk: invert data mask (will be xored on data)
*
* The parity uses a uint16_t data type to enable
* symbol size > 8. The calling code must take care of encoding of the
* syndrome result for storage itself.
*/
-int encode_rs8 (struct rs_control *rs, uint8_t *data, int len, uint16_t *par, uint16_t invmsk)
+int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par,
+ uint16_t invmsk)
{
#include "encode_rs.c"
}
+EXPORT_SYMBOL_GPL(encode_rs8);
+#endif
+#ifdef CONFIG_REED_SOLOMON_DEC8
/**
* decode_rs8 - Decode codeword (8bit data width)
*
@@ -262,28 +272,36 @@
* symbol size > 8. The calling code must take care of decoding of the
* syndrome result and the received parity before calling this code.
*/
-int decode_rs8 (struct rs_control *rs, uint8_t *data, uint16_t *par, int len,
- uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, uint16_t *corr)
+int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len,
+ uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,
+ uint16_t *corr)
{
#include "decode_rs.c"
}
+EXPORT_SYMBOL_GPL(decode_rs8);
+#endif
+#ifdef CONFIG_REED_SOLOMON_ENC16
/**
* encode_rs16 - Calculate the parity for data values (16bit data width)
*
* @rs: the rs control structure
* @data: data field of a given type
* @len: data length
- * @par: parity data field, must be initialized by caller (usually all 0)
+ * @par: parity data, must be initialized by caller (usually all 0)
* @invmsk: invert data mask (will be xored on data, not on parity!)
*
* Each field in the data array contains up to symbol size bits of valid data.
*/
-int encode_rs16 (struct rs_control *rs, uint16_t *data, int len, uint16_t *par, uint16_t invmsk)
+int encode_rs16(struct rs_control *rs, uint16_t *data, int len, uint16_t *par,
+ uint16_t invmsk)
{
#include "encode_rs.c"
}
+EXPORT_SYMBOL_GPL(encode_rs16);
+#endif
+#ifdef CONFIG_REED_SOLOMON_DEC16
/**
* decode_rs16 - Decode codeword (16bit data width)
*
@@ -299,66 +317,19 @@
*
* Each field in the data array contains up to symbol size bits of valid data.
*/
-int decode_rs16 (struct rs_control *rs, uint16_t *data, uint16_t *par, int len,
- uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, uint16_t *corr)
+int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len,
+ uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,
+ uint16_t *corr)
{
#include "decode_rs.c"
}
+EXPORT_SYMBOL_GPL(decode_rs16);
+#endif
-/**
- * encode_rs32 - Calculate the parity for data values (32bit data width)
- *
- * @rs: the rs control structure
- * @data: data field of a given type
- * @len: data length
- * @par: parity data field, must be initialized by caller (usually all 0)
- * @invmsk: invert data mask (will be xored on data)
- *
- * The parity uses a uint16_t data type due to the fact that
- * we can't handle symbol size >= 16 bit as the polynominal arrays would
- * be to large and the computation would be extreme slow.
- * Each field in the data array contains up to symbol size bits of data.
- */
-int encode_rs32 (struct rs_control *rs, uint32_t *data, int len, uint16_t *par, uint16_t invmsk)
-{
-#include "encode_rs.c"
-}
-
-/**
- * decode_rs32 - Decode codeword (32bit data width)
- *
- * @rs: the rs control structure
- * @data: data field of a given type
- * @par: received parity data field
- * @len: data length
- * @s: syndrome data field (if NULL, syndrome is calculated)
- * @no_eras: number of erasures
- * @eras_pos: position of erasures, can be NULL
- * @invmsk: invert data mask (will be xored on data, not on parity!)
- * @corr: buffer to store correction bitmask on eras_pos
- *
- * The syndrome and parity use a uint16_t data type due to the fact that
- * we can't handle symbol size > 16 as the polynominal arrays would be to
- * large and the computation would be extreme slow. The calling code must
- * take care of decoding of the syndrome result and the received parity
- * before calling this code.
- * Each field in the data array contains up to symbol size bits of data.
- */
-int decode_rs32 (struct rs_control *rs, uint32_t *data, uint16_t *par, int len,
- uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, uint16_t *corr)
-{
-#include "decode_rs.c"
-}
-
-EXPORT_SYMBOL(encode_rs8);
-EXPORT_SYMBOL(encode_rs16);
-EXPORT_SYMBOL(encode_rs32);
-EXPORT_SYMBOL(decode_rs8);
-EXPORT_SYMBOL(decode_rs16);
-EXPORT_SYMBOL(decode_rs32);
-EXPORT_SYMBOL(init_rs);
-EXPORT_SYMBOL(free_rs);
+EXPORT_SYMBOL_GPL(init_rs);
+EXPORT_SYMBOL_GPL(free_rs);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Reed Solomon encoder/decoder");
MODULE_AUTHOR("Phil Karn, Thomas Gleixner");
+
More information about the linux-mtd-cvs
mailing list