]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/tg3: use crc32() instead of hand-rolled equivalent
authorEric Biggers <ebiggers@google.com>
Tue, 13 May 2025 04:14:02 +0000 (21:14 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 15 May 2025 01:52:46 +0000 (18:52 -0700)
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>
drivers/net/ethernet/broadcom/Kconfig
drivers/net/ethernet/broadcom/tg3.c

index 1bd4313215d7150d1d0d6e7300d2d0d5b96121ec..636520bb4b8c7b0f97eeb42463583e5d5945a725 100644 (file)
@@ -123,6 +123,7 @@ config TIGON3
        tristate "Broadcom Tigon3 support"
        depends on PCI
        depends on PTP_1588_CLOCK_OPTIONAL
+       select CRC32
        select PHYLIB
        help
          This driver supports Broadcom Tigon3 based gigabit Ethernet cards.
index d1f541af4e3b88e6b140b3432d829f227053d2ff..ff47e96b912485c252e3bc54a3b5cf5c8aa4dfd5 100644 (file)
@@ -54,7 +54,7 @@
 #include <linux/ssb/ssb_driver_gige.h>
 #include <linux/hwmon.h>
 #include <linux/hwmon-sysfs.h>
-#include <linux/crc32poly.h>
+#include <linux/crc32.h>
 #include <linux/dmi.h>
 
 #include <net/checksum.h>
@@ -9809,26 +9809,7 @@ static void tg3_setup_rxbd_thresholds(struct tg3 *tp)
 
 static inline u32 calc_crc(unsigned char *buf, int len)
 {
-       u32 reg;
-       u32 tmp;
-       int j, k;
-
-       reg = 0xffffffff;
-
-       for (j = 0; j < len; j++) {
-               reg ^= buf[j];
-
-               for (k = 0; k < 8; k++) {
-                       tmp = reg & 0x01;
-
-                       reg >>= 1;
-
-                       if (tmp)
-                               reg ^= CRC32_POLY_LE;
-               }
-       }
-
-       return ~reg;
+       return ~crc32(~0, buf, len);
 }
 
 static void tg3_set_multi(struct tg3 *tp, unsigned int accept_all)