git: 2c7aac44f5ab - stable/13 - linux(4): Use inlined LINUX_KERNVER for tests to improve readability

From: Dmitry Chagin <dchagin_at_FreeBSD.org>
Date: Thu, 29 Jun 2023 08:20:12 UTC
The branch stable/13 has been updated by dchagin:

URL: https://cgit.FreeBSD.org/src/commit/?id=2c7aac44f5abd751465d5bf854a9ef0f104c5ee0

commit 2c7aac44f5abd751465d5bf854a9ef0f104c5ee0
Author:     Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-04-26 13:57:30 +0000
Commit:     Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-06-29 08:15:28 +0000

    linux(4): Use inlined LINUX_KERNVER for tests to improve readability
    
    MFC after:              1 month
    
    (cherry picked from commit e185d83fc48ba0f28896a986104c02203005b533)
---
 sys/compat/linux/linux_elf.c    | 2 +-
 sys/compat/linux/linux_mib.h    | 6 ------
 sys/compat/linux/linux_misc.c   | 4 ++--
 sys/compat/linux/linux_signal.c | 2 +-
 4 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/sys/compat/linux/linux_elf.c b/sys/compat/linux/linux_elf.c
index 1af861122f81..06a384325d14 100644
--- a/sys/compat/linux/linux_elf.c
+++ b/sys/compat/linux/linux_elf.c
@@ -513,7 +513,7 @@ __linuxN(copyout_auxargs)(struct image_params *imgp, uintptr_t base)
 	 * is not present.
 	 * Also see linux_times() implementation.
 	 */
-	if (linux_kernver(curthread) >= LINUX_KERNVER_2004000)
+	if (linux_kernver(td) >= LINUX_KERNVER(2,4,0))
 		AUXARGS_ENTRY(pos, LINUX_AT_CLKTCK, stclohz);
 	AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
 	AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
diff --git a/sys/compat/linux/linux_mib.h b/sys/compat/linux/linux_mib.h
index 7022d811959b..5902f523dfee 100644
--- a/sys/compat/linux/linux_mib.h
+++ b/sys/compat/linux/linux_mib.h
@@ -57,12 +57,6 @@ int	linux_kernver(struct thread *td);
 #define	LINUX_XKERNVERSTR(x)	LINUX_KERNVERSTR(x)
 #define	LINUX_VERSION_STR	LINUX_XKERNVERSTR(LINUX_KVERSION.LINUX_KPATCHLEVEL.LINUX_KSUBLEVEL)
 
-#define	LINUX_KERNVER_2004000	LINUX_KERNVER(2,4,0)
-#define	LINUX_KERNVER_2006039	LINUX_KERNVER(2,6,39)
-#define	LINUX_KERNVER_5004000	LINUX_KERNVER(5,4,0)
-
-#define	linux_use54(t)		(linux_kernver(t) >= LINUX_KERNVER_5004000)
-
 extern int linux_debug;
 extern int linux_default_openfiles;
 extern int linux_default_stacksize;
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index bc62c6b24d2c..ba0ac190a946 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -384,7 +384,7 @@ struct l_times_argv {
 #define	CONVOTCK(r)	(r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK))
 #define	CONVNTCK(r)	(r.tv_sec * stclohz + r.tv_usec / (1000000 / stclohz))
 
-#define	CONVTCK(r)	(linux_kernver(td) >= LINUX_KERNVER_2004000 ?		\
+#define	CONVTCK(r)	(linux_kernver(td) >= LINUX_KERNVER(2,4,0) ?	\
 			    CONVNTCK(r) : CONVOTCK(r))
 
 int
@@ -850,7 +850,7 @@ linux_waitid(struct thread *td, struct linux_waitid_args *args)
 		idtype = P_PID;
 		break;
 	case LINUX_P_PGID:
-		if (linux_use54(td) && args->id == 0) {
+		if (linux_kernver(td) >= LINUX_KERNVER(5,4,0) && args->id == 0) {
 			p = td->td_proc;
 			PROC_LOCK(p);
 			id = p->p_pgid;
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
index 5a3cb97c385f..89f0f38d7b6c 100644
--- a/sys/compat/linux/linux_signal.c
+++ b/sys/compat/linux/linux_signal.c
@@ -776,7 +776,7 @@ lsiginfo_to_siginfo(struct thread *td, const l_siginfo_t *lsi,
 
 	switch (lsi->lsi_code) {
 	case LINUX_SI_TKILL:
-		if (linux_kernver(td) >= LINUX_KERNVER_2006039) {
+		if (linux_kernver(td) >= LINUX_KERNVER(2,6,39)) {
 			linux_msg(td, "SI_TKILL forbidden since 2.6.39");
 			return (EPERM);
 		}