我发现了类似的帖子,但找不到解决方案,所以我想发布我的问题。我正在使用设备驱动程序。我知道,下面的函数可以使用 2.6 内核头文件成功编译,现在尝试使用“3.2.0-4-686-pae”(Debian)进行编译。我收到以下错误消息,
error: ‘struct tty_driver’ has no member named ‘ioctl’
error: ‘struct vc_data’ has no member named ‘vc_tty'
我检查了 tty_driver.h 中的“tty_driver”(包含在 tty.h 中),发现
int (*ioctl)(struct tty_struct *tty, struct file * file,
unsigned int cmd, unsigned long arg);
已定义,但不确定为什么会出现此错误。
此外,我无法在“console_struct.h”的“vc_data”中找到“vc_tty”,任何人都可以让我知道需要进行哪些更新才能使其与“3.2.0-4-”一起使用686-pae”?
#include <linux/tty.h>
#include <linux/console_struct.h>
struct tty_driver *my_driver;
static void my_func(unsigned long ptr)
{
/* Some code */
(my_driver->ioctl) (vc_cons[fg_console].d->vc_tty, NULL, KDSETLED,
*pstatus);
/* Some more code */
}
我没有在这里发布完整的代码,但如果需要的话我会发布的。如果您需要更多信息,请告诉我。
最佳答案
tty_driver
的“操作”在某个时刻被移至单独的 struct tty_operations *ops
成员,您会发现 ioctl
现在。
((my_driver->ops)->ioctl)(...);
对于struct vc_data
中的端口数据来说,同样的事情被移动到struct tty_port port
成员中。所以用这个代替:
vc_cons[fg_console].d->port.tty
通过搜索您收到的确切错误消息(一条一条),并查看您通常会找到的补丁和错误报告,您可以很容易地找到此类更改。对于像这样的简单事情,99% 的情况下它都会起作用。
然后您可以使用 Linux Cross Reference 等网站 Free Electrons在不同版本的标题之间导航并查找详细信息。 (例如,include/linux/console_struct.h
。)
关于c - 错误: ‘struct tty_driver’ has no member named ‘ioctl’ ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24978393/