hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/include/linux/bch.h
....@@ -1,18 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Generic binary BCH encoding/decoding library
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms of the GNU General Public License version 2 as published by
6
- * the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
12
- *
13
- * You should have received a copy of the GNU General Public License along with
14
- * this program; if not, write to the Free Software Foundation, Inc., 51
15
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
164 *
175 * Copyright © 2011 Parrot S.A.
186 *
....@@ -45,6 +33,7 @@
4533 * @cache: log-based polynomial representation buffer
4634 * @elp: error locator polynomial
4735 * @poly_2t: temporary polynomials of degree 2t
36
+ * @swap_bits: swap bits within data and syndrome bytes
4837 */
4938 struct bch_control {
5039 unsigned int m;
....@@ -63,16 +52,18 @@
6352 int *cache;
6453 struct gf_poly *elp;
6554 struct gf_poly *poly_2t[4];
55
+ bool swap_bits;
6656 };
6757
68
-struct bch_control *init_bch(int m, int t, unsigned int prim_poly);
58
+struct bch_control *bch_init(int m, int t, unsigned int prim_poly,
59
+ bool swap_bits);
6960
70
-void free_bch(struct bch_control *bch);
61
+void bch_free(struct bch_control *bch);
7162
72
-void encode_bch(struct bch_control *bch, const uint8_t *data,
63
+void bch_encode(struct bch_control *bch, const uint8_t *data,
7364 unsigned int len, uint8_t *ecc);
7465
75
-int decode_bch(struct bch_control *bch, const uint8_t *data, unsigned int len,
66
+int bch_decode(struct bch_control *bch, const uint8_t *data, unsigned int len,
7667 const uint8_t *recv_ecc, const uint8_t *calc_ecc,
7768 const unsigned int *syn, unsigned int *errloc);
7869