Lines Matching +full:de +full:- +full:serialized

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
58 * codec_init - Initialize a Reed-Solomon codec
59 * @symsize: symbol size, bits (1-8)
80 INIT_LIST_HEAD(&rs->list); in codec_init()
82 rs->mm = symsize; in codec_init()
83 rs->nn = (1 << symsize) - 1; in codec_init()
84 rs->fcr = fcr; in codec_init()
85 rs->prim = prim; in codec_init()
86 rs->nroots = nroots; in codec_init()
87 rs->gfpoly = gfpoly; in codec_init()
88 rs->gffunc = gffunc; in codec_init()
91 rs->alpha_to = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp); in codec_init()
92 if (rs->alpha_to == NULL) in codec_init()
95 rs->index_of = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp); in codec_init()
96 if (rs->index_of == NULL) in codec_init()
99 rs->genpoly = kmalloc_array(rs->nroots + 1, sizeof(uint16_t), gfp); in codec_init()
100 if(rs->genpoly == NULL) in codec_init()
104 rs->index_of[0] = rs->nn; /* log(zero) = -inf */ in codec_init()
105 rs->alpha_to[rs->nn] = 0; /* alpha**-inf = 0 */ in codec_init()
108 for (i = 0; i < rs->nn; i++) { in codec_init()
109 rs->index_of[sr] = i; in codec_init()
110 rs->alpha_to[i] = sr; in codec_init()
114 sr &= rs->nn; in codec_init()
118 for (i = 0; i < rs->nn; i++) { in codec_init()
119 rs->index_of[sr] = i; in codec_init()
120 rs->alpha_to[i] = sr; in codec_init()
125 if(sr != rs->alpha_to[0]) in codec_init()
128 /* Find prim-th root of 1, used in decoding */ in codec_init()
129 for(iprim = 1; (iprim % prim) != 0; iprim += rs->nn); in codec_init()
130 /* prim-th root of 1, index form */ in codec_init()
131 rs->iprim = iprim / prim; in codec_init()
134 rs->genpoly[0] = 1; in codec_init()
136 rs->genpoly[i + 1] = 1; in codec_init()
137 /* Multiply rs->genpoly[] by @**(root + x) */ in codec_init()
138 for (j = i; j > 0; j--) { in codec_init()
139 if (rs->genpoly[j] != 0) { in codec_init()
140 rs->genpoly[j] = rs->genpoly[j -1] ^ in codec_init()
141 rs->alpha_to[rs_modnn(rs, in codec_init()
142 rs->index_of[rs->genpoly[j]] + root)]; in codec_init()
144 rs->genpoly[j] = rs->genpoly[j - 1]; in codec_init()
146 /* rs->genpoly[0] can never be zero */ in codec_init()
147 rs->genpoly[0] = in codec_init()
148 rs->alpha_to[rs_modnn(rs, in codec_init()
149 rs->index_of[rs->genpoly[0]] + root)]; in codec_init()
151 /* convert rs->genpoly[] to index form for quicker encoding */ in codec_init()
153 rs->genpoly[i] = rs->index_of[rs->genpoly[i]]; in codec_init()
155 rs->users = 1; in codec_init()
156 list_add(&rs->list, &codec_list); in codec_init()
160 kfree(rs->genpoly); in codec_init()
161 kfree(rs->index_of); in codec_init()
162 kfree(rs->alpha_to); in codec_init()
169 * free_rs - Free the rs control structure
183 cd = rs->codec; in free_rs()
185 cd->users--; in free_rs()
186 if(!cd->users) { in free_rs()
187 list_del(&cd->list); in free_rs()
188 kfree(cd->alpha_to); in free_rs()
189 kfree(cd->index_of); in free_rs()
190 kfree(cd->genpoly); in free_rs()
199 * init_rs_internal - Allocate rs control, find a matching codec or allocate a new one
247 if (symsize != cd->mm) in init_rs_internal()
249 if (gfpoly != cd->gfpoly) in init_rs_internal()
251 if (gffunc != cd->gffunc) in init_rs_internal()
253 if (fcr != cd->fcr) in init_rs_internal()
255 if (prim != cd->prim) in init_rs_internal()
257 if (nroots != cd->nroots) in init_rs_internal()
260 cd->users++; in init_rs_internal()
261 rs->codec = cd; in init_rs_internal()
266 rs->codec = codec_init(symsize, gfpoly, gffunc, fcr, prim, nroots, gfp); in init_rs_internal()
267 if (!rs->codec) { in init_rs_internal()
277 * init_rs_gfp - Create a RS control struct and initialize it
296 * init_rs_non_canonical - Allocate rs control struct for fields with
297 * non-canonical representation
317 * encode_rs8 - Calculate the parity for data values (8bit data width)
338 * decode_rs8 - Decode codeword (8bit data width)
356 * serialized.
358 * Returns the number of corrected symbols or -EBADMSG for uncorrectable
372 * encode_rs16 - Calculate the parity for data values (16bit data width)
391 * decode_rs16 - Decode codeword (16bit data width)
407 * serialized.
409 * Returns the number of corrected symbols or -EBADMSG for uncorrectable