git: c5d6e2085a47 - main - LinuxKPI: add KERNEL_VERSION() macro

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Mon, 15 Jun 2026 14:14:34 UTC
The branch main has been updated by bz:

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

commit c5d6e2085a471cbb75cc7b88b37a2fe6276c16f8
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-06-13 11:08:00 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-06-15 14:14:19 +0000

    LinuxKPI: add KERNEL_VERSION() macro
    
    Add a KERNEL_VERSION() macro which normally would be in linux/version.h.
    On Linux that file is auto-generated and we are supporting more than
    one Linux version in LinuxKPI anyway so any further defines in there
    would likely be wrong.
    
    Adding the macro helps to support (vendor/out of tree) drivers more
    easily which are supporting multiple Linux versions.
    
    MFC after:      3 days
    Reviewed by:    dumbbell
    Differential Revision: https://reviews.freebsd.org/D57590
---
 sys/compat/linuxkpi/common/include/linux/kernel.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
index afbd9208a410..3fcc6c1a925e 100644
--- a/sys/compat/linuxkpi/common/include/linux/kernel.h
+++ b/sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -67,6 +67,9 @@
 
 #include <linux/stdarg.h>
 
+#define	KERNEL_VERSION(a,b,c)						\
+    (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))
+
 #define KERN_CONT       ""
 #define	KERN_EMERG	"<0>"
 #define	KERN_ALERT	"<1>"