Skip to content

Commit 84c8103

Browse files
Revert "corsair-hydro-platinum: Add fallback implementation for when CONFIG_CRC8 is disabled"
This reverts commit 3f9dd62. Signed-off-by: Jack Greiner <jack@emoss.org>
1 parent 3c28e03 commit 84c8103

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

drivers/hwmon/corsair-hydro-platinum.c

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@
8383
#define OFFSET_PUMP_MODE 20
8484
#define OFFSET_PROFILE_LEN 26
8585

86-
#if IS_REACHABLE(CONFIG_CRC8)
8786
DECLARE_CRC8_TABLE(corsair_crc8_table);
88-
#endif
8987

9088
struct hydro_platinum_data {
9189
struct hid_device *hdev;
@@ -129,32 +127,7 @@ struct hydro_platinum_device_info {
129127
/* SMBus standard CRC-8 polynomial x^8 + x^2 + x + 1 (0x07) */
130128
static void hydro_platinum_init_crc(void)
131129
{
132-
#if IS_REACHABLE(CONFIG_CRC8)
133130
crc8_populate_msb(corsair_crc8_table, 0x07);
134-
#endif
135-
}
136-
137-
static u8 hydro_platinum_calc_crc(const u8 *data, size_t len, u8 crc)
138-
{
139-
#if IS_REACHABLE(CONFIG_CRC8)
140-
return crc8(corsair_crc8_table, data, len, crc);
141-
#else
142-
/* Table-less fallback for when CONFIG_CRC8 is disabled */
143-
size_t i, j;
144-
u8 val;
145-
146-
for (i = 0; i < len; i++) {
147-
val = data[i];
148-
crc ^= val;
149-
for (j = 0; j < 8; j++) {
150-
if (crc & 0x80)
151-
crc = (crc << 1) ^ 0x07;
152-
else
153-
crc <<= 1;
154-
}
155-
}
156-
return crc;
157-
#endif
158131
}
159132

160133
/**
@@ -195,8 +168,8 @@ static int hydro_platinum_send_command(struct hydro_platinum_data *priv, u8 feat
195168

196169
/* Calculate CRC over buf[2] to buf[REPORT_LENGTH-1+1] */
197170
/* Payload is buf[1]..buf[64]. CRC is usually last byte of payload. */
198-
priv->tx_buffer[REPORT_LENGTH] = hydro_platinum_calc_crc(priv->tx_buffer + 2,
199-
REPORT_LENGTH - 2, 0);
171+
priv->tx_buffer[REPORT_LENGTH] = crc8(corsair_crc8_table, priv->tx_buffer + 2,
172+
REPORT_LENGTH - 2, 0);
200173

201174
/* Send Report - 65 bytes */
202175

@@ -258,7 +231,7 @@ static int hydro_platinum_transaction(struct hydro_platinum_data *priv, u8 featu
258231
* prevents the driver from processing invalid data, which could otherwise
259232
* confuse the device state machine and cause firmware crashes/reboots.
260233
*/
261-
if (hydro_platinum_calc_crc(priv->rx_buffer + 1, REPORT_LENGTH - 1, 0) != 0) {
234+
if (crc8(corsair_crc8_table, priv->rx_buffer + 1, REPORT_LENGTH - 1, 0) != 0) {
262235
dev_warn_ratelimited(&priv->hdev->dev,
263236
"CRC check failed for command %02x - possible userspace collision\n",
264237
command);

0 commit comments

Comments
 (0)