Lines Matching refs:rs

74 	struct rs_codec *rs;  in codec_init()  local
76 rs = kzalloc(sizeof(*rs), gfp); in codec_init()
77 if (!rs) in codec_init()
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()
129 for(iprim = 1; (iprim % prim) != 0; iprim += rs->nn); 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()
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()
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()
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()
157 return rs; 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()
163 kfree(rs); in codec_init()
176 void free_rs(struct rs_control *rs) in free_rs() argument
180 if (!rs) in free_rs()
183 cd = rs->codec; in free_rs()
194 kfree(rs); in free_rs()
218 struct rs_control *rs; in init_rs_internal() local
237 rs = kzalloc(sizeof(*rs) + bsize, gfp); in init_rs_internal()
238 if (!rs) 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()
268 kfree(rs); in init_rs_internal()
269 rs = NULL; in init_rs_internal()
273 return rs; in init_rs_internal()