fs: ext4: Use CRC-16 implementation from linux/crc16.h
Implementation in linux/crc16.h provides standard CRC-16 algorithm with
polynomial x^16 + x^15 + x^2 + 1. Use it and remove duplicate ext4 CRC-16
specific code.
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index c52cc40..d49ba4a 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -427,14 +427,14 @@
if (le32_to_cpu(fs->sb->feature_ro_compat) & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
int offset = offsetof(struct ext2_block_group, bg_checksum);
- crc = ext2fs_crc16(~0, fs->sb->unique_id,
+ crc = crc16(~0, (__u8 *)fs->sb->unique_id,
sizeof(fs->sb->unique_id));
- crc = ext2fs_crc16(crc, &le32_i, sizeof(le32_i));
- crc = ext2fs_crc16(crc, desc, offset);
+ crc = crc16(crc, (__u8 *)&le32_i, sizeof(le32_i));
+ crc = crc16(crc, (__u8 *)desc, offset);
offset += sizeof(desc->bg_checksum); /* skip checksum */
assert(offset == sizeof(*desc));
if (offset < fs->gdsize) {
- crc = ext2fs_crc16(crc, (__u8 *)desc + offset,
+ crc = crc16(crc, (__u8 *)desc + offset,
fs->gdsize - offset);
}
}