我正在尝试使用一款有些老旧的DAQ,并且不得不跳过一些障碍来编译一个旧的(大约是2004年)设备驱动程序(DTI-DT340 Linux-DAQ-PCI)。
我已经到了编译的阶段,可以加载内核模块,找到了卡片,并且可以使用mknod创建字符设备。
但是我似乎无法打开这些设备,并且在尝试时不断收到errno 19 (ENODEV) 'No such device'的错误提示。
open("/dev/dt340/0",O_RDWR);
但是mknod在创建它时没有任何投诉,它就在那里:
# ls -l /dev/dt340/
total 0
crw-rw-r-- 1 root staff 250, 0 2009-04-23 11:02 0
crw-rw-r-- 1 root staff 250, 1 2009-04-23 11:02 1
crw-rw-r-- 1 root staff 250, 2 2009-04-23 11:02 2
crw-rw-r-- 1 root staff 250, 3 2009-04-23 11:02 3
我有什么忽略的事情吗?打开失败的原因可能是什么?
这是我用来加载驱动程序和创建设备的脚本。
#!/bin/bash
module="dt340"
device="dt340"
mode="664"
# invoke modprobe with all arguments we were passed
#/sbin/modprobe -t misc -lroot -f -s $module.o $* || exit 1
insmod $module.ko
# remove stale nodes
rm -f /dev/${device}/[0-3]
major=`awk "\\$2==\"$module\" {print \\$1}" /proc/devices`
mkdir -p /dev/${device}
mknod /dev/${device}/0 c $major 0
mknod /dev/${device}/1 c $major 1
mknod /dev/${device}/2 c $major 2
mknod /dev/${device}/3 c $major 3
# give appropriate group/permissions, and change the group
# not all distributions have staff; some have "users" instead
group="staff"
grep '^staff:' /etc/group > /dev/null || group="users"
chgrp $group /dev/${device}/[0-3]
chmod $mode /dev/${device}/[0-3]
一些额外的信息:
#grep dt340 /proc/devices
250 dt340
# lsmod | grep dt340
dt340 21516 0
# tail /var/log/messages
Apr 23 11:59:26 ve kernel: [ 412.862139] dt340 0000:03:01.0: PCI INT A -> GSI 22 (level, low) -> IRQ 22
Apr 23 11:59:26 ve kernel: [ 412.862362] dt340: In function dt340_init_one:
Apr 23 11:59:26 ve kernel: [ 412.862363] Device DT340 Rev 0x0 detected at address 0xfebf0000
#lspci | grep 340
03:01.0 Multimedia controller: Data Translation DT340
答案:一个printk确认-ENODEV是从open()内部抛出的。遵循旧式
while ((pdev = pci_find_device(PCI_VENDOR_ID_DTI, PCI_ANY_ID, pdev)))
(已经过时),if(!pdev)
最终为真,返回-ENODEV。
我正在逐步接近 - 我想我必须通过更新pci代码来使用更现代的机制...