// SPDX-License-Identifier: GPL-2.0 // // mcp251xfd - Microchip MCP251xFD Family CAN controller driver // // Copyright (c) 2020 Pengutronix, // Marc Kleine-Budde <[email protected]> // // Based on: // // CAN bus driver for Microchip 25XXFD CAN Controller with SPI Interface // // Copyright (c) 2019 Martin Sperl <[email protected]> // #include "mcp251xfd.h" /* The standard crc16 in linux/crc16.h is unfortunately not computing * the correct results (left shift vs. right shift). So here an * implementation with a table generated with the help of: * * http://lkml.iu.edu/hypermail/linux/kernel/0508.1/1085.html */ static const u16 mcp251xfd_crc16_table[] = …; static inline u16 mcp251xfd_crc16_byte(u16 crc, const u8 data) { … } static u16 mcp251xfd_crc16(u16 crc, u8 const *buffer, size_t len) { … } u16 mcp251xfd_crc16_compute(const void *data, size_t data_size) { … } u16 mcp251xfd_crc16_compute2(const void *cmd, size_t cmd_size, const void *data, size_t data_size) { … }