1

I am trying to fix a driver that references d_alias or d_u.d_alias in kernel 3.16.0-69. The macro looks for the kernel versions and uses the appropriate one.

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) || LINUX_VERSION_CODE == KERNEL_VERSION(3,12,49) || LINUX_VERSION_CODE == KERNEL_VERSION(3,16,67)
    //946e51f2bf37f1656916eb75bd0742ba33983c28, move d_rcu from overlapping d_child to overlapping d_alias;
    //SLES 12.1 (3.12.49) back port it too
    dentry = hlist_entry(p, struct dentry, d_u.d_alias);
#else
    dentry = hlist_entry(p, struct dentry, d_alias);
#endif

The problem i am having is that if I use KERNEL_VERSION(3,16,0) it works for 3.16.0-69 but breaks for 3.16.0-30. How can i reference the bugfix part of the kernel, the 69 or 30 in this example. I have tried this and it does not work.

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0-31) || LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) || LINUX_VERSION_CODE == KERNEL_VERSION(3,12,49) || LINUX_VERSION_CODE == KERNEL_VERSION(3,16,67)

I am trying to fix this properly as I have to maintain this until the vendor fixes it.

4
  • 0-69 is -69, the values are integers. You can't compare versions that small with this macro Commented Apr 17, 2016 at 13:05
  • getting-kernel-version-from-linux-kernel-module-at-runtime led me to do the following. (LINUX_VERSION_CODE >= KERNEL_VERSION(3,16,0) && UTS_UBUNTU_RELEASE_ABI > 30). Not sure if that is the best way Commented Apr 17, 2016 at 13:15
  • Does it have to be done at compile time? Commented Apr 18, 2016 at 7:00
  • If you need to do it at compile time (rather than some autoconf hack, for example), you'll need some distro-specific tests as @stephenc01 mentioned. As near as I can work out, the fix is included in kernel version >= 3.18.1 || version >= 3.12.37 && version < 3.13.0 || version >= 3.14.40 && version < 3.15.0 || version == 3.16.7 && UTS_UBUNTU_RELEASE_ABI >= 31. Commented Apr 18, 2016 at 17:02

1 Answer 1

3

Based on the comments

(LINUX_VERSION_CODE == KERNEL_VERSION(3,16,0) && UTS_UBUNTU_RELEASE_ABI > 30) 

would answer my question.

I had to also add add

#include <generated/utsrelease.h>. 

One downside is that the patch level is unique to the distribution. i.e. Ubuntu in this example

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.