From b1092362e2c2ab04c38061b2701184a8423d99a2 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 6 Jun 2013 01:00:31 +0200 Subject: axgetput: Provide calc_crc() function to iterate over memory area. Signed-off-by: Ralf Baechle --- ax25/axgetput/proto_bin.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ax25') diff --git a/ax25/axgetput/proto_bin.c b/ax25/axgetput/proto_bin.c index aeee8bd..d61f72a 100644 --- a/ax25/axgetput/proto_bin.c +++ b/ax25/axgetput/proto_bin.c @@ -41,6 +41,14 @@ static int do_crc(char b, unsigned int crc) return crc; } +unsigned int calc_crc(char *buf, int n, unsigned crc) +{ + while (--n >= 0) + crc = do_crc(*buf++, crc); + + return crc; +} + /*---------------------------------------------------------------------------*/ static long parse_sfbin_date_to_unix(const char *s) -- cgit v1.2.3