Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:lib\bch.c Create Date:2022-07-28 07:00:06
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:_bch - initialize a BCH encoder/decoder*@m: Galois field order, should be in the range 5-15*@t: maximum error correction capability, in bits*@prim_poly: user-provided primitive polynomial (or 0 to use default)* Returns:* a newly allocated BCH control

Proto:struct bch_control *init_bch(int m, int t, unsigned int prim_poly)

Type:struct bch_control

Parameter:

TypeParameterName
intm
intt
unsigned intprim_poly
1261  err = 0
1264  struct bch_control * bch = NULL
1266  min_m = 5
1269  static const unsigned int prim_poly_tab[] = {0x25, 0x43, 0x83, 0x11d, 0x211, 0x409, 0x805, 0x1053, 0x201b, 0x402b, 0x8003, }
1282  If m < min_m || m > 2KB Then Go to fail
1290  If t > 64 bit correction Then Go to fail
1298  If t < 1 || m * t >= (1 << m) - 1 Then Go to fail
1303  If prim_poly == 0 Then prim_poly = prim_poly_tab[m - min_m]
1306  bch = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
1307  If (bch == NULL) Then Go to fail
1310  m = m
1311  t = t
1312  n = (1 << m) - 1
1313  words = DIV_ROUND_UP(m * t, 32)
1314  ecc_bytes = DIV_ROUND_UP(m * t, 8)
1315  private: = bch_alloc((1 + n) * size of private: , & err)
1316  a_log_tab = bch_alloc((1 + n) * size of a_log_tab , & err)
1317  mod8_tab = bch_alloc(words * 1024 * size of mod8_tab , & err)
1318  ecc_buf = bch_alloc(words * size of ecc_buf , & err)
1319  ecc_buf2 = bch_alloc(words * size of ecc_buf2 , & err)
1320  xi_tab = bch_alloc(m * size of xi_tab , & err)
1321  syn = bch_alloc(2 * t * size of syn , & err)
1322  cache = bch_alloc(2 * t * size of cache , & err)
1323  elp = bch_alloc((t + 1) * sizeof(structgf_poly_deg1), & err)
1325  When i < ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(poly_2t) cycle poly_2t[i] = bch_alloc(given its degree, compute a polynomial size in bytes (2 * t), & err)
1328  If err Then Go to fail
1331  err = generate Galois field lookup tables
1332  If err Then Go to fail
1336  genpoly = mpute generator polynomial for given (m,t) parameters.
1337  If (genpoly == NULL) Then Go to fail
1340  mpute generator polynomial remainder tables for fast encoding
1341  kfree(genpoly)
1343  err = ld a base for factoring degree 2 polynomials
1344  If err Then Go to fail
1347  Return bch
1349  fail :
1350  _bch - free the BCH control structure*@bch: BCH control structure to release
1351  Return NULL