Backward Compatibility
Many parts of the device driver API covered in this chapter have changed between the major kernel releases. For those of you needing to make your driver work with Linux 2.0 or 2.2, here is a quick rundown of the differences you will encounter.
Wait Queues in Linux 2.2 and 2.0
A relatively small amount of the material in this chapter changed in the 2.3 development cycle. The one significant change is in the area of wait queues. The 2.2 kernel had a different and simpler implementation of wait queues, but it lacked some important features, such as exclusive sleeps. The new implementation of wait queues was introduced in kernel version 2.3.1.
The 2.2 wait queue implementation used variables of the type
struct wait_queue * instead of
wait_queue_head_t. This pointer had to be
initialized to NULL prior to its first use. A
typical declaration and initialization of a wait queue looked like
this:
struct wait_queue *my_queue = NULL;
The various functions for sleeping and waking up looked the same, with
the exception of the variable type for the queue itself. As a result,
writing code that works for all 2.x kernels is
easily done with a bit of code like the following, which is part of
the sysdep.h header we use to compile our sample
code.
# define DECLARE_WAIT_QUEUE_HEAD(head) struct wait_queue *head = NULL typedef struct wait_queue *wait_queue_head_t; # define init_waitqueue_head(head) (*(head)) = NULL
The synchronous versions of wake_up were added in 2.3.29, ...