From: Zhang Boyang <zhangboyang.id@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Ferdinand Blomqvist <ferdinand.blomqvist@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Kees Cook <keescook@chromium.org>,
Randy Dunlap <rdunlap@infradead.org>,
Zhang Boyang <zhangboyang.id@gmail.com>
Subject: [PATCH v3 2/6] rslib: Replace hard-coded 1 with alpha_to[0]
Date: Mon, 20 Jun 2022 14:20:11 +0800 [thread overview]
Message-ID: <20220620062015.15612-3-zhangboyang.id@gmail.com> (raw)
In-Reply-To: <20220620062015.15612-1-zhangboyang.id@gmail.com>
Currently the rslib allows customizing the finite field by the `gffunc'
parameter of init_rs_non_canonical(). However, there are several places
in rslib use hard-coded 1 instead of alpha_to[0], leading to errors if
gffunc(0) != 1. This patch fixes the problem. One of such `gffunc' might
be gffunc'(x) = swab16(gffunc(swab16(x))), as gffunc'(0) = swab16(1).
This special gffunc'(x) is useful when implementing RS coder for
16 bit foreign-endian symbols.
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
---
lib/reed_solomon/decode_rs.c | 4 ++--
lib/reed_solomon/reed_solomon.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c
index 805de84ae83d..6c1d53d1b702 100644
--- a/lib/reed_solomon/decode_rs.c
+++ b/lib/reed_solomon/decode_rs.c
@@ -104,7 +104,7 @@
decode:
memset(&lambda[1], 0, nroots * sizeof(lambda[0]));
- lambda[0] = 1;
+ lambda[0] = alpha_to[0];
if (no_eras > 0) {
/* Init lambda to be the erasure locator polynomial */
@@ -198,7 +198,7 @@
memcpy(®[1], &lambda[1], nroots * sizeof(reg[0]));
count = 0; /* Number of roots of lambda(x) */
for (i = 1, k = iprim - 1; i <= nn; i++, k = rs_modnn(rs, k + iprim)) {
- q = 1; /* lambda[0] is always 0 */
+ q = alpha_to[0]; /* lambda[0] is always 0 */
for (j = deg_lambda; j > 0; j--) {
if (reg[j] != nn) {
reg[j] = rs_modnn(rs, reg[j] + j);
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
index bbc01bad3053..bb4f44c8edba 100644
--- a/lib/reed_solomon/reed_solomon.c
+++ b/lib/reed_solomon/reed_solomon.c
@@ -131,9 +131,9 @@ static struct rs_codec *codec_init(int symsize, int gfpoly, int (*gffunc)(int),
rs->iprim = iprim / prim;
/* Form RS code generator polynomial from its roots */
- rs->genpoly[0] = 1;
+ rs->genpoly[0] = rs->alpha_to[0];
for (i = 0, root = fcr * prim; i < nroots; i++, root += prim) {
- rs->genpoly[i + 1] = 1;
+ rs->genpoly[i + 1] = rs->alpha_to[0];
/* Multiply rs->genpoly[] by @**(root + x) */
for (j = i; j > 0; j--) {
if (rs->genpoly[j] != 0) {
--
2.30.2
next prev parent reply other threads:[~2022-06-20 6:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 6:20 [PATCH v3] rslib: Several improvements Zhang Boyang
2022-06-20 6:20 ` [PATCH v3 1/6] rslib: Fix incorrect documentation of rs_modnn() Zhang Boyang
2022-06-20 6:20 ` Zhang Boyang [this message]
2022-06-20 6:20 ` [PATCH v3 3/6] rslib: Fix obvious documentation mistakes Zhang Boyang
2022-06-20 6:20 ` [PATCH v3 4/6] rslib: Fix kernel-doc style for rs_modnn() Zhang Boyang
2022-06-21 0:18 ` Randy Dunlap
2022-06-20 6:20 ` [PATCH v3 5/6] rslib: Improve the performance of encode_rs.c Zhang Boyang
2022-06-20 6:20 ` [PATCH v3 6/6] rslib: Fix integer overflow on large fcr or prim Zhang Boyang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220620062015.15612-3-zhangboyang.id@gmail.com \
--to=zhangboyang.id@gmail.com \
--cc=ferdinand.blomqvist@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®