Skip to content

Commit 0aa4024

Browse files
ebiggerskuba-moo
authored andcommitted
net/tg3: use crc32() instead of hand-rolled equivalent
The calculation done by calc_crc() is equivalent to ~crc32(~0, buf, len), so just use that instead. Signed-off-by: Eric Biggers <ebiggers@google.com> Link: https://patch.msgid.link/20250513041402.541527-1-ebiggers@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 685e7b1 commit 0aa4024

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

drivers/net/ethernet/broadcom/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ config TIGON3
123123
tristate "Broadcom Tigon3 support"
124124
depends on PCI
125125
depends on PTP_1588_CLOCK_OPTIONAL
126+
select CRC32
126127
select PHYLIB
127128
help
128129
This driver supports Broadcom Tigon3 based gigabit Ethernet cards.

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#include <linux/ssb/ssb_driver_gige.h>
5555
#include <linux/hwmon.h>
5656
#include <linux/hwmon-sysfs.h>
57-
#include <linux/crc32poly.h>
57+
#include <linux/crc32.h>
5858
#include <linux/dmi.h>
5959

6060
#include <net/checksum.h>
@@ -9809,26 +9809,7 @@ static void tg3_setup_rxbd_thresholds(struct tg3 *tp)
98099809

98109810
static inline u32 calc_crc(unsigned char *buf, int len)
98119811
{
9812-
u32 reg;
9813-
u32 tmp;
9814-
int j, k;
9815-
9816-
reg = 0xffffffff;
9817-
9818-
for (j = 0; j < len; j++) {
9819-
reg ^= buf[j];
9820-
9821-
for (k = 0; k < 8; k++) {
9822-
tmp = reg & 0x01;
9823-
9824-
reg >>= 1;
9825-
9826-
if (tmp)
9827-
reg ^= CRC32_POLY_LE;
9828-
}
9829-
}
9830-
9831-
return ~reg;
9812+
return ~crc32(~0, buf, len);
98329813
}
98339814

98349815
static void tg3_set_multi(struct tg3 *tp, unsigned int accept_all)

0 commit comments

Comments
 (0)