*/
#include "lafs.h"
+#include <linux/crc32.h>
#include <linux/random.h>
#include <linux/slab.h>
int lafs_calc_cluster_csum(struct cluster_head *head)
{
unsigned int oldcsum = head->checksum;
- unsigned long long newcsum = 0;
unsigned long csum;
- int i;
- unsigned int *superc = (unsigned int *) head;
- head->checksum = 0;
- for (i = 0; i < le16_to_cpu(head->Hlength)/4; i++)
- newcsum += le32_to_cpu(superc[i]);
- csum = (newcsum & 0xffffffff) + (newcsum>>32);
+ head->checksum = 0;
+ csum = crc32_le(0, (unsigned char *)head, le16_to_cpu(head->Hlength));
head->checksum = oldcsum;
- return cpu_to_le32(csum);
+ return csum;
}
/*------------------------------------------------------------------------