tiny_tty模块在3.12.74内核编译时出现更多的错误以及兼容性问题,主要是新的内核要求tty驱动设置接口(struct tty_port),并且flip buffer在 tty_port 层实现,而不是原来的 tty_struct。
修正后的完整代码可以从链接下载:https://download.csdn.net/download/kingtj/10697459
一些错误可以参考2.6.32内核下编译问题,下面介绍不同的地方。
编译
warning: passing argument 1 of ‘tty_insert_flip_char’ from incompatible pointer type
需要为 tty_port 做相应修改,有几个要点:
- tty_port 结构需要调用 tty_port_init 进行初始化并与 tty_driver 捆绑起来(通过调用 tty_port_link_device 或 tty_port_register_device )
- 增加接口操作函数 tty_port_operations
- 在tty设备打开/关闭时调用 tty_port_open/close
- 模块退出时使用 tty_port_destroy 释放资源
大概修改如下:
struct tiny_serial {
struct tty_port *port; /* pointer to the tty port for this device */
...
};
static struct tty_port tiny_port[TINY_TTY_MINORS];
static void tiny_timer(unsigned long timer_data)
{
struct tiny_serial *tiny = (struct tiny_serial *)timer_data;
struct tty_port *port;
...
port = tiny->port;
for (i = 0; i < data_size; ++i) {
tty_insert_flip_char(port, data[i], TTY_NORMAL);
}
tty_flip_buffer_push(port);
}
static int tiny_activate(struct tty_port *port, struct tty_struct *tty)