Backports Archive mirror
 help / color / mirror / Atom feed
From: Hauke Mehrtens <hauke@hauke-m.de>
To: stable <stable@vger.kernel.org>, Sasha Levin <sashal@kernel.org>
Cc: Johannes Berg <johannes@sipsolutions.net>,
	"backports@vger.kernel.org" <backports@vger.kernel.org>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: Add LINUX_VERSION_SUBLEVEL to linux/version.h in LTS
Date: Thu, 17 Mar 2022 00:15:02 +0100	[thread overview]
Message-ID: <016f5ea6-f695-6994-c2ec-35cfef26058a@hauke-m.de> (raw)

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

             reply	other threads:[~2022-03-16 23:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16 23:15 Hauke Mehrtens [this message]
2022-03-17  6:57 ` Add LINUX_VERSION_SUBLEVEL to linux/version.h in LTS Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=016f5ea6-f695-6994-c2ec-35cfef26058a@hauke-m.de \
    --to=hauke@hauke-m.de \
    --cc=backports@vger.kernel.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=johannes@sipsolutions.net \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).