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

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

      reply	other threads:[~2022-03-17  6:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=YjLbvZq780tHNyjG@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=backports@vger.kernel.org \
    --cc=hauke@hauke-m.de \
    --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 NNTP newsgroup(s).