c - 错误: ‘struct tty_driver’ has no member named ‘ioctl’

标签 c linux-kernel linux-device-driver

我发现了类似的帖子,但找不到解决方案,所以我想发布我的问题。我正在使用设备驱动程序。我知道,下面的函数可以使用 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/

相关文章:

linux - 带有 _ 和 - 的内核模块名称?

linux - 使用 Linux 内核 call_usermodehelper 在用户模式下运行用户空间进程

c++ - 交换指针值

-std=c99 可以阻止我的#includes 正常工作吗?

linux-kernel - U-boot 起始地址?和 u-boot.imx 文件包含?

linux-kernel - 如何为 iMX6 sabre lite 板准备新的 SD 卡以运行 Linux

linux - 内核开发中是否有类似down_interruptible()的互斥量函数?

c++ - 我如何使用 C/C++ 获得对特定内存地址的 R/W 访问权限

objective-c - 如何在 OS X 上的 Objective C/C 中获取总 CPU 空闲时间?

c - 网络链接套接字