diff mbox series

Add LINUX_VERSION_SUBLEVEL to linux/version.h in LTS

Message ID 016f5ea6-f695-6994-c2ec-35cfef26058a@hauke-m.de (mailing list archive)
State New, archived
Headers show
Series Add LINUX_VERSION_SUBLEVEL to linux/version.h in LTS | expand

Commit Message

Hauke Mehrtens March 16, 2022, 11:15 p.m. UTC
Hi,

Upstream kernel commit 88a686728b37 ("kbuild: simplify access to the 
kernel's version") [0] extended the Makefile to add the following 
defines to the linux/version.h file:
#define LINUX_VERSION_MAJOR $(VERSION)
#define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL)
#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)

I would like to have these defines especially LINUX_VERSION_SUBLEVEL 
also in older stable kernel versions to make it easier for out of tree 
kernel code to detect which version it is compiling against.

In the Linux drivers backports project [1] we backport the current wifi 
driver to older Linux versions, so someone with an old kernel can use 
current wifi drivers. To make this work we have to know which kernel 
version it is being compiled against. The Makefile has access to the 
SUBLEVEL variable and can also forward it to the C code, but this does 
not work when someone compiles some other driver against the mac80211 
subsystem provided by backports for example.

I tried to cherry-pick commit 88a686728b37 to kernel 4.9, but it did not 
apply cleanly. Would it get accepted when I just port the changes in the 
main Makefile to the currently supported LTS kernel versions?

Hauke

[0]: https://git.kernel.org/linus/88a686728b3739d3598851e729c0e81f194e5c53
[1]: https://backports.wiki.kernel.org/index.php/Main_Page


Here would be my suggestion for kernel 4.9, I haven't tested this yet:
--
To unsubscribe from this list: send the line "unsubscribe backports" in

Comments

Greg KH March 17, 2022, 6:57 a.m. UTC | #1
On Thu, Mar 17, 2022 at 12:15:02AM +0100, Hauke Mehrtens wrote:
> Hi,
> 
> Upstream kernel commit 88a686728b37 ("kbuild: simplify access to the
> kernel's version") [0] extended the Makefile to add the following defines to
> the linux/version.h file:
> #define LINUX_VERSION_MAJOR $(VERSION)
> #define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL)
> #define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
> 
> I would like to have these defines especially LINUX_VERSION_SUBLEVEL also in
> older stable kernel versions to make it easier for out of tree kernel code
> to detect which version it is compiling against.
> 
> In the Linux drivers backports project [1] we backport the current wifi
> driver to older Linux versions, so someone with an old kernel can use
> current wifi drivers. To make this work we have to know which kernel version
> it is being compiled against. The Makefile has access to the SUBLEVEL
> variable and can also forward it to the C code, but this does not work when
> someone compiles some other driver against the mac80211 subsystem provided
> by backports for example.
> 
> I tried to cherry-pick commit 88a686728b37 to kernel 4.9, but it did not
> apply cleanly. Would it get accepted when I just port the changes in the
> main Makefile to the currently supported LTS kernel versions?
> 
> Hauke
> 
> [0]: https://git.kernel.org/linus/88a686728b3739d3598851e729c0e81f194e5c53
> [1]: https://backports.wiki.kernel.org/index.php/Main_Page
> 
> 
> Here would be my suggestion for kernel 4.9, I haven't tested this yet:
> --- a/Makefile
> +++ b/Makefile
> @@ -1142,7 +1142,10 @@ endef
>  define filechk_version.h
>  	(echo \#define LINUX_VERSION_CODE $(shell                         \
>  	expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \
> -	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
> +	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) \
> +	echo \#define LINUX_VERSION_MAJOR $(VERSION);                    \
> +	echo \#define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL);            \
> +	echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
>  endef
> 
>  $(version_h): $(srctree)/Makefile FORCE

We have been through this before, it is not needed.  See the archives
for the correct solution you should do in your out-of-tree code instead.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe backports" in
diff mbox series

Patch

--- a/Makefile
+++ b/Makefile
@@ -1142,7 +1142,10 @@  endef
  define filechk_version.h
  	(echo \#define LINUX_VERSION_CODE $(shell                         \
  	expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \
-	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
+	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) \
+	echo \#define LINUX_VERSION_MAJOR $(VERSION);                    \
+	echo \#define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL);            \
+	echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
  endef

  $(version_h): $(srctree)/Makefile FORCE