diff options
-rw-r--r-- | include/linux/rslib.h | 28 | ||||
-rw-r--r-- | lib/reed_solomon/Makefile | 2 | ||||
-rw-r--r-- | lib/reed_solomon/decode_rs.c | 36 | ||||
-rw-r--r-- | lib/reed_solomon/encode_rs.c | 14 | ||||
-rw-r--r-- | lib/reed_solomon/reed_solomon.c | 64 |
5 files changed, 72 insertions, 72 deletions
diff --git a/include/linux/rslib.h b/include/linux/rslib.h index 980c8f74d8dc..ace25acfdc97 100644 --- a/include/linux/rslib.h +++ b/include/linux/rslib.h | |||
@@ -1,15 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | * include/linux/rslib.h | 2 | * include/linux/rslib.h |
3 | * | 3 | * |
4 | * Overview: | 4 | * Overview: |
5 | * Generic Reed Solomon encoder / decoder library | 5 | * Generic Reed Solomon encoder / decoder library |
6 | * | 6 | * |
7 | * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de) | 7 | * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de) |
8 | * | 8 | * |
9 | * RS code lifted from reed solomon library written by Phil Karn | 9 | * RS code lifted from reed solomon library written by Phil Karn |
10 | * Copyright 2002 Phil Karn, KA9Q | 10 | * Copyright 2002 Phil Karn, KA9Q |
11 | * | 11 | * |
12 | * $Id: rslib.h,v 1.3 2004/10/05 22:08:22 gleixner Exp $ | 12 | * $Id: rslib.h,v 1.4 2005/11/07 11:14:52 gleixner Exp $ |
13 | * | 13 | * |
14 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU General Public License version 2 as | 15 | * it under the terms of the GNU General Public License version 2 as |
@@ -21,20 +21,20 @@ | |||
21 | 21 | ||
22 | #include <linux/list.h> | 22 | #include <linux/list.h> |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * struct rs_control - rs control structure | 25 | * struct rs_control - rs control structure |
26 | * | 26 | * |
27 | * @mm: Bits per symbol | 27 | * @mm: Bits per symbol |
28 | * @nn: Symbols per block (= (1<<mm)-1) | 28 | * @nn: Symbols per block (= (1<<mm)-1) |
29 | * @alpha_to: log lookup table | 29 | * @alpha_to: log lookup table |
30 | * @index_of: Antilog lookup table | 30 | * @index_of: Antilog lookup table |
31 | * @genpoly: Generator polynomial | 31 | * @genpoly: Generator polynomial |
32 | * @nroots: Number of generator roots = number of parity symbols | 32 | * @nroots: Number of generator roots = number of parity symbols |
33 | * @fcr: First consecutive root, index form | 33 | * @fcr: First consecutive root, index form |
34 | * @prim: Primitive element, index form | 34 | * @prim: Primitive element, index form |
35 | * @iprim: prim-th root of 1, index form | 35 | * @iprim: prim-th root of 1, index form |
36 | * @gfpoly: The primitive generator polynominal | 36 | * @gfpoly: The primitive generator polynominal |
37 | * @users: Users of this structure | 37 | * @users: Users of this structure |
38 | * @list: List entry for the rs control list | 38 | * @list: List entry for the rs control list |
39 | */ | 39 | */ |
40 | struct rs_control { | 40 | struct rs_control { |
@@ -58,7 +58,7 @@ int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par, | |||
58 | uint16_t invmsk); | 58 | uint16_t invmsk); |
59 | #endif | 59 | #endif |
60 | #ifdef CONFIG_REED_SOLOMON_DEC8 | 60 | #ifdef CONFIG_REED_SOLOMON_DEC8 |
61 | int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, | 61 | int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, |
62 | uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, | 62 | uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, |
63 | uint16_t *corr); | 63 | uint16_t *corr); |
64 | #endif | 64 | #endif |
@@ -75,7 +75,7 @@ int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, | |||
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | /* Create or get a matching rs control structure */ | 77 | /* Create or get a matching rs control structure */ |
78 | struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, | 78 | struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, |
79 | int nroots); | 79 | int nroots); |
80 | 80 | ||
81 | /* Release a rs control structure */ | 81 | /* Release a rs control structure */ |
@@ -87,9 +87,9 @@ void free_rs(struct rs_control *rs); | |||
87 | * @x: the value to reduce | 87 | * @x: the value to reduce |
88 | * | 88 | * |
89 | * where | 89 | * where |
90 | * rs->mm = number of bits per symbol | 90 | * rs->mm = number of bits per symbol |
91 | * rs->nn = (2^rs->mm) - 1 | 91 | * rs->nn = (2^rs->mm) - 1 |
92 | * | 92 | * |
93 | * Simple arithmetic modulo would return a wrong result for values | 93 | * Simple arithmetic modulo would return a wrong result for values |
94 | * >= 3 * rs->nn | 94 | * >= 3 * rs->nn |
95 | */ | 95 | */ |
diff --git a/lib/reed_solomon/Makefile b/lib/reed_solomon/Makefile index 747a2de29346..c3d7136827ed 100644 --- a/lib/reed_solomon/Makefile +++ b/lib/reed_solomon/Makefile | |||
@@ -1,5 +1,5 @@ | |||
1 | # | 1 | # |
2 | # This is a modified version of reed solomon lib, | 2 | # This is a modified version of reed solomon lib, |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_REED_SOLOMON) += reed_solomon.o | 5 | obj-$(CONFIG_REED_SOLOMON) += reed_solomon.o |
diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c index d401decd6289..a58df56f09b6 100644 --- a/lib/reed_solomon/decode_rs.c +++ b/lib/reed_solomon/decode_rs.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * lib/reed_solomon/decode_rs.c | 2 | * lib/reed_solomon/decode_rs.c |
3 | * | 3 | * |
4 | * Overview: | 4 | * Overview: |
5 | * Generic Reed Solomon encoder / decoder library | 5 | * Generic Reed Solomon encoder / decoder library |
6 | * | 6 | * |
7 | * Copyright 2002, Phil Karn, KA9Q | 7 | * Copyright 2002, Phil Karn, KA9Q |
8 | * May be used under the terms of the GNU General Public License (GPL) | 8 | * May be used under the terms of the GNU General Public License (GPL) |
9 | * | 9 | * |
10 | * Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de) | 10 | * Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de) |
11 | * | 11 | * |
12 | * $Id: decode_rs.c,v 1.6 2004/10/22 15:41:47 gleixner Exp $ | 12 | * $Id: decode_rs.c,v 1.7 2005/11/07 11:14:59 gleixner Exp $ |
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /* Generic data width independent code which is included by the | 16 | /* Generic data width independent code which is included by the |
17 | * wrappers. | 17 | * wrappers. |
18 | */ | 18 | */ |
19 | { | 19 | { |
20 | int deg_lambda, el, deg_omega; | 20 | int deg_lambda, el, deg_omega; |
21 | int i, j, r, k, pad; | 21 | int i, j, r, k, pad; |
22 | int nn = rs->nn; | 22 | int nn = rs->nn; |
@@ -41,9 +41,9 @@ | |||
41 | pad = nn - nroots - len; | 41 | pad = nn - nroots - len; |
42 | if (pad < 0 || pad >= nn) | 42 | if (pad < 0 || pad >= nn) |
43 | return -ERANGE; | 43 | return -ERANGE; |
44 | 44 | ||
45 | /* Does the caller provide the syndrome ? */ | 45 | /* Does the caller provide the syndrome ? */ |
46 | if (s != NULL) | 46 | if (s != NULL) |
47 | goto decode; | 47 | goto decode; |
48 | 48 | ||
49 | /* form the syndromes; i.e., evaluate data(x) at roots of | 49 | /* form the syndromes; i.e., evaluate data(x) at roots of |
@@ -54,11 +54,11 @@ | |||
54 | for (j = 1; j < len; j++) { | 54 | for (j = 1; j < len; j++) { |
55 | for (i = 0; i < nroots; i++) { | 55 | for (i = 0; i < nroots; i++) { |
56 | if (syn[i] == 0) { | 56 | if (syn[i] == 0) { |
57 | syn[i] = (((uint16_t) data[j]) ^ | 57 | syn[i] = (((uint16_t) data[j]) ^ |
58 | invmsk) & msk; | 58 | invmsk) & msk; |
59 | } else { | 59 | } else { |
60 | syn[i] = ((((uint16_t) data[j]) ^ | 60 | syn[i] = ((((uint16_t) data[j]) ^ |
61 | invmsk) & msk) ^ | 61 | invmsk) & msk) ^ |
62 | alpha_to[rs_modnn(rs, index_of[syn[i]] + | 62 | alpha_to[rs_modnn(rs, index_of[syn[i]] + |
63 | (fcr + i) * prim)]; | 63 | (fcr + i) * prim)]; |
64 | } | 64 | } |
@@ -70,7 +70,7 @@ | |||
70 | if (syn[i] == 0) { | 70 | if (syn[i] == 0) { |
71 | syn[i] = ((uint16_t) par[j]) & msk; | 71 | syn[i] = ((uint16_t) par[j]) & msk; |
72 | } else { | 72 | } else { |
73 | syn[i] = (((uint16_t) par[j]) & msk) ^ | 73 | syn[i] = (((uint16_t) par[j]) & msk) ^ |
74 | alpha_to[rs_modnn(rs, index_of[syn[i]] + | 74 | alpha_to[rs_modnn(rs, index_of[syn[i]] + |
75 | (fcr+i)*prim)]; | 75 | (fcr+i)*prim)]; |
76 | } | 76 | } |
@@ -99,14 +99,14 @@ | |||
99 | 99 | ||
100 | if (no_eras > 0) { | 100 | if (no_eras > 0) { |
101 | /* Init lambda to be the erasure locator polynomial */ | 101 | /* Init lambda to be the erasure locator polynomial */ |
102 | lambda[1] = alpha_to[rs_modnn(rs, | 102 | lambda[1] = alpha_to[rs_modnn(rs, |
103 | prim * (nn - 1 - eras_pos[0]))]; | 103 | prim * (nn - 1 - eras_pos[0]))]; |
104 | for (i = 1; i < no_eras; i++) { | 104 | for (i = 1; i < no_eras; i++) { |
105 | u = rs_modnn(rs, prim * (nn - 1 - eras_pos[i])); | 105 | u = rs_modnn(rs, prim * (nn - 1 - eras_pos[i])); |
106 | for (j = i + 1; j > 0; j--) { | 106 | for (j = i + 1; j > 0; j--) { |
107 | tmp = index_of[lambda[j - 1]]; | 107 | tmp = index_of[lambda[j - 1]]; |
108 | if (tmp != nn) { | 108 | if (tmp != nn) { |
109 | lambda[j] ^= | 109 | lambda[j] ^= |
110 | alpha_to[rs_modnn(rs, u + tmp)]; | 110 | alpha_to[rs_modnn(rs, u + tmp)]; |
111 | } | 111 | } |
112 | } | 112 | } |
@@ -127,8 +127,8 @@ | |||
127 | discr_r = 0; | 127 | discr_r = 0; |
128 | for (i = 0; i < r; i++) { | 128 | for (i = 0; i < r; i++) { |
129 | if ((lambda[i] != 0) && (s[r - i - 1] != nn)) { | 129 | if ((lambda[i] != 0) && (s[r - i - 1] != nn)) { |
130 | discr_r ^= | 130 | discr_r ^= |
131 | alpha_to[rs_modnn(rs, | 131 | alpha_to[rs_modnn(rs, |
132 | index_of[lambda[i]] + | 132 | index_of[lambda[i]] + |
133 | s[r - i - 1])]; | 133 | s[r - i - 1])]; |
134 | } | 134 | } |
@@ -143,7 +143,7 @@ | |||
143 | t[0] = lambda[0]; | 143 | t[0] = lambda[0]; |
144 | for (i = 0; i < nroots; i++) { | 144 | for (i = 0; i < nroots; i++) { |
145 | if (b[i] != nn) { | 145 | if (b[i] != nn) { |
146 | t[i + 1] = lambda[i + 1] ^ | 146 | t[i + 1] = lambda[i + 1] ^ |
147 | alpha_to[rs_modnn(rs, discr_r + | 147 | alpha_to[rs_modnn(rs, discr_r + |
148 | b[i])]; | 148 | b[i])]; |
149 | } else | 149 | } else |
@@ -229,7 +229,7 @@ | |||
229 | num1 = 0; | 229 | num1 = 0; |
230 | for (i = deg_omega; i >= 0; i--) { | 230 | for (i = deg_omega; i >= 0; i--) { |
231 | if (omega[i] != nn) | 231 | if (omega[i] != nn) |
232 | num1 ^= alpha_to[rs_modnn(rs, omega[i] + | 232 | num1 ^= alpha_to[rs_modnn(rs, omega[i] + |
233 | i * root[j])]; | 233 | i * root[j])]; |
234 | } | 234 | } |
235 | num2 = alpha_to[rs_modnn(rs, root[j] * (fcr - 1) + nn)]; | 235 | num2 = alpha_to[rs_modnn(rs, root[j] * (fcr - 1) + nn)]; |
@@ -239,13 +239,13 @@ | |||
239 | * lambda_pr of lambda[i] */ | 239 | * lambda_pr of lambda[i] */ |
240 | for (i = min(deg_lambda, nroots - 1) & ~1; i >= 0; i -= 2) { | 240 | for (i = min(deg_lambda, nroots - 1) & ~1; i >= 0; i -= 2) { |
241 | if (lambda[i + 1] != nn) { | 241 | if (lambda[i + 1] != nn) { |
242 | den ^= alpha_to[rs_modnn(rs, lambda[i + 1] + | 242 | den ^= alpha_to[rs_modnn(rs, lambda[i + 1] + |
243 | i * root[j])]; | 243 | i * root[j])]; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | /* Apply error to data */ | 246 | /* Apply error to data */ |
247 | if (num1 != 0 && loc[j] >= pad) { | 247 | if (num1 != 0 && loc[j] >= pad) { |
248 | uint16_t cor = alpha_to[rs_modnn(rs,index_of[num1] + | 248 | uint16_t cor = alpha_to[rs_modnn(rs,index_of[num1] + |
249 | index_of[num2] + | 249 | index_of[num2] + |
250 | nn - index_of[den])]; | 250 | nn - index_of[den])]; |
251 | /* Store the error correction pattern, if a | 251 | /* Store the error correction pattern, if a |
diff --git a/lib/reed_solomon/encode_rs.c b/lib/reed_solomon/encode_rs.c index 237bf65ae886..0b5b1a6728ec 100644 --- a/lib/reed_solomon/encode_rs.c +++ b/lib/reed_solomon/encode_rs.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | * lib/reed_solomon/encode_rs.c | 2 | * lib/reed_solomon/encode_rs.c |
3 | * | 3 | * |
4 | * Overview: | 4 | * Overview: |
5 | * Generic Reed Solomon encoder / decoder library | 5 | * Generic Reed Solomon encoder / decoder library |
6 | * | 6 | * |
7 | * Copyright 2002, Phil Karn, KA9Q | 7 | * Copyright 2002, Phil Karn, KA9Q |
8 | * May be used under the terms of the GNU General Public License (GPL) | 8 | * May be used under the terms of the GNU General Public License (GPL) |
9 | * | 9 | * |
10 | * Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de) | 10 | * Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de) |
11 | * | 11 | * |
12 | * $Id: encode_rs.c,v 1.4 2004/10/22 15:41:47 gleixner Exp $ | 12 | * $Id: encode_rs.c,v 1.5 2005/11/07 11:14:59 gleixner Exp $ |
13 | * | 13 | * |
14 | */ | 14 | */ |
15 | 15 | ||
16 | /* Generic data width independent code which is included by the | 16 | /* Generic data width independent code which is included by the |
17 | * wrappers. | 17 | * wrappers. |
18 | * int encode_rsX (struct rs_control *rs, uintX_t *data, int len, uintY_t *par) | 18 | * int encode_rsX (struct rs_control *rs, uintX_t *data, int len, uintY_t *par) |
19 | */ | 19 | */ |
@@ -35,16 +35,16 @@ | |||
35 | for (i = 0; i < len; i++) { | 35 | for (i = 0; i < len; i++) { |
36 | fb = index_of[((((uint16_t) data[i])^invmsk) & msk) ^ par[0]]; | 36 | fb = index_of[((((uint16_t) data[i])^invmsk) & msk) ^ par[0]]; |
37 | /* feedback term is non-zero */ | 37 | /* feedback term is non-zero */ |
38 | if (fb != nn) { | 38 | if (fb != nn) { |
39 | for (j = 1; j < nroots; j++) { | 39 | for (j = 1; j < nroots; j++) { |
40 | par[j] ^= alpha_to[rs_modnn(rs, fb + | 40 | par[j] ^= alpha_to[rs_modnn(rs, fb + |
41 | genpoly[nroots - j])]; | 41 | genpoly[nroots - j])]; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | /* Shift */ | 44 | /* Shift */ |
45 | memmove(&par[0], &par[1], sizeof(uint16_t) * (nroots - 1)); | 45 | memmove(&par[0], &par[1], sizeof(uint16_t) * (nroots - 1)); |
46 | if (fb != nn) { | 46 | if (fb != nn) { |
47 | par[nroots - 1] = alpha_to[rs_modnn(rs, | 47 | par[nroots - 1] = alpha_to[rs_modnn(rs, |
48 | fb + genpoly[0])]; | 48 | fb + genpoly[0])]; |
49 | } else { | 49 | } else { |
50 | par[nroots - 1] = 0; | 50 | par[nroots - 1] = 0; |
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c index 6604e3b1940c..f5fef948a415 100644 --- a/lib/reed_solomon/reed_solomon.c +++ b/lib/reed_solomon/reed_solomon.c | |||
@@ -1,22 +1,22 @@ | |||
1 | /* | 1 | /* |
2 | * lib/reed_solomon/rslib.c | 2 | * lib/reed_solomon/rslib.c |
3 | * | 3 | * |
4 | * Overview: | 4 | * Overview: |
5 | * Generic Reed Solomon encoder / decoder library | 5 | * Generic Reed Solomon encoder / decoder library |
6 | * | 6 | * |
7 | * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de) | 7 | * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de) |
8 | * | 8 | * |
9 | * Reed Solomon code lifted from reed solomon library written by Phil Karn | 9 | * Reed Solomon code lifted from reed solomon library written by Phil Karn |
10 | * Copyright 2002 Phil Karn, KA9Q | 10 | * Copyright 2002 Phil Karn, KA9Q |
11 | * | 11 | * |
12 | * $Id: rslib.c,v 1.5 2004/10/22 15:41:47 gleixner Exp $ | 12 | * $Id: rslib.c,v 1.7 2005/11/07 11:14:59 gleixner Exp $ |
13 | * | 13 | * |
14 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU General Public License version 2 as | 15 | * it under the terms of the GNU General Public License version 2 as |
16 | * published by the Free Software Foundation. | 16 | * published by the Free Software Foundation. |
17 | * | 17 | * |
18 | * Description: | 18 | * Description: |
19 | * | 19 | * |
20 | * The generic Reed Solomon library provides runtime configurable | 20 | * The generic Reed Solomon library provides runtime configurable |
21 | * encoding / decoding of RS codes. | 21 | * encoding / decoding of RS codes. |
22 | * Each user must call init_rs to get a pointer to a rs_control | 22 | * Each user must call init_rs to get a pointer to a rs_control |
@@ -25,11 +25,11 @@ | |||
25 | * If a structure is generated then the polynomial arrays for | 25 | * If a structure is generated then the polynomial arrays for |
26 | * fast encoding / decoding are built. This can take some time so | 26 | * fast encoding / decoding are built. This can take some time so |
27 | * make sure not to call this function from a time critical path. | 27 | * make sure not to call this function from a time critical path. |
28 | * Usually a module / driver should initialize the necessary | 28 | * Usually a module / driver should initialize the necessary |
29 | * rs_control structure on module / driver init and release it | 29 | * rs_control structure on module / driver init and release it |
30 | * on exit. | 30 | * on exit. |
31 | * The encoding puts the calculated syndrome into a given syndrome | 31 | * The encoding puts the calculated syndrome into a given syndrome |
32 | * buffer. | 32 | * buffer. |
33 | * The decoding is a two step process. The first step calculates | 33 | * The decoding is a two step process. The first step calculates |
34 | * the syndrome over the received (data + syndrome) and calls the | 34 | * the syndrome over the received (data + syndrome) and calls the |
35 | * second stage, which does the decoding / error correction itself. | 35 | * second stage, which does the decoding / error correction itself. |
@@ -51,7 +51,7 @@ static LIST_HEAD (rslist); | |||
51 | /* Protection for the list */ | 51 | /* Protection for the list */ |
52 | static DECLARE_MUTEX(rslistlock); | 52 | static DECLARE_MUTEX(rslistlock); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * rs_init - Initialize a Reed-Solomon codec | 55 | * rs_init - Initialize a Reed-Solomon codec |
56 | * | 56 | * |
57 | * @symsize: symbol size, bits (1-8) | 57 | * @symsize: symbol size, bits (1-8) |
@@ -63,7 +63,7 @@ static DECLARE_MUTEX(rslistlock); | |||
63 | * Allocate a control structure and the polynom arrays for faster | 63 | * Allocate a control structure and the polynom arrays for faster |
64 | * en/decoding. Fill the arrays according to the given parameters | 64 | * en/decoding. Fill the arrays according to the given parameters |
65 | */ | 65 | */ |
66 | static struct rs_control *rs_init(int symsize, int gfpoly, int fcr, | 66 | static struct rs_control *rs_init(int symsize, int gfpoly, int fcr, |
67 | int prim, int nroots) | 67 | int prim, int nroots) |
68 | { | 68 | { |
69 | struct rs_control *rs; | 69 | struct rs_control *rs; |
@@ -124,15 +124,15 @@ static struct rs_control *rs_init(int symsize, int gfpoly, int fcr, | |||
124 | /* Multiply rs->genpoly[] by @**(root + x) */ | 124 | /* Multiply rs->genpoly[] by @**(root + x) */ |
125 | for (j = i; j > 0; j--) { | 125 | for (j = i; j > 0; j--) { |
126 | if (rs->genpoly[j] != 0) { | 126 | if (rs->genpoly[j] != 0) { |
127 | rs->genpoly[j] = rs->genpoly[j -1] ^ | 127 | rs->genpoly[j] = rs->genpoly[j -1] ^ |
128 | rs->alpha_to[rs_modnn(rs, | 128 | rs->alpha_to[rs_modnn(rs, |
129 | rs->index_of[rs->genpoly[j]] + root)]; | 129 | rs->index_of[rs->genpoly[j]] + root)]; |
130 | } else | 130 | } else |
131 | rs->genpoly[j] = rs->genpoly[j - 1]; | 131 | rs->genpoly[j] = rs->genpoly[j - 1]; |
132 | } | 132 | } |
133 | /* rs->genpoly[0] can never be zero */ | 133 | /* rs->genpoly[0] can never be zero */ |
134 | rs->genpoly[0] = | 134 | rs->genpoly[0] = |
135 | rs->alpha_to[rs_modnn(rs, | 135 | rs->alpha_to[rs_modnn(rs, |
136 | rs->index_of[rs->genpoly[0]] + root)]; | 136 | rs->index_of[rs->genpoly[0]] + root)]; |
137 | } | 137 | } |
138 | /* convert rs->genpoly[] to index form for quicker encoding */ | 138 | /* convert rs->genpoly[] to index form for quicker encoding */ |
@@ -153,7 +153,7 @@ errrs: | |||
153 | } | 153 | } |
154 | 154 | ||
155 | 155 | ||
156 | /** | 156 | /** |
157 | * free_rs - Free the rs control structure, if its not longer used | 157 | * free_rs - Free the rs control structure, if its not longer used |
158 | * | 158 | * |
159 | * @rs: the control structure which is not longer used by the | 159 | * @rs: the control structure which is not longer used by the |
@@ -173,19 +173,19 @@ void free_rs(struct rs_control *rs) | |||
173 | up(&rslistlock); | 173 | up(&rslistlock); |
174 | } | 174 | } |
175 | 175 | ||
176 | /** | 176 | /** |
177 | * init_rs - Find a matching or allocate a new rs control structure | 177 | * init_rs - Find a matching or allocate a new rs control structure |
178 | * | 178 | * |
179 | * @symsize: the symbol size (number of bits) | 179 | * @symsize: the symbol size (number of bits) |
180 | * @gfpoly: the extended Galois field generator polynomial coefficients, | 180 | * @gfpoly: the extended Galois field generator polynomial coefficients, |
181 | * with the 0th coefficient in the low order bit. The polynomial | 181 | * with the 0th coefficient in the low order bit. The polynomial |
182 | * must be primitive; | 182 | * must be primitive; |
183 | * @fcr: the first consecutive root of the rs code generator polynomial | 183 | * @fcr: the first consecutive root of the rs code generator polynomial |
184 | * in index form | 184 | * in index form |
185 | * @prim: primitive element to generate polynomial roots | 185 | * @prim: primitive element to generate polynomial roots |
186 | * @nroots: RS code generator polynomial degree (number of roots) | 186 | * @nroots: RS code generator polynomial degree (number of roots) |
187 | */ | 187 | */ |
188 | struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, | 188 | struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, |
189 | int nroots) | 189 | int nroots) |
190 | { | 190 | { |
191 | struct list_head *tmp; | 191 | struct list_head *tmp; |
@@ -198,9 +198,9 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, | |||
198 | return NULL; | 198 | return NULL; |
199 | if (prim <= 0 || prim >= (1<<symsize)) | 199 | if (prim <= 0 || prim >= (1<<symsize)) |
200 | return NULL; | 200 | return NULL; |
201 | if (nroots < 0 || nroots >= (1<<symsize) || nroots > 8) | 201 | if (nroots < 0 || nroots >= (1<<symsize)) |
202 | return NULL; | 202 | return NULL; |
203 | 203 | ||
204 | down(&rslistlock); | 204 | down(&rslistlock); |
205 | 205 | ||
206 | /* Walk through the list and look for a matching entry */ | 206 | /* Walk through the list and look for a matching entry */ |
@@ -211,9 +211,9 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, | |||
211 | if (gfpoly != rs->gfpoly) | 211 | if (gfpoly != rs->gfpoly) |
212 | continue; | 212 | continue; |
213 | if (fcr != rs->fcr) | 213 | if (fcr != rs->fcr) |
214 | continue; | 214 | continue; |
215 | if (prim != rs->prim) | 215 | if (prim != rs->prim) |
216 | continue; | 216 | continue; |
217 | if (nroots != rs->nroots) | 217 | if (nroots != rs->nroots) |
218 | continue; | 218 | continue; |
219 | /* We have a matching one already */ | 219 | /* We have a matching one already */ |
@@ -227,18 +227,18 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim, | |||
227 | rs->users = 1; | 227 | rs->users = 1; |
228 | list_add(&rs->list, &rslist); | 228 | list_add(&rs->list, &rslist); |
229 | } | 229 | } |
230 | out: | 230 | out: |
231 | up(&rslistlock); | 231 | up(&rslistlock); |
232 | return rs; | 232 | return rs; |
233 | } | 233 | } |
234 | 234 | ||
235 | #ifdef CONFIG_REED_SOLOMON_ENC8 | 235 | #ifdef CONFIG_REED_SOLOMON_ENC8 |
236 | /** | 236 | /** |
237 | * encode_rs8 - Calculate the parity for data values (8bit data width) | 237 | * encode_rs8 - Calculate the parity for data values (8bit data width) |
238 | * | 238 | * |
239 | * @rs: the rs control structure | 239 | * @rs: the rs control structure |
240 | * @data: data field of a given type | 240 | * @data: data field of a given type |
241 | * @len: data length | 241 | * @len: data length |
242 | * @par: parity data, must be initialized by caller (usually all 0) | 242 | * @par: parity data, must be initialized by caller (usually all 0) |
243 | * @invmsk: invert data mask (will be xored on data) | 243 | * @invmsk: invert data mask (will be xored on data) |
244 | * | 244 | * |
@@ -246,7 +246,7 @@ out: | |||
246 | * symbol size > 8. The calling code must take care of encoding of the | 246 | * symbol size > 8. The calling code must take care of encoding of the |
247 | * syndrome result for storage itself. | 247 | * syndrome result for storage itself. |
248 | */ | 248 | */ |
249 | int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par, | 249 | int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par, |
250 | uint16_t invmsk) | 250 | uint16_t invmsk) |
251 | { | 251 | { |
252 | #include "encode_rs.c" | 252 | #include "encode_rs.c" |
@@ -255,7 +255,7 @@ EXPORT_SYMBOL_GPL(encode_rs8); | |||
255 | #endif | 255 | #endif |
256 | 256 | ||
257 | #ifdef CONFIG_REED_SOLOMON_DEC8 | 257 | #ifdef CONFIG_REED_SOLOMON_DEC8 |
258 | /** | 258 | /** |
259 | * decode_rs8 - Decode codeword (8bit data width) | 259 | * decode_rs8 - Decode codeword (8bit data width) |
260 | * | 260 | * |
261 | * @rs: the rs control structure | 261 | * @rs: the rs control structure |
@@ -273,7 +273,7 @@ EXPORT_SYMBOL_GPL(encode_rs8); | |||
273 | * syndrome result and the received parity before calling this code. | 273 | * syndrome result and the received parity before calling this code. |
274 | */ | 274 | */ |
275 | int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, | 275 | int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, |
276 | uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, | 276 | uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, |
277 | uint16_t *corr) | 277 | uint16_t *corr) |
278 | { | 278 | { |
279 | #include "decode_rs.c" | 279 | #include "decode_rs.c" |
@@ -287,13 +287,13 @@ EXPORT_SYMBOL_GPL(decode_rs8); | |||
287 | * | 287 | * |
288 | * @rs: the rs control structure | 288 | * @rs: the rs control structure |
289 | * @data: data field of a given type | 289 | * @data: data field of a given type |
290 | * @len: data length | 290 | * @len: data length |
291 | * @par: parity data, must be initialized by caller (usually all 0) | 291 | * @par: parity data, must be initialized by caller (usually all 0) |
292 | * @invmsk: invert data mask (will be xored on data, not on parity!) | 292 | * @invmsk: invert data mask (will be xored on data, not on parity!) |
293 | * | 293 | * |
294 | * Each field in the data array contains up to symbol size bits of valid data. | 294 | * Each field in the data array contains up to symbol size bits of valid data. |
295 | */ | 295 | */ |
296 | int encode_rs16(struct rs_control *rs, uint16_t *data, int len, uint16_t *par, | 296 | int encode_rs16(struct rs_control *rs, uint16_t *data, int len, uint16_t *par, |
297 | uint16_t invmsk) | 297 | uint16_t invmsk) |
298 | { | 298 | { |
299 | #include "encode_rs.c" | 299 | #include "encode_rs.c" |
@@ -302,7 +302,7 @@ EXPORT_SYMBOL_GPL(encode_rs16); | |||
302 | #endif | 302 | #endif |
303 | 303 | ||
304 | #ifdef CONFIG_REED_SOLOMON_DEC16 | 304 | #ifdef CONFIG_REED_SOLOMON_DEC16 |
305 | /** | 305 | /** |
306 | * decode_rs16 - Decode codeword (16bit data width) | 306 | * decode_rs16 - Decode codeword (16bit data width) |
307 | * | 307 | * |
308 | * @rs: the rs control structure | 308 | * @rs: the rs control structure |
@@ -312,13 +312,13 @@ EXPORT_SYMBOL_GPL(encode_rs16); | |||
312 | * @s: syndrome data field (if NULL, syndrome is calculated) | 312 | * @s: syndrome data field (if NULL, syndrome is calculated) |
313 | * @no_eras: number of erasures | 313 | * @no_eras: number of erasures |
314 | * @eras_pos: position of erasures, can be NULL | 314 | * @eras_pos: position of erasures, can be NULL |
315 | * @invmsk: invert data mask (will be xored on data, not on parity!) | 315 | * @invmsk: invert data mask (will be xored on data, not on parity!) |
316 | * @corr: buffer to store correction bitmask on eras_pos | 316 | * @corr: buffer to store correction bitmask on eras_pos |
317 | * | 317 | * |
318 | * Each field in the data array contains up to symbol size bits of valid data. | 318 | * Each field in the data array contains up to symbol size bits of valid data. |
319 | */ | 319 | */ |
320 | int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, | 320 | int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, |
321 | uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, | 321 | uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, |
322 | uint16_t *corr) | 322 | uint16_t *corr) |
323 | { | 323 | { |
324 | #include "decode_rs.c" | 324 | #include "decode_rs.c" |