diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-03-04 11:53:15 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-03-04 14:19:26 +0100 |
commit | 2d13b856604bd9486f5190438e695d0708dc5017 (patch) | |
tree | e2e514d2eeb7ccdfa8035bbeb501ab4867ce9174 /include | |
parent | 74de1afbd2ed4262d4105b12641de0c5c487d930 (diff) | |
download | barebox-2d13b856604bd9486f5190438e695d0708dc5017.tar.gz barebox-2d13b856604bd9486f5190438e695d0708dc5017.tar.xz |
crc: Add PBL variant for crc_itu_t()
Enable crc_itu_t() for PBL. For the PBL use the slower-but-smaller
variant without table.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/crc.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/crc.h b/include/crc.h index 317f6f5494..a67388f732 100644 --- a/include/crc.h +++ b/include/crc.h @@ -13,10 +13,26 @@ extern u16 const crc_itu_t_table[256]; extern u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len); +#ifdef __PBL__ +static inline u16 crc_itu_t_byte(u16 crc, const u8 data) +{ + int i; + + crc = crc ^ data << 8; + for (i = 0; i < 8; ++i) { + if (crc & 0x8000) + crc = crc << 1 ^ 0x1021; + else + crc = crc << 1; + } + return crc; +} +#else static inline u16 crc_itu_t_byte(u16 crc, const u8 data) { return (crc << 8) ^ crc_itu_t_table[((crc >> 8) ^ data) & 0xff]; } +#endif uint32_t crc32(uint32_t, const void *, unsigned int); uint32_t crc32_no_comp(uint32_t, const void *, unsigned int); |