Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
03ead842
Commit
03ead842
authored
Nov 07, 2005
by
Thomas Gleixner
Committed by
Thomas Gleixner
Nov 07, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LIB] reed_solomon: Clean up trailing white spaces
parent
182ec4ee
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
72 deletions
+72
-72
include/linux/rslib.h
include/linux/rslib.h
+14
-14
lib/reed_solomon/Makefile
lib/reed_solomon/Makefile
+1
-1
lib/reed_solomon/decode_rs.c
lib/reed_solomon/decode_rs.c
+18
-18
lib/reed_solomon/encode_rs.c
lib/reed_solomon/encode_rs.c
+7
-7
lib/reed_solomon/reed_solomon.c
lib/reed_solomon/reed_solomon.c
+32
-32
No files found.
include/linux/rslib.h
View file @
03ead842
/*
/*
* include/linux/rslib.h
* include/linux/rslib.h
*
*
* Overview:
* Overview:
* Generic Reed Solomon encoder / decoder library
* Generic Reed Solomon encoder / decoder library
*
*
* Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
* Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
*
*
* RS code lifted from reed solomon library written by Phil Karn
* RS code lifted from reed solomon library written by Phil Karn
* Copyright 2002 Phil Karn, KA9Q
* Copyright 2002 Phil Karn, KA9Q
*
*
* $Id: rslib.h,v 1.
3 2004/10/05 22:08:2
2 gleixner Exp $
* $Id: rslib.h,v 1.
4 2005/11/07 11:14:5
2 gleixner Exp $
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* it under the terms of the GNU General Public License version 2 as
...
@@ -21,20 +21,20 @@
...
@@ -21,20 +21,20 @@
#include <linux/list.h>
#include <linux/list.h>
/**
/**
* struct rs_control - rs control structure
* struct rs_control - rs control structure
*
*
* @mm: Bits per symbol
* @mm: Bits per symbol
* @nn: Symbols per block (= (1<<mm)-1)
* @nn: Symbols per block (= (1<<mm)-1)
* @alpha_to: log lookup table
* @alpha_to: log lookup table
* @index_of: Antilog lookup table
* @index_of: Antilog lookup table
* @genpoly: Generator polynomial
* @genpoly: Generator polynomial
* @nroots: Number of generator roots = number of parity symbols
* @nroots: Number of generator roots = number of parity symbols
* @fcr: First consecutive root, index form
* @fcr: First consecutive root, index form
* @prim: Primitive element, index form
* @prim: Primitive element, index form
* @iprim: prim-th root of 1, index form
* @iprim: prim-th root of 1, index form
* @gfpoly: The primitive generator polynominal
* @gfpoly: The primitive generator polynominal
* @users: Users of this structure
* @users: Users of this structure
* @list: List entry for the rs control list
* @list: List entry for the rs control list
*/
*/
struct
rs_control
{
struct
rs_control
{
...
@@ -58,7 +58,7 @@ int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par,
...
@@ -58,7 +58,7 @@ int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par,
uint16_t
invmsk
);
uint16_t
invmsk
);
#endif
#endif
#ifdef CONFIG_REED_SOLOMON_DEC8
#ifdef CONFIG_REED_SOLOMON_DEC8
int
decode_rs8
(
struct
rs_control
*
rs
,
uint8_t
*
data
,
uint16_t
*
par
,
int
len
,
int
decode_rs8
(
struct
rs_control
*
rs
,
uint8_t
*
data
,
uint16_t
*
par
,
int
len
,
uint16_t
*
s
,
int
no_eras
,
int
*
eras_pos
,
uint16_t
invmsk
,
uint16_t
*
s
,
int
no_eras
,
int
*
eras_pos
,
uint16_t
invmsk
,
uint16_t
*
corr
);
uint16_t
*
corr
);
#endif
#endif
...
@@ -75,7 +75,7 @@ int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len,
...
@@ -75,7 +75,7 @@ int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len,
#endif
#endif
/* Create or get a matching rs control structure */
/* Create or get a matching rs control structure */
struct
rs_control
*
init_rs
(
int
symsize
,
int
gfpoly
,
int
fcr
,
int
prim
,
struct
rs_control
*
init_rs
(
int
symsize
,
int
gfpoly
,
int
fcr
,
int
prim
,
int
nroots
);
int
nroots
);
/* Release a rs control structure */
/* Release a rs control structure */
...
@@ -87,9 +87,9 @@ void free_rs(struct rs_control *rs);
...
@@ -87,9 +87,9 @@ void free_rs(struct rs_control *rs);
* @x: the value to reduce
* @x: the value to reduce
*
*
* where
* where
* rs->mm = number of bits per symbol
* rs->mm = number of bits per symbol
* rs->nn = (2^rs->mm) - 1
* rs->nn = (2^rs->mm) - 1
*
*
* Simple arithmetic modulo would return a wrong result for values
* Simple arithmetic modulo would return a wrong result for values
* >= 3 * rs->nn
* >= 3 * rs->nn
*/
*/
...
...
lib/reed_solomon/Makefile
View file @
03ead842
#
#
# This is a modified version of reed solomon lib,
# This is a modified version of reed solomon lib,
#
#
obj-$(CONFIG_REED_SOLOMON)
+=
reed_solomon.o
obj-$(CONFIG_REED_SOLOMON)
+=
reed_solomon.o
...
...
lib/reed_solomon/decode_rs.c
View file @
03ead842
/*
/*
* lib/reed_solomon/decode_rs.c
* lib/reed_solomon/decode_rs.c
*
*
* Overview:
* Overview:
* Generic Reed Solomon encoder / decoder library
* Generic Reed Solomon encoder / decoder library
*
*
* Copyright 2002, Phil Karn, KA9Q
* Copyright 2002, Phil Karn, KA9Q
* May be used under the terms of the GNU General Public License (GPL)
* May be used under the terms of the GNU General Public License (GPL)
*
*
* Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de)
* Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de)
*
*
* $Id: decode_rs.c,v 1.
6 2004/10/22 15:41:47
gleixner Exp $
* $Id: decode_rs.c,v 1.
7 2005/11/07 11:14:59
gleixner Exp $
*
*
*/
*/
/* Generic data width independent code which is included by the
/* Generic data width independent code which is included by the
* wrappers.
* wrappers.
*/
*/
{
{
int
deg_lambda
,
el
,
deg_omega
;
int
deg_lambda
,
el
,
deg_omega
;
int
i
,
j
,
r
,
k
,
pad
;
int
i
,
j
,
r
,
k
,
pad
;
int
nn
=
rs
->
nn
;
int
nn
=
rs
->
nn
;
...
@@ -41,9 +41,9 @@
...
@@ -41,9 +41,9 @@
pad
=
nn
-
nroots
-
len
;
pad
=
nn
-
nroots
-
len
;
if
(
pad
<
0
||
pad
>=
nn
)
if
(
pad
<
0
||
pad
>=
nn
)
return
-
ERANGE
;
return
-
ERANGE
;
/* Does the caller provide the syndrome ? */
/* Does the caller provide the syndrome ? */
if
(
s
!=
NULL
)
if
(
s
!=
NULL
)
goto
decode
;
goto
decode
;
/* form the syndromes; i.e., evaluate data(x) at roots of
/* form the syndromes; i.e., evaluate data(x) at roots of
...
@@ -54,11 +54,11 @@
...
@@ -54,11 +54,11 @@
for
(
j
=
1
;
j
<
len
;
j
++
)
{
for
(
j
=
1
;
j
<
len
;
j
++
)
{
for
(
i
=
0
;
i
<
nroots
;
i
++
)
{
for
(
i
=
0
;
i
<
nroots
;
i
++
)
{
if
(
syn
[
i
]
==
0
)
{
if
(
syn
[
i
]
==
0
)
{
syn
[
i
]
=
(((
uint16_t
)
data
[
j
])
^
syn
[
i
]
=
(((
uint16_t
)
data
[
j
])
^
invmsk
)
&
msk
;
invmsk
)
&
msk
;
}
else
{
}
else
{
syn
[
i
]
=
((((
uint16_t
)
data
[
j
])
^
syn
[
i
]
=
((((
uint16_t
)
data
[
j
])
^
invmsk
)
&
msk
)
^
invmsk
)
&
msk
)
^
alpha_to
[
rs_modnn
(
rs
,
index_of
[
syn
[
i
]]
+
alpha_to
[
rs_modnn
(
rs
,
index_of
[
syn
[
i
]]
+
(
fcr
+
i
)
*
prim
)];
(
fcr
+
i
)
*
prim
)];
}
}
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
if
(
syn
[
i
]
==
0
)
{
if
(
syn
[
i
]
==
0
)
{
syn
[
i
]
=
((
uint16_t
)
par
[
j
])
&
msk
;
syn
[
i
]
=
((
uint16_t
)
par
[
j
])
&
msk
;
}
else
{
}
else
{
syn
[
i
]
=
(((
uint16_t
)
par
[
j
])
&
msk
)
^
syn
[
i
]
=
(((
uint16_t
)
par
[
j
])
&
msk
)
^
alpha_to
[
rs_modnn
(
rs
,
index_of
[
syn
[
i
]]
+
alpha_to
[
rs_modnn
(
rs
,
index_of
[
syn
[
i
]]
+
(
fcr
+
i
)
*
prim
)];
(
fcr
+
i
)
*
prim
)];
}
}
...
@@ -99,14 +99,14 @@
...
@@ -99,14 +99,14 @@
if
(
no_eras
>
0
)
{
if
(
no_eras
>
0
)
{
/* Init lambda to be the erasure locator polynomial */
/* Init lambda to be the erasure locator polynomial */
lambda
[
1
]
=
alpha_to
[
rs_modnn
(
rs
,
lambda
[
1
]
=
alpha_to
[
rs_modnn
(
rs
,
prim
*
(
nn
-
1
-
eras_pos
[
0
]))];
prim
*
(
nn
-
1
-
eras_pos
[
0
]))];
for
(
i
=
1
;
i
<
no_eras
;
i
++
)
{
for
(
i
=
1
;
i
<
no_eras
;
i
++
)
{
u
=
rs_modnn
(
rs
,
prim
*
(
nn
-
1
-
eras_pos
[
i
]));
u
=
rs_modnn
(
rs
,
prim
*
(
nn
-
1
-
eras_pos
[
i
]));
for
(
j
=
i
+
1
;
j
>
0
;
j
--
)
{
for
(
j
=
i
+
1
;
j
>
0
;
j
--
)
{
tmp
=
index_of
[
lambda
[
j
-
1
]];
tmp
=
index_of
[
lambda
[
j
-
1
]];
if
(
tmp
!=
nn
)
{
if
(
tmp
!=
nn
)
{
lambda
[
j
]
^=
lambda
[
j
]
^=
alpha_to
[
rs_modnn
(
rs
,
u
+
tmp
)];
alpha_to
[
rs_modnn
(
rs
,
u
+
tmp
)];
}
}
}
}
...
@@ -127,8 +127,8 @@
...
@@ -127,8 +127,8 @@
discr_r
=
0
;
discr_r
=
0
;
for
(
i
=
0
;
i
<
r
;
i
++
)
{
for
(
i
=
0
;
i
<
r
;
i
++
)
{
if
((
lambda
[
i
]
!=
0
)
&&
(
s
[
r
-
i
-
1
]
!=
nn
))
{
if
((
lambda
[
i
]
!=
0
)
&&
(
s
[
r
-
i
-
1
]
!=
nn
))
{
discr_r
^=
discr_r
^=
alpha_to
[
rs_modnn
(
rs
,
alpha_to
[
rs_modnn
(
rs
,
index_of
[
lambda
[
i
]]
+
index_of
[
lambda
[
i
]]
+
s
[
r
-
i
-
1
])];
s
[
r
-
i
-
1
])];
}
}
...
@@ -143,7 +143,7 @@
...
@@ -143,7 +143,7 @@
t
[
0
]
=
lambda
[
0
];
t
[
0
]
=
lambda
[
0
];
for
(
i
=
0
;
i
<
nroots
;
i
++
)
{
for
(
i
=
0
;
i
<
nroots
;
i
++
)
{
if
(
b
[
i
]
!=
nn
)
{
if
(
b
[
i
]
!=
nn
)
{
t
[
i
+
1
]
=
lambda
[
i
+
1
]
^
t
[
i
+
1
]
=
lambda
[
i
+
1
]
^
alpha_to
[
rs_modnn
(
rs
,
discr_r
+
alpha_to
[
rs_modnn
(
rs
,
discr_r
+
b
[
i
])];
b
[
i
])];
}
else
}
else
...
@@ -229,7 +229,7 @@
...
@@ -229,7 +229,7 @@
num1
=
0
;
num1
=
0
;
for
(
i
=
deg_omega
;
i
>=
0
;
i
--
)
{
for
(
i
=
deg_omega
;
i
>=
0
;
i
--
)
{
if
(
omega
[
i
]
!=
nn
)
if
(
omega
[
i
]
!=
nn
)
num1
^=
alpha_to
[
rs_modnn
(
rs
,
omega
[
i
]
+
num1
^=
alpha_to
[
rs_modnn
(
rs
,
omega
[
i
]
+
i
*
root
[
j
])];
i
*
root
[
j
])];
}
}
num2
=
alpha_to
[
rs_modnn
(
rs
,
root
[
j
]
*
(
fcr
-
1
)
+
nn
)];
num2
=
alpha_to
[
rs_modnn
(
rs
,
root
[
j
]
*
(
fcr
-
1
)
+
nn
)];
...
@@ -239,13 +239,13 @@
...
@@ -239,13 +239,13 @@
* lambda_pr of lambda[i] */
* lambda_pr of lambda[i] */
for
(
i
=
min
(
deg_lambda
,
nroots
-
1
)
&
~
1
;
i
>=
0
;
i
-=
2
)
{
for
(
i
=
min
(
deg_lambda
,
nroots
-
1
)
&
~
1
;
i
>=
0
;
i
-=
2
)
{
if
(
lambda
[
i
+
1
]
!=
nn
)
{
if
(
lambda
[
i
+
1
]
!=
nn
)
{
den
^=
alpha_to
[
rs_modnn
(
rs
,
lambda
[
i
+
1
]
+
den
^=
alpha_to
[
rs_modnn
(
rs
,
lambda
[
i
+
1
]
+
i
*
root
[
j
])];
i
*
root
[
j
])];
}
}
}
}
/* Apply error to data */
/* Apply error to data */
if
(
num1
!=
0
&&
loc
[
j
]
>=
pad
)
{
if
(
num1
!=
0
&&
loc
[
j
]
>=
pad
)
{
uint16_t
cor
=
alpha_to
[
rs_modnn
(
rs
,
index_of
[
num1
]
+
uint16_t
cor
=
alpha_to
[
rs_modnn
(
rs
,
index_of
[
num1
]
+
index_of
[
num2
]
+
index_of
[
num2
]
+
nn
-
index_of
[
den
])];
nn
-
index_of
[
den
])];
/* Store the error correction pattern, if a
/* Store the error correction pattern, if a
...
...
lib/reed_solomon/encode_rs.c
View file @
03ead842
/*
/*
* lib/reed_solomon/encode_rs.c
* lib/reed_solomon/encode_rs.c
*
*
* Overview:
* Overview:
* Generic Reed Solomon encoder / decoder library
* Generic Reed Solomon encoder / decoder library
*
*
* Copyright 2002, Phil Karn, KA9Q
* Copyright 2002, Phil Karn, KA9Q
* May be used under the terms of the GNU General Public License (GPL)
* May be used under the terms of the GNU General Public License (GPL)
*
*
* Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de)
* Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de)
*
*
* $Id: encode_rs.c,v 1.
4 2004/10/22 15:41:47
gleixner Exp $
* $Id: encode_rs.c,v 1.
5 2005/11/07 11:14:59
gleixner Exp $
*
*
*/
*/
/* Generic data width independent code which is included by the
/* Generic data width independent code which is included by the
* wrappers.
* wrappers.
* int encode_rsX (struct rs_control *rs, uintX_t *data, int len, uintY_t *par)
* int encode_rsX (struct rs_control *rs, uintX_t *data, int len, uintY_t *par)
*/
*/
...
@@ -35,16 +35,16 @@
...
@@ -35,16 +35,16 @@
for
(
i
=
0
;
i
<
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
fb
=
index_of
[((((
uint16_t
)
data
[
i
])
^
invmsk
)
&
msk
)
^
par
[
0
]];
fb
=
index_of
[((((
uint16_t
)
data
[
i
])
^
invmsk
)
&
msk
)
^
par
[
0
]];
/* feedback term is non-zero */
/* feedback term is non-zero */
if
(
fb
!=
nn
)
{
if
(
fb
!=
nn
)
{
for
(
j
=
1
;
j
<
nroots
;
j
++
)
{
for
(
j
=
1
;
j
<
nroots
;
j
++
)
{
par
[
j
]
^=
alpha_to
[
rs_modnn
(
rs
,
fb
+
par
[
j
]
^=
alpha_to
[
rs_modnn
(
rs
,
fb
+
genpoly
[
nroots
-
j
])];
genpoly
[
nroots
-
j
])];
}
}
}
}
/* Shift */
/* Shift */
memmove
(
&
par
[
0
],
&
par
[
1
],
sizeof
(
uint16_t
)
*
(
nroots
-
1
));
memmove
(
&
par
[
0
],
&
par
[
1
],
sizeof
(
uint16_t
)
*
(
nroots
-
1
));
if
(
fb
!=
nn
)
{
if
(
fb
!=
nn
)
{
par
[
nroots
-
1
]
=
alpha_to
[
rs_modnn
(
rs
,
par
[
nroots
-
1
]
=
alpha_to
[
rs_modnn
(
rs
,
fb
+
genpoly
[
0
])];
fb
+
genpoly
[
0
])];
}
else
{
}
else
{
par
[
nroots
-
1
]
=
0
;
par
[
nroots
-
1
]
=
0
;
...
...
lib/reed_solomon/reed_solomon.c
View file @
03ead842
/*
/*
* lib/reed_solomon/rslib.c
* lib/reed_solomon/rslib.c
*
*
* Overview:
* Overview:
* Generic Reed Solomon encoder / decoder library
* Generic Reed Solomon encoder / decoder library
*
*
* Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
* Copyright (C) 2004 Thomas Gleixner (tglx@linutronix.de)
*
*
* Reed Solomon code lifted from reed solomon library written by Phil Karn
* Reed Solomon code lifted from reed solomon library written by Phil Karn
* Copyright 2002 Phil Karn, KA9Q
* Copyright 2002 Phil Karn, KA9Q
*
*
* $Id: rslib.c,v 1.
5 2004/10/22 15:41:47
gleixner Exp $
* $Id: rslib.c,v 1.
7 2005/11/07 11:14:59
gleixner Exp $
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
* published by the Free Software Foundation.
*
*
* Description:
* Description:
*
*
* The generic Reed Solomon library provides runtime configurable
* The generic Reed Solomon library provides runtime configurable
* encoding / decoding of RS codes.
* encoding / decoding of RS codes.
* Each user must call init_rs to get a pointer to a rs_control
* Each user must call init_rs to get a pointer to a rs_control
...
@@ -25,11 +25,11 @@
...
@@ -25,11 +25,11 @@
* If a structure is generated then the polynomial arrays for
* If a structure is generated then the polynomial arrays for
* fast encoding / decoding are built. This can take some time so
* fast encoding / decoding are built. This can take some time so
* make sure not to call this function from a time critical path.
* make sure not to call this function from a time critical path.
* Usually a module / driver should initialize the necessary
* Usually a module / driver should initialize the necessary
* rs_control structure on module / driver init and release it
* rs_control structure on module / driver init and release it
* on exit.
* on exit.
* The encoding puts the calculated syndrome into a given syndrome
* The encoding puts the calculated syndrome into a given syndrome
* buffer.
* buffer.
* The decoding is a two step process. The first step calculates
* The decoding is a two step process. The first step calculates
* the syndrome over the received (data + syndrome) and calls the
* the syndrome over the received (data + syndrome) and calls the
* second stage, which does the decoding / error correction itself.
* second stage, which does the decoding / error correction itself.
...
@@ -51,7 +51,7 @@ static LIST_HEAD (rslist);
...
@@ -51,7 +51,7 @@ static LIST_HEAD (rslist);
/* Protection for the list */
/* Protection for the list */
static
DECLARE_MUTEX
(
rslistlock
);
static
DECLARE_MUTEX
(
rslistlock
);
/**
/**
* rs_init - Initialize a Reed-Solomon codec
* rs_init - Initialize a Reed-Solomon codec
*
*
* @symsize: symbol size, bits (1-8)
* @symsize: symbol size, bits (1-8)
...
@@ -63,7 +63,7 @@ static DECLARE_MUTEX(rslistlock);
...
@@ -63,7 +63,7 @@ static DECLARE_MUTEX(rslistlock);
* Allocate a control structure and the polynom arrays for faster
* Allocate a control structure and the polynom arrays for faster
* en/decoding. Fill the arrays according to the given parameters
* en/decoding. Fill the arrays according to the given parameters
*/
*/
static
struct
rs_control
*
rs_init
(
int
symsize
,
int
gfpoly
,
int
fcr
,
static
struct
rs_control
*
rs_init
(
int
symsize
,
int
gfpoly
,
int
fcr
,
int
prim
,
int
nroots
)
int
prim
,
int
nroots
)
{
{
struct
rs_control
*
rs
;
struct
rs_control
*
rs
;
...
@@ -124,15 +124,15 @@ static struct rs_control *rs_init(int symsize, int gfpoly, int fcr,
...
@@ -124,15 +124,15 @@ static struct rs_control *rs_init(int symsize, int gfpoly, int fcr,
/* Multiply rs->genpoly[] by @**(root + x) */
/* Multiply rs->genpoly[] by @**(root + x) */
for
(
j
=
i
;
j
>
0
;
j
--
)
{
for
(
j
=
i
;
j
>
0
;
j
--
)
{
if
(
rs
->
genpoly
[
j
]
!=
0
)
{
if
(
rs
->
genpoly
[
j
]
!=
0
)
{
rs
->
genpoly
[
j
]
=
rs
->
genpoly
[
j
-
1
]
^
rs
->
genpoly
[
j
]
=
rs
->
genpoly
[
j
-
1
]
^
rs
->
alpha_to
[
rs_modnn
(
rs
,
rs
->
alpha_to
[
rs_modnn
(
rs
,
rs
->
index_of
[
rs
->
genpoly
[
j
]]
+
root
)];
rs
->
index_of
[
rs
->
genpoly
[
j
]]
+
root
)];
}
else
}
else
rs
->
genpoly
[
j
]
=
rs
->
genpoly
[
j
-
1
];
rs
->
genpoly
[
j
]
=
rs
->
genpoly
[
j
-
1
];
}
}
/* rs->genpoly[0] can never be zero */
/* rs->genpoly[0] can never be zero */
rs
->
genpoly
[
0
]
=
rs
->
genpoly
[
0
]
=
rs
->
alpha_to
[
rs_modnn
(
rs
,
rs
->
alpha_to
[
rs_modnn
(
rs
,
rs
->
index_of
[
rs
->
genpoly
[
0
]]
+
root
)];
rs
->
index_of
[
rs
->
genpoly
[
0
]]
+
root
)];
}
}
/* convert rs->genpoly[] to index form for quicker encoding */
/* convert rs->genpoly[] to index form for quicker encoding */
...
@@ -153,7 +153,7 @@ static struct rs_control *rs_init(int symsize, int gfpoly, int fcr,
...
@@ -153,7 +153,7 @@ static struct rs_control *rs_init(int symsize, int gfpoly, int fcr,
}
}
/**
/**
* free_rs - Free the rs control structure, if its not longer used
* free_rs - Free the rs control structure, if its not longer used
*
*
* @rs: the control structure which is not longer used by the
* @rs: the control structure which is not longer used by the
...
@@ -173,19 +173,19 @@ void free_rs(struct rs_control *rs)
...
@@ -173,19 +173,19 @@ void free_rs(struct rs_control *rs)
up
(
&
rslistlock
);
up
(
&
rslistlock
);
}
}
/**
/**
* init_rs - Find a matching or allocate a new rs control structure
* init_rs - Find a matching or allocate a new rs control structure
*
*
* @symsize: the symbol size (number of bits)
* @symsize: the symbol size (number of bits)
* @gfpoly: the extended Galois field generator polynomial coefficients,
* @gfpoly: the extended Galois field generator polynomial coefficients,
* with the 0th coefficient in the low order bit. The polynomial
* with the 0th coefficient in the low order bit. The polynomial
* must be primitive;
* must be primitive;
* @fcr: the first consecutive root of the rs code generator polynomial
* @fcr: the first consecutive root of the rs code generator polynomial
* in index form
* in index form
* @prim: primitive element to generate polynomial roots
* @prim: primitive element to generate polynomial roots
* @nroots: RS code generator polynomial degree (number of roots)
* @nroots: RS code generator polynomial degree (number of roots)
*/
*/
struct
rs_control
*
init_rs
(
int
symsize
,
int
gfpoly
,
int
fcr
,
int
prim
,
struct
rs_control
*
init_rs
(
int
symsize
,
int
gfpoly
,
int
fcr
,
int
prim
,
int
nroots
)
int
nroots
)
{
{
struct
list_head
*
tmp
;
struct
list_head
*
tmp
;
...
@@ -198,9 +198,9 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
...
@@ -198,9 +198,9 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
return
NULL
;
return
NULL
;
if
(
prim
<=
0
||
prim
>=
(
1
<<
symsize
))
if
(
prim
<=
0
||
prim
>=
(
1
<<
symsize
))
return
NULL
;
return
NULL
;
if
(
nroots
<
0
||
nroots
>=
(
1
<<
symsize
)
||
nroots
>
8
)
if
(
nroots
<
0
||
nroots
>=
(
1
<<
symsize
))
return
NULL
;
return
NULL
;
down
(
&
rslistlock
);
down
(
&
rslistlock
);
/* Walk through the list and look for a matching entry */
/* Walk through the list and look for a matching entry */
...
@@ -211,9 +211,9 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
...
@@ -211,9 +211,9 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
if
(
gfpoly
!=
rs
->
gfpoly
)
if
(
gfpoly
!=
rs
->
gfpoly
)
continue
;
continue
;
if
(
fcr
!=
rs
->
fcr
)
if
(
fcr
!=
rs
->
fcr
)
continue
;
continue
;
if
(
prim
!=
rs
->
prim
)
if
(
prim
!=
rs
->
prim
)
continue
;
continue
;
if
(
nroots
!=
rs
->
nroots
)
if
(
nroots
!=
rs
->
nroots
)
continue
;
continue
;
/* We have a matching one already */
/* We have a matching one already */
...
@@ -227,18 +227,18 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
...
@@ -227,18 +227,18 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
rs
->
users
=
1
;
rs
->
users
=
1
;
list_add
(
&
rs
->
list
,
&
rslist
);
list_add
(
&
rs
->
list
,
&
rslist
);
}
}
out:
out:
up
(
&
rslistlock
);
up
(
&
rslistlock
);
return
rs
;
return
rs
;
}
}
#ifdef CONFIG_REED_SOLOMON_ENC8
#ifdef CONFIG_REED_SOLOMON_ENC8
/**
/**
* encode_rs8 - Calculate the parity for data values (8bit data width)
* encode_rs8 - Calculate the parity for data values (8bit data width)
*
*
* @rs: the rs control structure
* @rs: the rs control structure
* @data: data field of a given type
* @data: data field of a given type
* @len: data length
* @len: data length
* @par: parity data, must be initialized by caller (usually all 0)
* @par: parity data, must be initialized by caller (usually all 0)
* @invmsk: invert data mask (will be xored on data)
* @invmsk: invert data mask (will be xored on data)
*
*
...
@@ -246,7 +246,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
...
@@ -246,7 +246,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
* symbol size > 8. The calling code must take care of encoding of the
* symbol size > 8. The calling code must take care of encoding of the
* syndrome result for storage itself.
* syndrome result for storage itself.
*/
*/
int
encode_rs8
(
struct
rs_control
*
rs
,
uint8_t
*
data
,
int
len
,
uint16_t
*
par
,
int
encode_rs8
(
struct
rs_control
*
rs
,
uint8_t
*
data
,
int
len
,
uint16_t
*
par
,
uint16_t
invmsk
)
uint16_t
invmsk
)
{
{
#include "encode_rs.c"
#include "encode_rs.c"
...
@@ -255,7 +255,7 @@ EXPORT_SYMBOL_GPL(encode_rs8);
...
@@ -255,7 +255,7 @@ EXPORT_SYMBOL_GPL(encode_rs8);
#endif
#endif
#ifdef CONFIG_REED_SOLOMON_DEC8
#ifdef CONFIG_REED_SOLOMON_DEC8
/**
/**
* decode_rs8 - Decode codeword (8bit data width)
* decode_rs8 - Decode codeword (8bit data width)
*
*
* @rs: the rs control structure
* @rs: the rs control structure
...
@@ -273,7 +273,7 @@ EXPORT_SYMBOL_GPL(encode_rs8);
...
@@ -273,7 +273,7 @@ EXPORT_SYMBOL_GPL(encode_rs8);
* syndrome result and the received parity before calling this code.
* syndrome result and the received parity before calling this code.
*/
*/
int
decode_rs8
(
struct
rs_control
*
rs
,
uint8_t
*
data
,
uint16_t
*
par
,
int
len
,
int
decode_rs8
(
struct
rs_control
*
rs
,
uint8_t
*
data
,
uint16_t
*
par
,
int
len
,
uint16_t
*
s
,
int
no_eras
,
int
*
eras_pos
,
uint16_t
invmsk
,
uint16_t
*
s
,
int
no_eras
,
int
*
eras_pos
,
uint16_t
invmsk
,
uint16_t
*
corr
)
uint16_t
*
corr
)
{
{
#include "decode_rs.c"
#include "decode_rs.c"
...
@@ -287,13 +287,13 @@ EXPORT_SYMBOL_GPL(decode_rs8);
...
@@ -287,13 +287,13 @@ EXPORT_SYMBOL_GPL(decode_rs8);
*
*
* @rs: the rs control structure
* @rs: the rs control structure
* @data: data field of a given type
* @data: data field of a given type
* @len: data length
* @len: data length
* @par: parity data, must be initialized by caller (usually all 0)
* @par: parity data, must be initialized by caller (usually all 0)
* @invmsk: invert data mask (will be xored on data, not on parity!)
* @invmsk: invert data mask (will be xored on data, not on parity!)
*
*
* Each field in the data array contains up to symbol size bits of valid data.
* Each field in the data array contains up to symbol size bits of valid data.
*/
*/
int
encode_rs16
(
struct
rs_control
*
rs
,
uint16_t
*
data
,
int
len
,
uint16_t
*
par
,
int
encode_rs16
(
struct
rs_control
*
rs
,
uint16_t
*
data
,
int
len
,
uint16_t
*
par
,
uint16_t
invmsk
)
uint16_t
invmsk
)
{
{
#include "encode_rs.c"
#include "encode_rs.c"
...
@@ -302,7 +302,7 @@ EXPORT_SYMBOL_GPL(encode_rs16);
...
@@ -302,7 +302,7 @@ EXPORT_SYMBOL_GPL(encode_rs16);
#endif
#endif
#ifdef CONFIG_REED_SOLOMON_DEC16
#ifdef CONFIG_REED_SOLOMON_DEC16
/**
/**
* decode_rs16 - Decode codeword (16bit data width)
* decode_rs16 - Decode codeword (16bit data width)
*
*
* @rs: the rs control structure
* @rs: the rs control structure
...
@@ -312,13 +312,13 @@ EXPORT_SYMBOL_GPL(encode_rs16);
...
@@ -312,13 +312,13 @@ EXPORT_SYMBOL_GPL(encode_rs16);
* @s: syndrome data field (if NULL, syndrome is calculated)
* @s: syndrome data field (if NULL, syndrome is calculated)
* @no_eras: number of erasures
* @no_eras: number of erasures
* @eras_pos: position of erasures, can be NULL
* @eras_pos: position of erasures, can be NULL
* @invmsk: invert data mask (will be xored on data, not on parity!)
* @invmsk: invert data mask (will be xored on data, not on parity!)
* @corr: buffer to store correction bitmask on eras_pos
* @corr: buffer to store correction bitmask on eras_pos
*
*
* Each field in the data array contains up to symbol size bits of valid data.
* Each field in the data array contains up to symbol size bits of valid data.
*/
*/
int
decode_rs16
(
struct
rs_control
*
rs
,
uint16_t
*
data
,
uint16_t
*
par
,
int
len
,
int
decode_rs16
(
struct
rs_control
*
rs
,
uint16_t
*
data
,
uint16_t
*
par
,
int
len
,
uint16_t
*
s
,
int
no_eras
,
int
*
eras_pos
,
uint16_t
invmsk
,
uint16_t
*
s
,
int
no_eras
,
int
*
eras_pos
,
uint16_t
invmsk
,
uint16_t
*
corr
)
uint16_t
*
corr
)
{
{
#include "decode_rs.c"
#include "decode_rs.c"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment