brintos

brintos / linux-shallow public Read only

0
0
Text · 754 B · 6ad43c7 Raw
35 lines · c
1/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */2/* Copyright (C) 2015-2017 Netronome Systems, Inc. */3 4#ifndef NFP_CRC32_H5#define NFP_CRC32_H6 7#include <linux/crc32.h>8 9/**10 * crc32_posix_end() - Finalize POSIX CRC32 working state11 * @crc:	Current CRC32 working state12 * @total_len:	Total length of data that was CRC32'd13 *14 * Return: Final POSIX CRC32 value15 */16static inline u32 crc32_posix_end(u32 crc, size_t total_len)17{18	/* Extend with the length of the string. */19	while (total_len != 0) {20		u8 c = total_len & 0xff;21 22		crc = crc32_be(crc, &c, 1);23		total_len >>= 8;24	}25 26	return ~crc;27}28 29static inline u32 crc32_posix(const void *buff, size_t len)30{31	return crc32_posix_end(crc32_be(0, buff, len), len);32}33 34#endif /* NFP_CRC32_H */35