History

lib/bch: Rework a little bit the exported function names

There are four exported functions, all suffixed by _bch, which is clearly not the norm. Let's rename them by prefixing them with bch_ instead. This is a mechanical change: init_bch -> bch_init free_bch -> bch_free encode_bch -> bch_encode decode_bch -> bch_decode

Miquel Raynal committed 6 years ago

Commit c8ae3f71 parent f0689804 files · +46 −46Browse files

Unified · Split

4 files
  1. drivers/mtd/devices/docg3.c +5 −5
  2. drivers/mtd/nand/raw/nand_bch.c +5 −5
  3. include/linux/bch.h +4 −4
  4. lib/bch.c +32 −32
drivers/mtd/devices/docg3.c+5−5
@@ -647,7 +647,7 @@ static int doc_ecc_bch_fix_data(struct docg3 *docg3, void *buf, u8 *hwecc) · 646 unmodified lines
647647
648648 for (i = 0; i < DOC_ECC_BCH_SIZE; i++)
649649 ecc[i] = bitrev8(hwecc[i]);
650− numerrs = decode_bch(docg3->cascade->bch, NULL,
650+ numerrs = bch_decode(docg3->cascade->bch, NULL,
651651 DOC_ECC_BCH_COVERED_BYTES,
652652 NULL, ecc, NULL, errorpos);
653653 BUG_ON(numerrs == -EINVAL);
@@ -1984,8 +1984,8 @@ static int __init docg3_probe(struct platform_device *pdev) · 1330 unmodified lines
19841984 return ret;
19851985 cascade->base = base;
19861986 mutex_init(&cascade->lock);
1987− cascade->bch = init_bch(DOC_ECC_BCH_M, DOC_ECC_BCH_T,
1988− DOC_ECC_BCH_PRIMPOLY);
1987+ cascade->bch = bch_init(DOC_ECC_BCH_M, DOC_ECC_BCH_T,
1988+ DOC_ECC_BCH_PRIMPOLY);
19891989 if (!cascade->bch)
19901990 return ret;
19911991
@@ -2021,7 +2021,7 @@ notfound: · 29 unmodified lines
20212021 ret = -ENODEV;
20222022 dev_info(dev, "No supported DiskOnChip found\n");
20232023 err_probe:
2024− free_bch(cascade->bch);
2024+ bch_free(cascade->bch);
20252025 for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++)
20262026 if (cascade->floors[floor])
20272027 doc_release_device(cascade->floors[floor]);
@@ -2045,7 +2045,7 @@ static int docg3_release(struct platform_device *pdev) · 17 unmodified lines
20452045 if (cascade->floors[floor])
20462046 doc_release_device(cascade->floors[floor]);
20472047
2048− free_bch(docg3->cascade->bch);
2048+ bch_free(docg3->cascade->bch);
20492049 return 0;
20502050 }
20512051
drivers/mtd/nand/raw/nand_bch.c+5−5
@@ -41,7 +41,7 @@ int nand_bch_calculate_ecc(struct nand_chip *chip, const unsigned char *buf, · 40 unmodified lines
4141 unsigned int i;
4242
4343 memset(code, 0, chip->ecc.bytes);
44− encode_bch(nbc->bch, buf, chip->ecc.size, code);
44+ bch_encode(nbc->bch, buf, chip->ecc.size, code);
4545
4646 /* apply mask so that an erased page is a valid codeword */
4747 for (i = 0; i < chip->ecc.bytes; i++)
@@ -67,7 +67,7 @@ int nand_bch_correct_data(struct nand_chip *chip, unsigned char *buf, · 19 unmodified lines
6767 unsigned int *errloc = nbc->errloc;
6868 int i, count;
6969
70− count = decode_bch(nbc->bch, NULL, chip->ecc.size, read_ecc, calc_ecc,
70+ count = bch_decode(nbc->bch, NULL, chip->ecc.size, read_ecc, calc_ecc,
7171 NULL, errloc);
7272 if (count > 0) {
7373 for (i = 0; i < count; i++) {
@@ -130,7 +130,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) · 56 unmodified lines
130130 if (!nbc)
131131 goto fail;
132132
133− nbc->bch = init_bch(m, t, 0);
133+ nbc->bch = bch_init(m, t, 0);
134134 if (!nbc->bch)
135135 goto fail;
136136
@@ -182,7 +182,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) · 45 unmodified lines
182182 goto fail;
183183
184184 memset(erased_page, 0xff, eccsize);
185− encode_bch(nbc->bch, erased_page, eccsize, nbc->eccmask);
185+ bch_encode(nbc->bch, erased_page, eccsize, nbc->eccmask);
186186 kfree(erased_page);
187187
188188 for (i = 0; i < eccbytes; i++)
@@ -205,7 +205,7 @@ EXPORT_SYMBOL(nand_bch_init); · 16 unmodified lines
205205 void nand_bch_free(struct nand_bch_control *nbc)
206206 {
207207 if (nbc) {
208− free_bch(nbc->bch);
208+ bch_free(nbc->bch);
209209 kfree(nbc->errloc);
210210 kfree(nbc->eccmask);
211211 kfree(nbc);
include/linux/bch.h+4−4
@@ -53,14 +53,14 @@ struct bch_control { · 52 unmodified lines
5353 struct gf_poly *poly_2t[4];
5454 };
5555
56−struct bch_control *init_bch(int m, int t, unsigned int prim_poly);
56+struct bch_control *bch_init(int m, int t, unsigned int prim_poly);
5757
58−void free_bch(struct bch_control *bch);
58+void bch_free(struct bch_control *bch);
5959
60−void encode_bch(struct bch_control *bch, const uint8_t *data,
60+void bch_encode(struct bch_control *bch, const uint8_t *data,
6161 unsigned int len, uint8_t *ecc);
6262
63−int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len,
63+int bch_decode(struct bch_control *bch, const uint8_t *data, unsigned int len,
6464 const uint8_t *recv_ecc, const uint8_t *calc_ecc,
6565 const unsigned int *syn, unsigned int *errloc);
6666
lib/bch.c+32−32
@@ -23,15 +23,15 @@ · 22 unmodified lines
2323 * This library provides runtime configurable encoding/decoding of binary
2424 * Bose-Chaudhuri-Hocquenghem (BCH) codes.
2525 *
26− * Call init_bch to get a pointer to a newly allocated bch_control structure for
26+ * Call bch_init to get a pointer to a newly allocated bch_control structure for
2727 * the given m (Galois field order), t (error correction capability) and
2828 * (optional) primitive polynomial parameters.
2929 *
30− * Call encode_bch to compute and store ecc parity bytes to a given buffer.
31− * Call decode_bch to detect and locate errors in received data.
30+ * Call bch_encode to compute and store ecc parity bytes to a given buffer.
31+ * Call bch_decode to detect and locate errors in received data.
3232 *
3333 * On systems supporting hw BCH features, intermediate results may be provided
34− * to decode_bch in order to skip certain steps. See decode_bch() documentation
34+ * to bch_decode in order to skip certain steps. See bch_decode() documentation
3535 * for details.
3636 *
3737 * Option CONFIG_BCH_CONST_PARAMS can be used to force fixed values of
@@ -115,9 +115,9 @@ struct gf_poly_deg1 { · 77 unmodified lines
115115 };
116116
117117 /*
118− * same as encode_bch(), but process input data one byte at a time
118+ * same as bch_encode(), but process input data one byte at a time
119119 */
120−static void encode_bch_unaligned(struct bch_control *bch,
120+static void bch_encode_unaligned(struct bch_control *bch,
121121 const unsigned char *data, unsigned int len,
122122 uint32_t *ecc)
123123 {
@@ -174,7 +174,7 @@ static void store_ecc8(struct bch_control *bch, uint8_t *dst, · 50 unmodified lines
174174 }
175175
176176 /**
177− * encode_bch - calculate BCH ecc parity of data
177+ * bch_encode - calculate BCH ecc parity of data
178178 * @bch: BCH control structure
179179 * @data: data to encode
180180 * @len: data length in bytes
@@ -187,7 +187,7 @@ static void store_ecc8(struct bch_control *bch, uint8_t *dst, · 6 unmodified lines
187187 * The exact number of computed ecc parity bits is given by member @ecc_bits of
188188 * @bch; it may be less than m*t for large values of t.
189189 */
190−void encode_bch(struct bch_control *bch, const uint8_t *data,
190+void bch_encode(struct bch_control *bch, const uint8_t *data,
191191 unsigned int len, uint8_t *ecc)
192192 {
193193 const unsigned int l = BCH_ECC_WORDS(bch)-1;
@@ -215,7 +215,7 @@ void encode_bch(struct bch_control *bch, const uint8_t *data, · 21 unmodified lines
215215 m = ((unsigned long)data) & 3;
216216 if (m) {
217217 mlen = (len < (4-m)) ? len : 4-m;
218− encode_bch_unaligned(bch, data, mlen, bch->ecc_buf);
218+ bch_encode_unaligned(bch, data, mlen, bch->ecc_buf);
219219 data += mlen;
220220 len -= mlen;
221221 }
@@ -255,13 +255,13 @@ void encode_bch(struct bch_control *bch, const uint8_t *data, · 33 unmodified lines
255255
256256 /* process last unaligned bytes */
257257 if (len)
258− encode_bch_unaligned(bch, data, len, bch->ecc_buf);
258+ bch_encode_unaligned(bch, data, len, bch->ecc_buf);
259259
260260 /* store ecc parity bytes into original parity buffer */
261261 if (ecc)
262262 store_ecc8(bch, ecc, bch->ecc_buf);
263263 }
264−EXPORT_SYMBOL_GPL(encode_bch);
264+EXPORT_SYMBOL_GPL(bch_encode);
265265
266266 static inline int modulo(struct bch_control *bch, unsigned int v)
267267 {
@@ -952,7 +952,7 @@ static int chien_search(struct bch_control *bch, unsigned int len, · 684 unmodified lines
952952 #endif /* USE_CHIEN_SEARCH */
953953
954954 /**
955− * decode_bch - decode received codeword and find bit error locations
955+ * bch_decode - decode received codeword and find bit error locations
956956 * @bch: BCH control structure
957957 * @data: received data, ignored if @calc_ecc is provided
958958 * @len: data length in bytes, must always be provided
@@ -966,22 +966,22 @@ static int chien_search(struct bch_control *bch, unsigned int len, · 7 unmodified lines
966966 * invalid parameters were provided
967967 *
968968 * Depending on the available hw BCH support and the need to compute @calc_ecc
969− * separately (using encode_bch()), this function should be called with one of
969+ * separately (using bch_encode()), this function should be called with one of
970970 * the following parameter configurations -
971971 *
972972 * by providing @data and @recv_ecc only:
973− * decode_bch(@bch, @data, @len, @recv_ecc, NULL, NULL, @errloc)
973+ * bch_decode(@bch, @data, @len, @recv_ecc, NULL, NULL, @errloc)
974974 *
975975 * by providing @recv_ecc and @calc_ecc:
976− * decode_bch(@bch, NULL, @len, @recv_ecc, @calc_ecc, NULL, @errloc)
976+ * bch_decode(@bch, NULL, @len, @recv_ecc, @calc_ecc, NULL, @errloc)
977977 *
978978 * by providing ecc = recv_ecc XOR calc_ecc:
979− * decode_bch(@bch, NULL, @len, NULL, ecc, NULL, @errloc)
979+ * bch_decode(@bch, NULL, @len, NULL, ecc, NULL, @errloc)
980980 *
981981 * by providing syndrome results @syn:
982− * decode_bch(@bch, NULL, @len, NULL, NULL, @syn, @errloc)
982+ * bch_decode(@bch, NULL, @len, NULL, NULL, @syn, @errloc)
983983 *
984− * Once decode_bch() has successfully returned with a positive value, error
984+ * Once bch_decode() has successfully returned with a positive value, error
985985 * locations returned in array @errloc should be interpreted as follows -
986986 *
987987 * if (errloc[n] >= 8*len), then n-th error is located in ecc (no need for
@@ -993,7 +993,7 @@ static int chien_search(struct bch_control *bch, unsigned int len, · 5 unmodified lines
993993 * Note that this function does not perform any data correction by itself, it
994994 * merely indicates error locations.
995995 */
996−int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len,
996+int bch_decode(struct bch_control *bch, const uint8_t *data, unsigned int len,
997997 const uint8_t *recv_ecc, const uint8_t *calc_ecc,
998998 const unsigned int *syn, unsigned int *errloc)
999999 {
@@ -1012,7 +1012,7 @@ int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len, · 12 unmodified lines
10121012 /* compute received data ecc into an internal buffer */
10131013 if (!data || !recv_ecc)
10141014 return -EINVAL;
1015− encode_bch(bch, data, len, NULL);
1015+ bch_encode(bch, data, len, NULL);
10161016 } else {
10171017 /* load provided calculated ecc */
10181018 load_ecc8(bch, bch->ecc_buf, calc_ecc);
@@ -1053,7 +1053,7 @@ int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len, · 34 unmodified lines
10531053 }
10541054 return (err >= 0) ? err : -EBADMSG;
10551055 }
1056−EXPORT_SYMBOL_GPL(decode_bch);
1056+EXPORT_SYMBOL_GPL(bch_decode);
10571057
10581058 /*
10591059 * generate Galois field lookup tables
@@ -1236,7 +1236,7 @@ finish: · 176 unmodified lines
12361236 }
12371237
12381238 /**
1239− * init_bch - initialize a BCH encoder/decoder
1239+ * bch_init - initialize a BCH encoder/decoder
12401240 * @m: Galois field order, should be in the range 5-15
12411241 * @t: maximum error correction capability, in bits
12421242 * @prim_poly: user-provided primitive polynomial (or 0 to use default)
@@ -1246,17 +1246,17 @@ finish: · 3 unmodified lines
12461246 *
12471247 * This initialization can take some time, as lookup tables are built for fast
12481248 * encoding/decoding; make sure not to call this function from a time critical
1249− * path. Usually, init_bch() should be called on module/driver init and
1250− * free_bch() should be called to release memory on exit.
1249+ * path. Usually, bch_init() should be called on module/driver init and
1250+ * bch_free() should be called to release memory on exit.
12511251 *
12521252 * You may provide your own primitive polynomial of degree @m in argument
1253− * @prim_poly, or let init_bch() use its default polynomial.
1253+ * @prim_poly, or let bch_init() use its default polynomial.
12541254 *
1255− * Once init_bch() has successfully returned a pointer to a newly allocated
1255+ * Once bch_init() has successfully returned a pointer to a newly allocated
12561256 * BCH control structure, ecc length in bytes is given by member @ecc_bytes of
12571257 * the structure.
12581258 */
1259−struct bch_control *init_bch(int m, int t, unsigned int prim_poly)
1259+struct bch_control *bch_init(int m, int t, unsigned int prim_poly)
12601260 {
12611261 int err = 0;
12621262 unsigned int i, words;
@@ -1347,16 +1347,16 @@ struct bch_control *init_bch(int m, int t, unsigned int prim_poly) · 84 unmodified lines
13471347 return bch;
13481348
13491349 fail:
1350− free_bch(bch);
1350+ bch_free(bch);
13511351 return NULL;
13521352 }
1353−EXPORT_SYMBOL_GPL(init_bch);
1353+EXPORT_SYMBOL_GPL(bch_init);
13541354
13551355 /**
1356− * free_bch - free the BCH control structure
1356+ * bch_free - free the BCH control structure
13571357 * @bch: BCH control structure to release
13581358 */
1359−void free_bch(struct bch_control *bch)
1359+void bch_free(struct bch_control *bch)
13601360 {
13611361 unsigned int i;
13621362
@@ -1377,7 +1377,7 @@ void free_bch(struct bch_control *bch) · 14 unmodified lines
13771377 kfree(bch);
13781378 }
13791379 }
1380−EXPORT_SYMBOL_GPL(free_bch);
1380+EXPORT_SYMBOL_GPL(bch_free);
13811381
13821382 MODULE_LICENSE("GPL");
13831383 MODULE_AUTHOR("Ivan Djelic <ivan.djelic@parrot.com>");