Merge tag 'for-4.19/post-20180822' of git://git.kernel.dk/linux-block
[sfrench/cifs-2.6.git] / drivers / md / bcache / util.h
index 4e0ed19e32d3f5ab68bdee4760c0fffc0c42644f..00aab6abcfe4fd3bb4e625780de0badee109dbf0 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/ratelimit.h>
 #include <linux/vmalloc.h>
 #include <linux/workqueue.h>
+#include <linux/crc64.h>
 
 #include "closure.h"
 
@@ -543,6 +544,22 @@ dup:                                                                       \
 #define RB_PREV(ptr, member)                                           \
        container_of_or_null(rb_prev(&(ptr)->member), typeof(*ptr), member)
 
+static inline uint64_t bch_crc64(const void *p, size_t len)
+{
+       uint64_t crc = 0xffffffffffffffffULL;
+
+       crc = crc64_be(crc, p, len);
+       return crc ^ 0xffffffffffffffffULL;
+}
+
+static inline uint64_t bch_crc64_update(uint64_t crc,
+                                       const void *p,
+                                       size_t len)
+{
+       crc = crc64_be(crc, p, len);
+       return crc;
+}
+
 /* Does linear interpolation between powers of two */
 static inline unsigned int fract_exp_two(unsigned int x,
                                         unsigned int fract_bits)
@@ -563,8 +580,4 @@ static inline sector_t bdev_sectors(struct block_device *bdev)
 {
        return bdev->bd_inode->i_size >> 9;
 }
-
-uint64_t bch_crc64_update(uint64_t crc, const void *_data, size_t len);
-uint64_t bch_crc64(const void *data, size_t len);
-
 #endif /* _BCACHE_UTIL_H */