Version dependency
Kernel interfaces change from kernel to kernel in that case modules need to be compatible with both versions of kernel.
The need for this occasionally arise.The header file < linux/version.h > contains the related macros.This header is automatically included by module.h.
LINUX_VERSION_CODE macro expands to the kernel version release number.E.g:the 2.6.10 kernel is represented as 132618(0x02060a).
KERNEL_VERSION(x,y,z) macro builds the integer corresponding to the given kernel version.
E.g:KERNEL_VERSION(2,6,10) will expand to 132618 that can be used to compare the kernel version.
This can be used with #ifdef to workaround the kernel related interface changes.
An example:
The usb_unlink_urb has been changed to usb_kill_urb with 2.6.10 kernel.(http://kerneltrap.org/files/ChangeLog-2.6.10 )
To handle this verson related change the above discussed macros can be used as in this code snippet:
#include < linux/version.h >
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)
usb_unlink_urb(bulk_out_urb);
#else
usb_kill_urb(bulk_out_urb);
#endif
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home