2

I am porting a v4l2 driver from kernel 4.4 to 4.9. In 4.4 kernel, we are using type and group_id for enumerating media entity. But group_id is obsolete in kernel 4.9. I want to have same user space code for both kernel versions.

Is there any way to identify kernel version at compile time or run time. I will prefer to have compile time check.

struct media_entity_desc This is same for both kernel versions, but on 4.9 group_id will always contains 0.

struct media_entity on 4.9

struct media_entity on 4.4

Thanks in advance.

  • Possible duplicate of [Is there a macro definition to check the Linux kernel version?](https://stackoverflow.com/questions/16721346/is-there-a-macro-definition-to-check-the-linux-kernel-version) – Tsyvarev Dec 28 '17 at 19:37
  • @Tsyvarev [This](https://stackoverflow.com/questions/16721346/is-there-a-macro-definition-to-check-the-linux-kernel-version) does not allow me to differentiate b/w 4.4 and 4.9. – Trishansh Bhardwaj Dec 29 '17 at 11:56
  • What exactly do you use? (The accepted answer suggests several approaches.) Why it don't help? Note, that macro LINUX_VERSION_CODE contains version of the kernel against which libc has been compiled, not the current kernel version. – Tsyvarev Dec 29 '17 at 15:11

0 Answers0