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.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
stephenc01
  • 43
  • 8
  • `0-69` is `-69`, the values are integers. You can't compare versions that small with this macro – Sami Kuhmonen Apr 17 '16 at 13:05
  • [getting-kernel-version-from-linux-kernel-module-at-runtime](http://stackoverflow.com/questions/8030758/getting-kernel-version-from-linux-kernel-module-at-runtime/8030951#8030951) 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 – stephenc01 Apr 17 '16 at 13:15
  • Does it have to be done at compile time? – Harry Apr 18 '16 at 07: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. – Ian Abbott Apr 18 '16 at 17:02

1 Answers1

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

stephenc01
  • 43
  • 8