From 2669a340472e89a521ac6fbc803961124311453b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= <joanbrugueram@gmail.com>
Date: Fri, 19 Jul 2024 20:10:32 +0000
Subject: [PATCH] Exclude unused struct since Linux >= 6.5
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Since Linux >= 6.5 we don't need `struct ctl_table verbosity_ctl_root`,
only the sysctl path, so move it to a constant and exclude the struct.

This is just a cosmetic change, intended to make it clear that neither
the struct nor the sentinel that follows are needed on newer kernels.

Signed-off-by: Joan Bruguera Micó <joanbrugueram@gmail.com>
---
 ioctl.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/ioctl.c
+++ b/ioctl.c
@@ -1231,6 +1231,7 @@ cryptodev_deregister(void)
 }
 
 /* ====== Module init/exit ====== */
+static const char verbosity_ctl_path[] = "ioctl";
 static struct ctl_table verbosity_ctl_dir[] = {
 	{
 		.procname       = "cryptodev_verbosity",
@@ -1244,16 +1245,16 @@ static struct ctl_table verbosity_ctl_di
 #endif
 };
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0))
 static struct ctl_table verbosity_ctl_root[] = {
 	{
-		.procname       = "ioctl",
+		.procname       = verbosity_ctl_path,
 		.mode           = 0555,
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0))
 		.child          = verbosity_ctl_dir,
-#endif
 	},
 	{},
 };
+#endif
 static struct ctl_table_header *verbosity_sysctl_header;
 static int __init init_cryptodev(void)
 {
@@ -1274,7 +1275,7 @@ static int __init init_cryptodev(void)
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0))
 	verbosity_sysctl_header = register_sysctl_table(verbosity_ctl_root);
 #else
-	verbosity_sysctl_header = register_sysctl(verbosity_ctl_root->procname, verbosity_ctl_dir);
+	verbosity_sysctl_header = register_sysctl(verbosity_ctl_path, verbosity_ctl_dir);
 #endif
 
 	pr_info(PFX "driver %s loaded.\n", VERSION);
