LDD3: tiny_tty模块编译和测试(3.12.x内核)

本文档介绍了在3.12.74内核中编译和测试tiny_tty模块时遇到的兼容性问题,主要涉及到tty_port结构的初始化和接口变更。内容包括对tty_port_init、tty_port_link_device等函数的修改,以适配新内核的要求。提供了一个修正后的代码链接,并详细说明了编译过程中的关键修改。测试结果显示模块已成功编译并安装。
摘要由CSDN通过智能技术生成

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 做相应修改,有几个要点:

  1. tty_port 结构需要调用 tty_port_init 进行初始化并与 tty_driver 捆绑起来(通过调用 tty_port_link_devicetty_port_register_device
  2. 增加接口操作函数 tty_port_operations
  3. 在tty设备打开/关闭时调用 tty_port_open/close
  4. 模块退出时使用 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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值