Re: writing driver code supporting multiple linux kernel versions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/10/05, kaustav.majumdar@xxxxxxxxx <kaustav.majumdar@xxxxxxxxx> wrote:
>
> Actually I want to write a single code using some macro to identify the
> kernel version and using preprocessor directives during preprocessing
> time which code snippet will be there, that I want to decide....
>
> Like
> #if UTS_RELEASE == 2.6.9
>         some code
> #elif UTS_RELEASE == 2.6.13
>         some code
> #endif
>
> can I do this
>

You can do this only at the compile time through the Macros

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
   some_code
#else
   some_code
#endif


And for doing this at the module loading time then you might do this
trick ... Take a string as a MODULE_PARAM in which you can get the
version of the kernel at the time time of loading of module can be
through script like insmod mymodule.o kernel_version=$(shell uname -r)




--
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux