mtd/lib/reed_solomon decode_rs.c,1.3,1.4 rslib.c,1.2,1.3

gleixner at infradead.org gleixner at infradead.org
Fri Oct 1 17:44:42 EDT 2004


Update of /home/cvs/mtd/lib/reed_solomon
In directory phoenix.infradead.org:/tmp/cvs-serv8221

Modified Files:
	decode_rs.c rslib.c 
Log Message:
update RS-library to provide error correction for weird bitordering etc. Fix correction of error locations outside the data buffer

Index: decode_rs.c
===================================================================
RCS file: /home/cvs/mtd/lib/reed_solomon/decode_rs.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- decode_rs.c	20 Sep 2004 13:58:31 -0000	1.3
+++ decode_rs.c	1 Oct 2004 21:44:39 -0000	1.4
@@ -214,7 +214,14 @@
 		/* Apply error to data */
 		if (num1 != 0 && loc[j] >= PAD) {
 			uint16_t cor = ALPHA_TO[MODNN (INDEX_OF[num1] + INDEX_OF[num2] + NN - INDEX_OF[den])];
-			data[loc[j] - PAD] ^= cor;
+			/* Store the error correction pattern, if a correction buffer is available */
+			if (corr) {
+				corr[j] = cor;
+			} else {
+				/* If a data buffer is given and the error is inside the message, correct it */
+				if (data && (loc[j] < (NN - NROOTS)))
+					data[loc[j] - PAD] ^= cor;
+			}
 		}
 	}
 

Index: rslib.c
===================================================================
RCS file: /home/cvs/mtd/lib/reed_solomon/rslib.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- rslib.c	19 Sep 2004 12:09:40 -0000	1.2
+++ rslib.c	1 Oct 2004 21:44:39 -0000	1.3
@@ -252,17 +252,18 @@
  *  @data:	data field of a given type
  *  @par:	received parity data field
  *  @len:	data length
- *  @s:		syndrome data field (if NULL, syndrome must be calculated)
+ *  @s:		syndrome data field (if NULL, syndrome is calculated)
  *  @no_eras:	number of erasures
  *  @eras_pos:	position of erasures, can be NULL
  *  @invmsk:	invert data mask (will be xored on data, not on parity!)
+ *  @corr:	buffer to store correction bitmask on eras_pos
  *
  *  The syndrome and parity uses a uint16_t data type to enable
  *  symbol size > 8. The calling code must take care of decoding of the
  *  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, uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk)
+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 *corr)
 {
 #include "decode_rs.c"
 }
@@ -290,15 +291,16 @@
  *  @data:	data field of a given type
  *  @par:	received parity data field
  *  @len:	data length
- *  @s:		syndrome data field (if NULL, syndrome must be calculated)
+ *  @s:		syndrome data field (if NULL, syndrome is calculated)
  *  @no_eras:	number of erasures
  *  @eras_pos:	position of erasures, can be NULL
  *  @invmsk:	invert data mask (will be xored on data, not on parity!) 
+ *  @corr:	buffer to store correction bitmask on eras_pos
  *
  *  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, uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk)
+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 *corr)
 {
 #include "decode_rs.c"
 }
@@ -329,10 +331,11 @@
  *  @data:	data field of a given type
  *  @par:	received parity data field
  *  @len:	data length
- *  @s:		syndrome data field (if NULL, syndrome must be calculated)
+ *  @s:		syndrome data field (if NULL, syndrome is calculated)
  *  @no_eras:	number of erasures
  *  @eras_pos:	position of erasures, can be NULL
  *  @invmsk:	invert data mask (will be xored on data, not on parity!)
+ *  @corr:	buffer to store correction bitmask on eras_pos
  *
  *  The syndrome and parity use a uint16_t data type due to the fact that
  *  we can't handle symbol size > 16 as the polynominal arrays would be to 
@@ -341,8 +344,8 @@
  *  before calling this code.
  *  Each field in the data array contains up to symbol size bits of data.
  */
-int decode_rs32 (struct rs_control *rs, uint32_t *data, uint16_t *par, 
-			int len, uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk)
+int decode_rs32 (struct rs_control *rs, uint32_t *data, uint16_t *par, int len,
+		 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, uint16_t *corr)
 {
 #include "decode_rs.c"
 }





More information about the linux-mtd-cvs mailing list