Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[LIB] reed_solomon: Clean up trailing white spaces

authored by

Thomas Gleixner and committed by
Thomas Gleixner
03ead842 182ec4ee

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