LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   LKM for multiple kernel versions (https://www.linuxquestions.org/questions/linux-kernel-70/lkm-for-multiple-kernel-versions-888499/)

yaplej 06-26-2011 09:43 PM

LKM for multiple kernel versions
 
I have a kernel module that works for kernel versions < 2.6.20 but there were some changes in that version that cause it to break. I already know how to fix the code but in my source but how can I check the kernel version and swap the code? I dont want to just update the code because I still need it to work for both kernel versions.

Thanks.

yaplej 01-27-2012 01:10 PM

Just in case someone else needs to know I figured this out.

Code:

#if (LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 20))
/*
 *Code for kernel 2.6.20
 */
#else
/*
 *Code for all others
 */
#endif



All times are GMT -5. The time now is 01:25 PM.