Page MenuHomeFreeBSD

LinuxKPI: add KERNEL_VERSION() macro
ClosedPublic

Authored by bz on Sun, Jun 14, 6:57 PM.
Tags
None
Referenced Files
F159765310: D57590.diff
Wed, Jun 17, 11:48 PM
Unknown Object (File)
Mon, Jun 15, 10:07 PM

Details

Summary

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

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bz requested review of this revision.Sun, Jun 14, 6:57 PM

What are the use cases for this macro?

I’m curious because of the relationship it could have with LINUXKPI_VERSION we define and compare in several places.

What are the use cases for this macro?

I’m curious because of the relationship it could have with LINUXKPI_VERSION we define and compare in several places.

LINUXKPI_VERSION we define "readable" as 70000; that's how I found it, that's how I kept doing it.

The equivalent would be LINUX_VERSION_CODE which uses the KERNEL_VERSION encoding.
So for an external driver which checks against KERNEL_VERSION() I have to define:

CFLAGS+=        -DLINUX_VERSION_CODE=458752     # 7.0.0

Don't ask me; that's the way it seems to be.

I should add; obviously if I define it as 0x70000 that would likely work too but seems less common (at least in the code I was looking at).

In D57590#1319911, @bz wrote:

I should add; obviously if I define it as 0x70000 that would likely work too but seems less common (at least in the code I was looking at).

So if I think it to the end, in theory LINUXKPI_VERSION should have been 0xNNNNN and not just NNNNN and we would almost be good.

Thanks for the explanation!

This revision is now accepted and ready to land.Mon, Jun 15, 7:56 AM
This revision was automatically updated to reflect the committed changes.