Lines Matching defs:rs

16  * for the given rs parameters. The control struct is unique per instance.
52 /* This list holds all currently allocated rs codec structures */
74 struct rs_codec *rs;
76 rs = kzalloc(sizeof(*rs), gfp);
77 if (!rs)
80 INIT_LIST_HEAD(&rs->list);
82 rs->mm = symsize;
83 rs->nn = (1 << symsize) - 1;
84 rs->fcr = fcr;
85 rs->prim = prim;
86 rs->nroots = nroots;
87 rs->gfpoly = gfpoly;
88 rs->gffunc = gffunc;
91 rs->alpha_to = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp);
92 if (rs->alpha_to == NULL)
95 rs->index_of = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp);
96 if (rs->index_of == NULL)
99 rs->genpoly = kmalloc_array(rs->nroots + 1, sizeof(uint16_t), gfp);
100 if(rs->genpoly == NULL)
104 rs->index_of[0] = rs->nn; /* log(zero) = -inf */
105 rs->alpha_to[rs->nn] = 0; /* alpha**-inf = 0 */
108 for (i = 0; i < rs->nn; i++) {
109 rs->index_of[sr] = i;
110 rs->alpha_to[i] = sr;
114 sr &= rs->nn;
118 for (i = 0; i < rs->nn; i++) {
119 rs->index_of[sr] = i;
120 rs->alpha_to[i] = sr;
125 if(sr != rs->alpha_to[0])
129 for(iprim = 1; (iprim % prim) != 0; iprim += rs->nn);
131 rs->iprim = iprim / prim;
134 rs->genpoly[0] = 1;
136 rs->genpoly[i + 1] = 1;
137 /* Multiply rs->genpoly[] by @**(root + x) */
139 if (rs->genpoly[j] != 0) {
140 rs->genpoly[j] = rs->genpoly[j -1] ^
141 rs->alpha_to[rs_modnn(rs,
142 rs->index_of[rs->genpoly[j]] + root)];
144 rs->genpoly[j] = rs->genpoly[j - 1];
146 /* rs->genpoly[0] can never be zero */
147 rs->genpoly[0] =
148 rs->alpha_to[rs_modnn(rs,
149 rs->index_of[rs->genpoly[0]] + root)];
151 /* convert rs->genpoly[] to index form for quicker encoding */
153 rs->genpoly[i] = rs->index_of[rs->genpoly[i]];
155 rs->users = 1;
156 list_add(&rs->list, &codec_list);
157 return rs;
160 kfree(rs->genpoly);
161 kfree(rs->index_of);
162 kfree(rs->alpha_to);
163 kfree(rs);
169 * free_rs - Free the rs control structure
170 * @rs: The control structure which is not longer used by the
173 * Free the control structure. If @rs is the last user of the associated
176 void free_rs(struct rs_control *rs)
180 if (!rs)
183 cd = rs->codec;
194 kfree(rs);
199 * init_rs_internal - Allocate rs control, find a matching codec or allocate a new one
207 * @fcr: the first consecutive root of the rs code generator polynomial
218 struct rs_control *rs;
237 rs = kzalloc(sizeof(*rs) + bsize, gfp);
238 if (!rs)
261 rs->codec = cd;
266 rs->codec = codec_init(symsize, gfpoly, gffunc, fcr, prim, nroots, gfp);
267 if (!rs->codec) {
268 kfree(rs);
269 rs = NULL;
273 return rs;
282 * @fcr: the first consecutive root of the rs code generator polynomial
296 * init_rs_non_canonical - Allocate rs control struct for fields with
302 * @fcr: the first consecutive root of the rs code generator polynomial
318 * @rsc: the rs control structure
339 * @rsc: the rs control structure
373 * @rsc: the rs control structure
392 * @rsc: the rs control structure