PageRenderTime 24ms CodeModel.GetById 15ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/scsi/bfa/include/cs/bfa_checksum.h

https://bitbucket.org/abioy/linux
C Header | 60 lines | 30 code | 11 blank | 19 comment | 3 complexity | fb269961530ee71a6c5554801d5cdfe5 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, GPL-2.0, LGPL-2.0, AGPL-1.0
 1/*
 2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
 3 * All rights reserved
 4 * www.brocade.com
 5 *
 6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
 7 *
 8 * This program is free software; you can redistribute it and/or modify it
 9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 */
17
18/**
19 *  bfa_checksum.h BFA checksum utilities
20 */
21
22#ifndef __BFA_CHECKSUM_H__
23#define __BFA_CHECKSUM_H__
24
25static inline u32
26bfa_checksum_u32(u32 *buf, int sz)
27{
28	int		i, m = sz >> 2;
29	u32	sum = 0;
30
31	for (i = 0; i < m; i++)
32		sum ^= buf[i];
33
34	return sum;
35}
36
37static inline u16
38bfa_checksum_u16(u16 *buf, int sz)
39{
40	int             i, m = sz >> 1;
41	u16        sum = 0;
42
43	for (i = 0; i < m; i++)
44		sum ^= buf[i];
45
46	return sum;
47}
48
49static inline u8
50bfa_checksum_u8(u8 *buf, int sz)
51{
52	int             i;
53	u8         sum = 0;
54
55	for (i = 0; i < sz; i++)
56		sum ^= buf[i];
57
58	return sum;
59}
60#endif