唯客微博客

专注于计算机,嵌入式领域的技术

0%

Linux驱动开发杂记(0x18) - 内核tty接口各版本的变化(二)之tty_driver.h

Linux驱动开发杂记(0x18) - 内核tty接口各版本的变化(二)之tty_driver.h

2.6.17 - 2.6.18

删除

1
2
3
struct tty_driver {
const char *devfs_name;
}
## 2.6.19 - 2.6.20 修改
1
2
3
4
5
struct tty_operations {
void (*set_termios)(struct tty_struct *tty, struct termios * old);
//改为
void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct tty_driver {
struct termios init_termios; /* Initial termios */
//改为
struct ktermios init_termios; /* Initial termios */

struct termios **termios;
struct termios **termios_locked;
//改为
struct ktermios **termios;
struct ktermios **termios_locked;

void (*set_termios)(struct tty_struct *tty, struct termios * old);
//改为
void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
}
## 2.6.21 - 2.6.22 添加
1
2
3
4
struct tty_operations {
long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg);
}
1
2
3
4
struct tty_driver {
long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg);
}
## 2.6.25 - 2.6.26 添加
1
extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
1
2
3
struct tty_driver {
const struct tty_operations *ops;
}

修改

1
2
3
4
5
struct tty_operations {
void (*put_char)(struct tty_struct *tty, unsigned char ch);
//改为
int (*put_char)(struct tty_struct *tty, unsigned char ch);
}
1
2
3
4
struct tty_driver {
long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg);
}
删除
1
2
3
4
struct tty_operations {
int (*write_proc)(struct file *file, const char __user *buffer,
unsigned long count, void *data);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
struct tty_driver {
int (*open)(struct tty_struct * tty, struct file * filp);
void (*close)(struct tty_struct * tty, struct file * filp);
int (*write)(struct tty_struct * tty,
const unsigned char *buf, int count);
void (*put_char)(struct tty_struct *tty, unsigned char ch);
void (*flush_chars)(struct tty_struct *tty);
int (*write_room)(struct tty_struct *tty);
int (*chars_in_buffer)(struct tty_struct *tty);
int (*ioctl)(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg);
long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg);
void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
void (*throttle)(struct tty_struct * tty);
void (*unthrottle)(struct tty_struct * tty);
void (*stop)(struct tty_struct *tty);
void (*start)(struct tty_struct *tty);
void (*hangup)(struct tty_struct *tty);
void (*break_ctl)(struct tty_struct *tty, int state);
void (*flush_buffer)(struct tty_struct *tty);
void (*set_ldisc)(struct tty_struct *tty);
void (*wait_until_sent)(struct tty_struct *tty, int timeout);
void (*send_xchar)(struct tty_struct *tty, char ch);
int (*read_proc)(char *page, char **start, off_t off,
int count, int *eof, void *data);
int (*write_proc)(struct file *file, const char __user *buffer,
unsigned long count, void *data);
int (*tiocmget)(struct tty_struct *tty, struct file *file);
int (*tiocmset)(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear);
}

2.6.26 - 2.6.27

添加

1
2
3
struct tty_operations {
int (*resize)(struct tty_struct *tty, struct tty_struct *real_tty, struct winsize *ws);
}
修改
1
2
3
4
5
struct tty_operations {	
void (*break_ctl)(struct tty_struct *tty, int state);
//改为
int (*break_ctl)(struct tty_struct *tty, int state);
}

2.6.29 - 2.6.30

添加

1
2
3
4
5
6
7
struct tty_operations {
struct tty_struct * (*lookup)(struct tty_driver *driver, struct inode *inode, int idx);
int (*install)(struct tty_driver *driver, struct tty_struct *tty);
void (*remove)(struct tty_driver *driver, struct tty_struct *tty);
void (*shutdown)(struct tty_struct *tty);
int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew);
}
1
2
3
struct tty_driver {
struct kref kref; /* Reference management */
}

1
2
extern void tty_driver_kref_put(struct tty_driver *driver);
extern inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d);

删除

1
2
3
struct tty_driver {
int refcount; /* for loadable tty drivers */
}

2.6.28 - 2.6.29

修改

1
2
3
4
struct tty_operations {
int (*resize)(struct tty_struct *tty, struct tty_struct *real_tty, unsigned int rows, unsigned int cols);
int (*resize)(struct tty_struct *tty, struct winsize *ws);
}

2.6.29 - 2.6.30

添加

1
2
3
struct tty_operations {
const struct file_operations *proc_fops;
}
删除
1
2
3
4
struct tty_operations {
int (*read_proc)(char *page, char **start, off_t off, int count, int *eof, void *data);

}

2.6.31 - 2.6.32

添加

1
2
3
struct tty_operations {
void (*cleanup)(struct tty_struct *tty);
}

2.6.36 - 2.6.37

添加

1
2
3
struct tty_operations {
int (*get_icount)(struct tty_struct *tty, struct serial_icounter_struct *icount);
}
## 2.6.38 - 2.6.39 //修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct tty_operations {
int (*ioctl)(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg);
// 改为
int (*ioctl)(struct tty_struct *tty, unsigned int cmd, unsigned long arg);

long (*compat_ioctl)(struct tty_struct *tty, struct file * file,unsigned int cmd, unsigned long arg);
// 改为
long (*compat_ioctl)(struct tty_struct *tty,unsigned int cmd, unsigned long arg);

int (*tiocmget)(struct tty_struct *tty, struct file *file);
int (*tiocmset)(struct tty_struct *tty, struct file *file,unsigned int set, unsigned int clear);
// 改为
int (*tiocmget)(struct tty_struct *tty);
int (*tiocmset)(struct tty_struct *tty, unsigned int set, unsigned int clear);
}

3.2 - 3.3

删除

1
2
3
4
5
struct tty_driver {
......
struct ktermios **termios_locked;
......
}
## 3.3 - 3.4 删除
1
2
3
4
5
struct tty_driver {
......
int minor_num; /* number of *possible* devices */
......
}

3.6 - 3.7

添加

1
2
3
4
5
struct tty_driver {
......
struct tty_port **ports;
......
}

1
#define tty_alloc_driver(lines, flags)

修改

1
2
3
4
5
6
7
struct tty_driver {
......
struct cdev cdev;
// 改为
struct cdev *cdevs;
......
}

4.2 - 4.3

修改

1
2
3
4
5
6
7
struct tty_driver {
......
struct cdev *cdevs;
// 改为
struct cdev **cdevs;
......
}
## 4.5 - 4.6 修改
1
2
3
4
5
6
7
struct tty_operations {
......
struct tty_struct * (*lookup)(struct tty_driver *self, int idx);
// 改为
struct tty_struct * (*lookup)(struct tty_driver *self, struct file *, int idx);
......
}
1
2
struct tty_struct * (*lookup)(struct tty_driver *self, int idx)
struct tty_struct * (*lookup)(struct tty_driver *self, struct file *, int idx)

4.13 - 4.14

添加

1
2
3
4
5
struct tty_operations {
......
void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m);
......
}
## 4.17 - 4.18 添加
1
2
3
4
5
struct tty_operations {
......
int (*proc_show)(struct seq_file *, void *);
......
}
删除
1
2
3
4
5
struct tty_operations {
......
const struct file_operations *proc_fops;
......
}

4.19 - 4.20

添加

1
2
3
4
5
6
struct tty_operations {
......
int (*get_serial)(struct tty_struct *tty, struct serial_struct *p);
int (*set_serial)(struct tty_struct *tty, struct serial_struct *p);
......
}

-------------本文结束感谢您的阅读-------------

本文标题:Linux驱动开发杂记(0x18) - 内核tty接口各版本的变化(二)之tty_driver.h

文章作者:Vinx

发布时间:2019年02月19日 - 09:59

最后更新:2023年09月18日 - 11:11

原始链接:https://blog.vinkvin.com/post/24/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。