Skip to contentSkip to conversation

lib/crc-t10dif: remove digest and block size constants

PATCH In review Eric Biggers 2 participants 4 messages Feb 4, 2025 – Feb 6, 2025

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 lib/crc-t10dif: remove digest and block size constants

From: Eric Biggers <[email protected]>

These constants are only used in crypto/crct10dif_generic.c, and they are better off just hardcoded there.

---

I'm planning to take this via the crc tree.

 crypto/crct10dif_generic.c | 8 ++++----
 include/linux/crc-t10dif.h | 3 ---
 2 files changed, 4 insertions(+), 7 deletions(-)
crypto/crct10dif_generic.c +4 -4
index 259cb01932cb5..fdfe78aba3ae0 100644
@@ -114,34 +114,34 @@ static int chksum_digest_arch(struct shash_desc *desc, const u8 *data,
 {
 	return __chksum_finup_arch(0, data, length, out);
 }
 
 static struct shash_alg algs[] = {{
-	.digestsize		= CRC_T10DIF_DIGEST_SIZE,
+	.digestsize		= sizeof(u16),
 	.init			= chksum_init,
 	.update			= chksum_update,
 	.final			= chksum_final,
 	.finup			= chksum_finup,
 	.digest			= chksum_digest,
 	.descsize		= sizeof(struct chksum_desc_ctx),
 	.base.cra_name		= "crct10dif",
 	.base.cra_driver_name	= "crct10dif-generic",
 	.base.cra_priority	= 100,
-	.base.cra_blocksize	= CRC_T10DIF_BLOCK_SIZE,
+	.base.cra_blocksize	= 1,
 	.base.cra_module	= THIS_MODULE,
 }, {
-	.digestsize		= CRC_T10DIF_DIGEST_SIZE,
+	.digestsize		= sizeof(u16),
 	.init			= chksum_init,
 	.update			= chksum_update_arch,
 	.final			= chksum_final,
 	.finup			= chksum_finup_arch,
 	.digest			= chksum_digest_arch,
 	.descsize		= sizeof(struct chksum_desc_ctx),
 	.base.cra_name		= "crct10dif",
 	.base.cra_driver_name	= "crct10dif-" __stringify(ARCH),
 	.base.cra_priority	= 150,
-	.base.cra_blocksize	= CRC_T10DIF_BLOCK_SIZE,
+	.base.cra_blocksize	= 1,
 	.base.cra_module	= THIS_MODULE,
 }};
 
 static int num_algs;
 
include/linux/crc-t10dif.h +0 -3
index 16787c1cee21c..d0706544fc11f 100644
@@ -2,13 +2,10 @@
 #ifndef _LINUX_CRC_T10DIF_H
 #define _LINUX_CRC_T10DIF_H
 
 #include <linux/types.h>
 
-#define CRC_T10DIF_DIGEST_SIZE 2
-#define CRC_T10DIF_BLOCK_SIZE 1
-
 u16 crc_t10dif_arch(u16 crc, const u8 *p, size_t len);
 u16 crc_t10dif_generic(u16 crc, const u8 *p, size_t len);
 
 static inline u16 crc_t10dif_update(u16 crc, const u8 *p, size_t len)
 {

base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b

Signature · 1 line
2.48.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Eric Biggers

From: Eric Biggers <[email protected]>

These constants are only used in crypto/crct10dif_generic.c, and they are better off just hardcoded there.

---

I'm planning to take this via the crc tree.

Could you remind me why we are keeping this driver?

Quoted 70 lines
 crypto/crct10dif_generic.c | 8 ++++----
 include/linux/crc-t10dif.h | 3 ---
 2 files changed, 4 insertions(+), 7 deletions(-)
crypto/crct10dif_generic.c +4 -4
index 259cb01932cb5..fdfe78aba3ae0 100644
@@ -114,34 +114,34 @@ static int chksum_digest_arch(struct shash_desc *desc, const u8 *data,
 {
        return __chksum_finup_arch(0, data, length, out);
 }
 
 static struct shash_alg algs[] = {{
-       .digestsize             = CRC_T10DIF_DIGEST_SIZE,
+       .digestsize             = sizeof(u16),
        .init                   = chksum_init,
        .update                 = chksum_update,
        .final                  = chksum_final,
        .finup                  = chksum_finup,
        .digest                 = chksum_digest,
        .descsize               = sizeof(struct chksum_desc_ctx),
        .base.cra_name          = "crct10dif",
        .base.cra_driver_name   = "crct10dif-generic",
        .base.cra_priority      = 100,
-       .base.cra_blocksize     = CRC_T10DIF_BLOCK_SIZE,
+       .base.cra_blocksize     = 1,
        .base.cra_module        = THIS_MODULE,
 }, {
-       .digestsize             = CRC_T10DIF_DIGEST_SIZE,
+       .digestsize             = sizeof(u16),
        .init                   = chksum_init,
        .update                 = chksum_update_arch,
        .final                  = chksum_final,
        .finup                  = chksum_finup_arch,
        .digest                 = chksum_digest_arch,
        .descsize               = sizeof(struct chksum_desc_ctx),
        .base.cra_name          = "crct10dif",
        .base.cra_driver_name   = "crct10dif-" __stringify(ARCH),
        .base.cra_priority      = 150,
-       .base.cra_blocksize     = CRC_T10DIF_BLOCK_SIZE,
+       .base.cra_blocksize     = 1,
        .base.cra_module        = THIS_MODULE,
 }};
 
 static int num_algs;
 
include/linux/crc-t10dif.h +0 -3
index 16787c1cee21c..d0706544fc11f 100644
@@ -2,13 +2,10 @@
 #ifndef _LINUX_CRC_T10DIF_H
 #define _LINUX_CRC_T10DIF_H
 
 #include <linux/types.h>
 
-#define CRC_T10DIF_DIGEST_SIZE 2
-#define CRC_T10DIF_BLOCK_SIZE 1
-
 u16 crc_t10dif_arch(u16 crc, const u8 *p, size_t len);
 u16 crc_t10dif_generic(u16 crc, const u8 *p, size_t len);
 
 static inline u16 crc_t10dif_update(u16 crc, const u8 *p, size_t len)
 {

base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b --
2.48.1

author maintainer
#2 lore raw
Quoted 10 lines · Ard Biesheuvel
Quoted 9 lines · Eric Biggers

From: Eric Biggers <[email protected]>

These constants are only used in crypto/crct10dif_generic.c, and they are better off just hardcoded there.

---

Quoted 7 lines
Quoted 2 lines

I'm planning to take this via the crc tree.

Could you remind me why we are keeping this driver?

I don't know. I had to keep "crc32" and "crc32c" around for now because they are still used, and I just defaulted to doing the same for "crct10dif". It *looks like* "crct10dif" is different and we could indeed safely remove it like I ended up doing for "crc64-rocksoft", though. "crct10dif" has no remaining references in the kernel; it has no references in cryptsetup, iwd, or libell; and Debian Code Search doesn't find anything else. It's over a decade old, so I was worried there was time for users to have crept in, but that doesn't seem to have happened. So yeah, good idea. I'll send a patch that removes it, with the device-mapper folks Cc'd in case they know of anything else.

- Eric

#3 lore raw
Quoted 20 lines · Eric Biggers
Quoted 10 lines · Ard Biesheuvel
Quoted 9 lines · Eric Biggers

From: Eric Biggers <[email protected]>

These constants are only used in crypto/crct10dif_generic.c, and they are better off just hardcoded there.

---

Quoted 7 lines
Quoted 2 lines

I'm planning to take this via the crc tree.

Could you remind me why we are keeping this driver?

Quoted 10 lines

I don't know. I had to keep "crc32" and "crc32c" around for now because they are still used, and I just defaulted to doing the same for "crct10dif". It *looks like* "crct10dif" is different and we could indeed safely remove it like I ended up doing for "crc64-rocksoft", though. "crct10dif" has no remaining references in the kernel; it has no references in cryptsetup, iwd, or libell; and Debian Code Search doesn't find anything else. It's over a decade old, so I was worried there was time for users to have crept in, but that doesn't seem to have happened. So yeah, good idea. I'll send a patch that removes it, with the device-mapper folks Cc'd in case they know of anything else.

Good idea.