VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   35 Branches   59 Tags
dc8f923eaee24 (Thomas Gleixner 2018-04-22 18:23:50 +0200  1) // SPDX-License-Identifier: GPL-2.0
03ead8427d65f (Thomas Gleixner 2005-11-07 11:15:37 +0000  2) /*
3413e1891d443 (Thomas Gleixner 2018-04-22 18:23:49 +0200  3)  * Generic Reed Solomon encoder / decoder library
03ead8427d65f (Thomas Gleixner 2005-11-07 11:15:37 +0000  4)  *
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700  5)  * Copyright 2002, Phil Karn, KA9Q
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700  6)  * May be used under the terms of the GNU General Public License (GPL)
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700  7)  *
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700  8)  * Adaption to the kernel by Thomas Gleixner (tglx@linutronix.de)
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700  9)  *
3413e1891d443 (Thomas Gleixner 2018-04-22 18:23:49 +0200 10)  * Generic data width independent code which is included by the wrappers.
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 11)  */
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 12) {
2163398192f6a (Thomas Gleixner 2018-04-22 18:23:53 +0200 13) 	struct rs_codec *rs = rsc->codec;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 14) 	int i, j, pad;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 15) 	int nn = rs->nn;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 16) 	int nroots = rs->nroots;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 17) 	uint16_t *alpha_to = rs->alpha_to;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 18) 	uint16_t *index_of = rs->index_of;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 19) 	uint16_t *genpoly = rs->genpoly;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 20) 	uint16_t fb;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 21) 	uint16_t msk = (uint16_t) rs->nn;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 22) 
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 23) 	/* Check length parameter for validity */
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 24) 	pad = nn - nroots - len;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 25) 	if (pad < 0 || pad >= nn)
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 26) 		return -ERANGE;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 27) 
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 28) 	for (i = 0; i < len; i++) {
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 29) 		fb = index_of[((((uint16_t) data[i])^invmsk) & msk) ^ par[0]];
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 30) 		/* feedback term is non-zero */
03ead8427d65f (Thomas Gleixner 2005-11-07 11:15:37 +0000 31) 		if (fb != nn) {
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 32) 			for (j = 1; j < nroots; j++) {
03ead8427d65f (Thomas Gleixner 2005-11-07 11:15:37 +0000 33) 				par[j] ^= alpha_to[rs_modnn(rs, fb +
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 34) 							 genpoly[nroots - j])];
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 35) 			}
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 36) 		}
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 37) 		/* Shift */
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 38) 		memmove(&par[0], &par[1], sizeof(uint16_t) * (nroots - 1));
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 39) 		if (fb != nn) {
03ead8427d65f (Thomas Gleixner 2005-11-07 11:15:37 +0000 40) 			par[nroots - 1] = alpha_to[rs_modnn(rs,
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 41) 							    fb + genpoly[0])];
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 42) 		} else {
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 43) 			par[nroots - 1] = 0;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 44) 		}
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 45) 	}
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 46) 	return 0;
^1da177e4c3f4 (Linus Torvalds  2005-04-16 15:20:36 -0700 47) }