如何从另一个驱动程序“调用”驱动程序ioctl?

时间:2019-07-09 11:32:47

标签: driver tty uart

用户空间程序可以使用ioctl调用来修改串行端口/ UART的RTS引脚。例如:

int RTS_flag = TIOCM_RTS;
ioctl(fd, TIOCMBIS, &RTS_flag);
ioctl(fd, TIOCMBIC, &RTS_flag);

假设我想从驱动程序控制RTS引脚。是否可以“呼叫”拿着tty的驾驶员,并要求它为我控制销? (而不是找出特定设备的控制寄存器并读取/写入字节,更不用说立即支持内核驱动程序支持的所有UART芯片了。)

解决这个问题的正确方法是什么?

例如,在myDriver中:

static const struct file_operations ecp_fileOps =
{
    .owner          = THIS_MODULE,
    .unlocked_ioctl = my_ioctl,
    .write      = 0,  
    .read       = 0,
    .poll       = 0,
    .open       = lirc_dev_fop_open,
    .release    = lirc_dev_fop_close,
    .llseek     = no_llseek,
};

static long ecp_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
{
    switch (cmd)
    {
        "Call" tty ioctl function...
    }
}

操作系统信息

# uname -a
Linux ecp 4.4.127-1.el6.elrepo.i686 #1 SMP Sun Apr 8 09:44:43 EDT 2018 i686 i686 i386 GNU/Linux
# cat /etc/centos-release
CentOS release 6.6 (Final)

0 个答案:

没有答案
相关问题