core/psd/imx6ull/bch.c
static void factor_polynomial(struct bch_control *bch, int k, struct gf_poly *f,
			      struct gf_poly **g, struct gf_poly **h)
{
	struct gf_poly *f2 = bch->poly_2t[0];
	struct gf_poly *q  = bch->poly_2t[1];
	struct gf_poly *tk = bch->poly_2t[2];
	struct gf_poly *z  = bch->poly_2t[3];
	struct gf_poly *gcd;

	*g = f;
	*h = NULL;

	/* tk = Tr(a^k.X) mod f */
	compute_trace_bk_mod(bch, k, f, z, tk);

	if (tk->deg > 0) {
		/* compute g = gcd(f, tk) (destructive operation) */
		gf_poly_copy(f2, f);
		gcd = gf_poly_gcd(bch, f2, tk);
		if (gcd->deg < f->deg) {
			/* compute h=f/gcd(f,tk); this will modify f and q */
			gf_poly_div(bch, f, gcd, q);
			/* store g and h in-place (clobbering f) */
			*h = &((struct gf_poly_deg1 *)f)[gcd->deg].poly;
			gf_poly_copy(*g, gcd);
			gf_poly_copy(*h, q);
		}
	}
}
/*
 * factor a polynomial using Berlekamp Trace algorithm (BTA)
 */
factor a polynomial using Berlekamp Trace algorithm (BTA)
factor a polynomial using Berlekamp Trace algorithm ( BTA )
static void factor_polynomial(struct bch_control *bch, int k, struct gf_poly *f,
			      struct gf_poly **g, struct gf_poly **h)
{
	struct gf_poly *f2 = bch->poly_2t[0];
	struct gf_poly *q  = bch->poly_2t[1];
	struct gf_poly *tk = bch->poly_2t[2];
	struct gf_poly *z  = bch->poly_2t[3];
	struct gf_poly *gcd;
	*g = f;
	*h = NULL;
	compute_trace_bk_mod(bch, k, f, z, tk);
	if (tk->deg > 0) {
		gf_poly_copy(f2, f);
		gcd = gf_poly_gcd(bch, f2, tk);
		if (gcd->deg < f->deg) {
			gf_poly_div(bch, f, gcd, q);
			*h = &((struct gf_poly_deg1 *)f)[gcd->deg].poly;
			gf_poly_copy(*g, gcd);
			gf_poly_copy(*h, q);
		}
	}
}
static void factor_polynomial ( struct bch_control * bch , int k , struct gf_poly * f , struct gf_poly * * g , struct gf_poly * * h ) { struct gf_poly * f2 = bch -> poly_2t [ 0 ] ; struct gf_poly * q = bch -> poly_2t [ 1 ] ; struct gf_poly * tk = bch -> poly_2t [ 2 ] ; struct gf_poly * z = bch -> poly_2t [ 3 ] ; struct gf_poly * gcd ; * g = f ; * h = NULL ; compute_trace_bk_mod ( bch , k , f , z , tk ) ; if ( tk -> deg > 0 ) { gf_poly_copy ( f2 , f ) ; gcd = gf_poly_gcd ( bch , f2 , tk ) ; if ( gcd -> deg < f -> deg ) { gf_poly_div ( bch , f , gcd , q ) ; * h = & ( ( struct gf_poly_deg1 * ) f ) [ gcd -> deg ] . poly ; gf_poly_copy ( * g , gcd ) ; gf_poly_copy ( * h , q ) ; } } }
factor a polynomial using Berlekamp Trace algorithm (BTA)
factor a polynomial using Berlekamp Trace algorithm ( BTA )
/* tk = Tr(a^k.X) mod f */ /* compute g = gcd(f, tk) (destructive operation) */ /* compute h=f/gcd(f,tk); this will modify f and q */ /* store g and h in-place (clobbering f) */