[PATCH 1/2] rslib: Minimum symbol size for a Reed-Solomon code is 2 bits not 1 bit

From: Cody Planteen
Date: Sun Mar 01 2020 - 23:27:49 EST


The minimum field for a R-S code is GF(2**2). A code in GF(2**1) would
only be 1 symbol long including data and parity which does not make sense.

Signed-off-by: Cody Planteen <planteen@xxxxxxxxx>
---
include/linux/rslib.h | 4 ++--
lib/reed_solomon/reed_solomon.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/rslib.h b/include/linux/rslib.h
index 5974cedd008c..3e48d4302908 100644
--- a/include/linux/rslib.h
+++ b/include/linux/rslib.h
@@ -57,7 +57,7 @@ struct rs_control {
uint16_t buffers[0];
};

-/* General purpose RS codec, 8-bit data width, symbol width 1-15 bit */
+/* General purpose RS codec, 8-bit data width, symbol width 2-15 bit */
#ifdef CONFIG_REED_SOLOMON_ENC8
int encode_rs8(struct rs_control *rs, uint8_t *data, int len, uint16_t *par,
uint16_t invmsk);
@@ -68,7 +68,7 @@ int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len,
uint16_t *corr);
#endif

-/* General purpose RS codec, 16-bit data width, symbol width 1-15 bit */
+/* General purpose RS codec, 16-bit data width, symbol width 2-15 bit */
#ifdef CONFIG_REED_SOLOMON_ENC16
int encode_rs16(struct rs_control *rs, uint16_t *data, int len, uint16_t *par,
uint16_t invmsk);
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
index bbc01bad3053..357723ac252f 100644
--- a/lib/reed_solomon/reed_solomon.c
+++ b/lib/reed_solomon/reed_solomon.c
@@ -219,7 +219,7 @@ static struct rs_control *init_rs_internal(int symsize, int gfpoly,
unsigned int bsize;

/* Sanity checks */
- if (symsize < 1)
+ if (symsize < 2)
return NULL;
if (fcr < 0 || fcr >= (1<<symsize))
return NULL;
--
2.20.1