backports.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Add LINUX_VERSION_SUBLEVEL to linux/version.h in LTS
@ 2022-03-16 23:15 Hauke Mehrtens
  2022-03-17  6:57 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Hauke Mehrtens @ 2022-03-16 23:15 UTC (permalink / raw)
  To: stable, Sasha Levin; +Cc: Johannes Berg, backports, Jiaxun Yang

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
--
To unsubscribe from this list: send the line "unsubscribe backports" in

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Add LINUX_VERSION_SUBLEVEL to linux/version.h in LTS
  2022-03-16 23:15 Add LINUX_VERSION_SUBLEVEL to linux/version.h in LTS Hauke Mehrtens
@ 2022-03-17  6:57 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2022-03-17  6:57 UTC (permalink / raw)
  To: Hauke Mehrtens; +Cc: stable, Sasha Levin, Johannes Berg, backports, Jiaxun Yang

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-17  6:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 23:15 Add LINUX_VERSION_SUBLEVEL to linux/version.h in LTS Hauke Mehrtens
2022-03-17  6:57 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).