FreeBSD/sys/dev/firewire/firewire.c
/*
 * CRC16 check-sum for IEEE1394 register blocks.
 */
CRC16 check-sum for IEEE1394 register blocks.
CRC16 check - sum for IEEE1394 register blocks .
uint16_t
fw_crc16(uint32_t *ptr, uint32_t len)
{
	uint32_t i, sum, crc = 0;
	int shift;
	len = (len + 3) & ~3;
	for (i = 0; i < len; i += 4) {
		for (shift = 28; shift >= 0; shift -= 4) {
			sum = ((crc >> 12) ^ (ptr[i/4] >> shift)) & 0xf;
			crc = (crc << 4) ^ (sum << 12) ^ (sum << 5) ^ sum;
		}
		crc &= 0xffff;
	}
	return ((uint16_t) crc);
}
uint16_t fw_crc16 ( uint32_t * ptr , uint32_t len ) { uint32_t i , sum , crc = 0 ; int shift ; len = ( len + 3 ) & ~ 3 ; for ( i = 0 ; i < len ; i += 4 ) { for ( shift = 28 ; shift >= 0 ; shift -= 4 ) { sum = ( ( crc >> 12 ) ^ ( ptr [ i / 4 ] >> shift ) ) & 0xf ; crc = ( crc << 4 ) ^ ( sum << 12 ) ^ ( sum << 5 ) ^ sum ; } crc &= 0xffff ; } return ( ( uint16_t ) crc ) ; }
CRC16 check-sum for IEEE1394 register blocks.
CRC16 check - sum for IEEE1394 register blocks .