On 3/7/24 01:37, John Garry wrote:
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index acf0592d63da..5bac3b5aa5fa 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -3471,6 +3471,7 @@ static bool comp_write_worker(struct
sdeb_store_info *sip, u64 lba, u32 num,
return res;
}
+#if (IS_ENABLED(CONFIG_CRC_T10DIF))
static __be16 dif_compute_csum(const void *buf, int len)
{
__be16 csum;
@@ -3509,6 +3510,13 @@ static int dif_verify(struct t10_pi_tuple *sdt,
const void *data,
}
return 0;
}
+#else
+static int dif_verify(struct t10_pi_tuple *sdt, const void *data,
+ sector_t sector, u32 ei_lba)
+{
+ return -EOPNOTSUPP;
+}
+#endif
static void dif_copy_prot(struct scsi_cmnd *scp, sector_t sector,
unsigned int sectors, bool read)
@@ -7421,7 +7429,12 @@ static int __init scsi_debug_init(void)
case T10_PI_TYPE1_PROTECTION:
case T10_PI_TYPE2_PROTECTION:
case T10_PI_TYPE3_PROTECTION:
+ #if (IS_ENABLED(CONFIG_CRC_T10DIF))
have_dif_prot = true;
+ #else
+ pr_err("CRC_T10DIF not enabled\n");
+ return -EINVAL;
+ #endif
break;
default:
----8<-----
I know that IS_ENABLED(CONFIG_XXX)) ain't too nice to use, but this is a
lot less change and we also don't need multiple files for the driver. As
below, it's not easy to separate the CRC_T10DIF-related stuff out.
The above suggestion violates the following rule from the Linux kernel
coding style: "As a general rule, #ifdef use should be confined to
header files whenever possible." See also
Documentation/process/4.Coding.rst.
The approach to use multiple files in order to avoid #ifdefs in .c files
is strongly preferred in Linux kernel code.
Thanks,
Bart.