Lines Matching +full:error +full:- +full:correction

1 // SPDX-License-Identifier: GPL-2.0
13 struct rs_codec *rs = rsc->codec;
16 int nn = rs->nn;
17 int nroots = rs->nroots;
18 int fcr = rs->fcr;
19 int prim = rs->prim;
20 int iprim = rs->iprim;
21 uint16_t *alpha_to = rs->alpha_to;
22 uint16_t *index_of = rs->index_of;
26 uint16_t msk = (uint16_t) rs->nn;
32 uint16_t *lambda = rsc->buffers + RS_DECODE_LAMBDA * (nroots + 1);
33 uint16_t *syn = rsc->buffers + RS_DECODE_SYN * (nroots + 1);
34 uint16_t *b = rsc->buffers + RS_DECODE_B * (nroots + 1);
35 uint16_t *t = rsc->buffers + RS_DECODE_T * (nroots + 1);
36 uint16_t *omega = rsc->buffers + RS_DECODE_OMEGA * (nroots + 1);
37 uint16_t *root = rsc->buffers + RS_DECODE_ROOT * (nroots + 1);
38 uint16_t *reg = rsc->buffers + RS_DECODE_REG * (nroots + 1);
39 uint16_t *loc = rsc->buffers + RS_DECODE_LOC * (nroots + 1);
42 pad = nn - nroots - len;
43 BUG_ON(pad < 0 || pad >= nn - nroots);
112 prim * (nn - 1 - (eras_pos[0] + pad)))];
114 u = rs_modnn(rs, prim * (nn - 1 - (eras_pos[i] + pad)));
115 for (j = i + 1; j > 0; j--) {
116 tmp = index_of[lambda[j - 1]];
129 * Begin Berlekamp-Massey algorithm to determine error+erasure
135 /* Compute discrepancy at the r-th step in poly-form */
138 if ((lambda[i] != 0) && (s[r - i - 1] != nn)) {
142 s[r - i - 1])];
147 /* 2 lines below: B(x) <-- x*B(x) */
151 /* 7 lines below: T(x) <-- lambda(x)-discr_r*x*b(x) */
161 if (2 * el <= r + no_eras - 1) {
162 el = r + no_eras - el;
164 * 2 lines below: B(x) <-- inv(discr_r) *
170 - discr_r + nn);
173 /* 2 lines below: B(x) <-- x*B(x) */
191 * deg(lambda) is zero even though the syndrome is non-zero
192 * => uncorrectable error detected
194 return -EBADMSG;
197 /* Find roots of error+erasure locator polynomial by Chien search */
200 for (i = 1, k = iprim - 1; i <= nn; i++, k = rs_modnn(rs, k + iprim)) {
202 for (j = deg_lambda; j > 0; j--) {
212 /* Impossible error location. Uncorrectable error. */
213 return -EBADMSG;
216 /* store root (index-form) and error location number */
228 * error detected
230 return -EBADMSG;
236 deg_omega = deg_lambda - 1;
239 for (j = i; j >= 0; j--) {
240 if ((s[i - j] != nn) && (lambda[j] != nn))
242 alpha_to[rs_modnn(rs, s[i - j] + lambda[j])];
248 * Compute error values in poly-form. num1 = omega(inv(X(l))), num2 =
249 * inv(X(l))**(fcr-1) and den = lambda_pr(inv(X(l))) all in poly-form
250 * Note: we reuse the buffer for b to store the correction pattern
253 for (j = count - 1; j >= 0; j--) {
255 for (i = deg_omega; i >= 0; i--) {
267 num2 = alpha_to[rs_modnn(rs, root[j] * (fcr - 1) + nn)];
272 for (i = min(deg_lambda, nroots - 1) & ~1; i >= 0; i -= 2) {
281 nn - index_of[den])];
286 * We compute the syndrome of the 'error' and check that it matches
295 k = (fcr + i) * prim * (nn-loc[j]-1);
300 return -EBADMSG;
304 * Store the error correction pattern, if a
305 * correction buffer is available
312 eras_pos[j++] = loc[i] - pad;
316 /* Apply error to data and parity */
318 if (loc[i] < (nn - nroots))
319 data[loc[i] - pad] ^= b[i];
321 par[loc[i] - pad - len] ^= b[i];