core/psd/imx6ull/bch.c
static void compute_trace_bk_mod(struct bch_control *bch, int k,
				 const struct gf_poly *f, struct gf_poly *z,
				 struct gf_poly *out)
{
	const int m = GF_M(bch);
	int i, j;

	/* z contains z^2j mod f */
	z->deg = 1;
	z->c[0] = 0;
	z->c[1] = bch->a_pow_tab[k];

	out->deg = 0;
	memset(out, 0, GF_POLY_SZ(f->deg));

	/* compute f log representation only once */
	gf_poly_logrep(bch, f, bch->cache);

	for (i = 0; i < m; i++) {
		/* add a^(k*2^i)(z^(2^i) mod f) and compute (z^(2^i) mod f)^2 */
		for (j = z->deg; j >= 0; j--) {
			out->c[j] ^= z->c[j];
			z->c[2*j] = gf_sqr(bch, z->c[j]);
			z->c[2*j+1] = 0;
		}
		if (z->deg > out->deg)
			out->deg = z->deg;

		if (i < m-1) {
			z->deg *= 2;
			/* z^(2(i+1)) mod f = (z^(2^i) mod f)^2 mod f */
			gf_poly_mod(bch, z, f, bch->cache);
		}
	}
	while (!out->c[out->deg] && out->deg)
		out->deg--;
}
/*
 * Given a polynomial f and an integer k, compute Tr(a^kX) mod f
 * This is used in Berlekamp Trace algorithm for splitting polynomials
 */
Given a polynomial f and an integer k, compute Tr(a^kX) mod f
This is used in Berlekamp Trace algorithm for splitting polynomials
Given a polynomial f and an integer k compute Tr ( a^kX ) mod f This is used in Berlekamp Trace algorithm for splitting polynomials
static void compute_trace_bk_mod(struct bch_control *bch, int k,
				 const struct gf_poly *f, struct gf_poly *z,
				 struct gf_poly *out)
{
	const int m = GF_M(bch);
	int i, j;
	z->deg = 1;
	z->c[0] = 0;
	z->c[1] = bch->a_pow_tab[k];
	out->deg = 0;
	memset(out, 0, GF_POLY_SZ(f->deg));
	gf_poly_logrep(bch, f, bch->cache);
	for (i = 0; i < m; i++) {
		for (j = z->deg; j >= 0; j--) {
			out->c[j] ^= z->c[j];
			z->c[2*j] = gf_sqr(bch, z->c[j]);
			z->c[2*j+1] = 0;
		}
		if (z->deg > out->deg)
			out->deg = z->deg;
		if (i < m-1) {
			z->deg *= 2;
			gf_poly_mod(bch, z, f, bch->cache);
		}
	}
	while (!out->c[out->deg] && out->deg)
		out->deg--;
}
static void compute_trace_bk_mod ( struct bch_control * bch , int k , const struct gf_poly * f , struct gf_poly * z , struct gf_poly * out ) { const int m = GF_M ( bch ) ; int i , j ; z -> deg = 1 ; z -> c [ 0 ] = 0 ; z -> c [ 1 ] = bch -> a_pow_tab [ k ] ; out -> deg = 0 ; memset ( out , 0 , GF_POLY_SZ ( f -> deg ) ) ; gf_poly_logrep ( bch , f , bch -> cache ) ; for ( i = 0 ; i < m ; i ++ ) { for ( j = z -> deg ; j >= 0 ; j -- ) { out -> c [ j ] ^= z -> c [ j ] ; z -> c [ 2 * j ] = gf_sqr ( bch , z -> c [ j ] ) ; z -> c [ 2 * j + 1 ] = 0 ; } if ( z -> deg > out -> deg ) out -> deg = z -> deg ; if ( i < m - 1 ) { z -> deg *= 2 ; gf_poly_mod ( bch , z , f , bch -> cache ) ; } } while ( ! out -> c [ out -> deg ] && out -> deg ) out -> deg -- ; }
Given a polynomial f and an integer k, compute Tr(a^kX) mod f
 This is used in Berlekamp Trace algorithm for splitting polynomials
Given a polynomial f and an integer k compute Tr ( a^kX ) mod f This is used in Berlekamp Trace algorithm for splitting polynomials
/* z contains z^2j mod f */ /* compute f log representation only once */ /* add a^(k*2^i)(z^(2^i) mod f) and compute (z^(2^i) mod f)^2 */ /* z^(2(i+1)) mod f = (z^(2^i) mod f)^2 mod f */