Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Eric Biggers and committed by
Jakub Kicinski
0aa4024b 685e7b15

+3 -21
+1
drivers/net/ethernet/broadcom/Kconfig
··· 123 123 tristate "Broadcom Tigon3 support" 124 124 depends on PCI 125 125 depends on PTP_1588_CLOCK_OPTIONAL 126 + select CRC32 126 127 select PHYLIB 127 128 help 128 129 This driver supports Broadcom Tigon3 based gigabit Ethernet cards.
+2 -21
drivers/net/ethernet/broadcom/tg3.c
··· 54 54 #include <linux/ssb/ssb_driver_gige.h> 55 55 #include <linux/hwmon.h> 56 56 #include <linux/hwmon-sysfs.h> 57 - #include <linux/crc32poly.h> 57 + #include <linux/crc32.h> 58 58 #include <linux/dmi.h> 59 59 60 60 #include <net/checksum.h> ··· 9809 9809 9810 9810 static inline u32 calc_crc(unsigned char *buf, int len) 9811 9811 { 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); 9832 9813 } 9833 9814 9834 9815 static void tg3_set_multi(struct tg3 *tp, unsigned int accept_all)