Re: current->timeout

From: Rafael E. Herrera (raffo@neuronet.pitt.edu)
Date: Mon Apr 03 2000 - 14:46:16 EST


Paul Burkacki wrote:
>
> I am in the process of porting a char driver from
> kernel version 2.0.x to version 2.2.12. While building
> the driver against the new kernel, gcc tells me that
> "struct no longer has a member timeout" (this is struct
> current).
>
> I believe I found a code sample that shows how to deal
> with this build error however, I am wondering, where one
> would look for any kind of information that documents
> what happend to struct current between versions 2.0.x and
> 2.2.x?
>
> Also, I am wondering if there is a document that talks
> about how file_operations' select has been replaced by a
> poll.
>

I had a similar task before. These links are useful:

http://linux.oreilly.com/news/cox_0799.html
http://www.linux-mag.com/1999-06/gear_01.html
http://www.atnf.csiro.au/~rgooch/linux/docs/porting-to-2.2.html

There is a specific refference in R. Gooch's page to the removed
"timeout" member of the current structure. If you use it to implement a
timeout, the following can be used as an example (this also from Gooch's
page):

2.0.x:
        unsigned long timeout;
        ...
        current->timeout = jiffies + timeout;
        ...
        interruptible_sleep_on(&wait);

2.2.x:

        unsigned long timeout;
        ...
        timeout = interruptible_sleep_on_timeout(&wait,timeout);

Another thing to be careful about are the file operation methods.
They've changed, for example this is what I had to do:

2.0.x:

static int mydrvr_open(struct inode *, struct file *);
static void mydrvr_release(struct inode *, struct file *);
static int mydrvr_read(struct inode *, struct file *, char *, int);
static int mydrvr_write(struct inode *, struct file *, const char
*,);
static int mydrvr_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);
static void mydrvr_interrupt(int irq, void *dev_id, struct pt_regs *);

2.2.x:

static int mydrvr_open(struct inode *, struct file *);
static int mydrvr_release(struct inode *, struct file *);
static ssize_t mydrvr_read(struct file *, char *, size_t, loff_t *);
static ssize_t mydrvr_write(struct file *, const char *, size_t, loff_t
*);
static int mydrvr_ioctl(struct inode *, struct file *, unsigned int,
unsigned long);
static void mydrvr_interrupt(int , void *, struct pt_regs *);

I needed the minor number of the device. Since you get a struct file*
instead of a struct inode *, use something like:

static ssize_t mydrvr_write(struct file * file, const char * buffer,
                            size_t count, loff_t *ppos)
{
    minor_t ctrl;
    ctrl = MINOR(file->f_dentry->d_inode->i_rdev);
    ...
}

For changes related to select() read Cox's articles.

-- 
Rafael Herrera

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:10 EST