I'm trying to use a somewhat old DAQ, and had to jump through a few hoops to get an old (circa 2004) device driver for it to compile (DTI-DT340 Linux-DAQ-PCI).
我正在尝试使用一个有点旧的DAQ,并且必须跳过几个箍以获得一个旧的(circa 2004)设备驱动程序来编译(DTI-DT340 Linux-DAQ-PCI)。
I've gotten to the point where it compiles, I can load the the kernel module, it finds the card, and I can create the character devices using mknod.
我已经达到了编译的目的,我可以加载内核模块,它找到了card,我可以使用mknod创建字符设备。
But I can't seem to open these devices and keep getting errno 19 (ENODEV) 'No such device' when I try to
但我似乎无法打开这些设备,并不断地获取errno 19 (ENODEV)当我尝试的时候,没有这样的装置。
open("/dev/dt340/0",O_RDWR);
but mknod had no complaints about making it, and it's there:
但是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
Is there something I'm neglecting to do? What might be a reason open fails?
有什么事情是我没注意到的吗?什么可能是开放失败的原因?
Here's the script I use to load the driver and make the devices.
下面是我用来加载驱动程序和制作设备的脚本。
#!/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]
Some additional info:
一些额外的信息:
#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
ANSWER: A printk confirmed that the -ENODEV was thrown from inside open(). Following an oldstyle
答:printk确认了-ENODEV是从内部打开的()。oldstyle之后
while ((pdev = pci_find_device(PCI_VENDOR_ID_DTI, PCI_ANY_ID, pdev)))
(which is deprecated), if(!pdev)
ends up true, and returns the -ENODEV.
如果(!pdev)结束true,并返回-ENODEV。
I'm inching closer - I guess I have to work through and update the pci code to use more modern mechanisms...
我正在慢慢地接近——我想我必须通过和更新pci代码来使用更多的现代机制……
4 个解决方案
#1
8
If the device shows up in /proc/devices, and you're sure you've got the number right in mknod, then the driver itself is refusing the open. The driver can return any error code from open() - including "no such device", which it might if it discovered a problem initialising the hardware.
如果设备出现在/proc/设备中,并且您确信在mknod中有正确的数字,那么驱动程序本身拒绝打开。驱动程序可以从open()中返回任何错误代码——包括“没有这样的设备”,如果它发现了初始化硬件的问题,它可能会返回。
#2
1
I'd guess it is a problem in the driver, check the open function.
我猜这是司机的一个问题,检查打开的功能。
It shows up in /proc/devices, so all the generic device stuff seems to be ok.
它显示在/proc/devices中,所以所有的通用设备似乎都没问题。
#3
0
mknod doesn't care if there is an device corresponding to the given major/minor numbers. Are you sure insmod is installing your module? What does lsmod tell you?
mknod不关心是否有一个设备对应于给定的主要/次要数字。你确定insmod正在安装你的模块吗?lsmod告诉你什么?
I'm unfamiliar with having to add the ".ko" extension. Is that something specific to your device driver?
我不熟悉必须添加“。ko”扩展。这是你的设备驱动程序特有的吗?
#4
0
Check through lspci and make sure hardware is properly initialized. If your system supports hotplug, pci_find_device won't work. The problem with this is a refcnt. The best way to deal and learn is to dissect the API. BOL !!
检查lspci并确保正确初始化硬件。如果您的系统支持热插拔,那么pci_find_device将不起作用。这个问题是refcnt。处理和学习的最好方法是剖析API。波尔! !
#1
8
If the device shows up in /proc/devices, and you're sure you've got the number right in mknod, then the driver itself is refusing the open. The driver can return any error code from open() - including "no such device", which it might if it discovered a problem initialising the hardware.
如果设备出现在/proc/设备中,并且您确信在mknod中有正确的数字,那么驱动程序本身拒绝打开。驱动程序可以从open()中返回任何错误代码——包括“没有这样的设备”,如果它发现了初始化硬件的问题,它可能会返回。
#2
1
I'd guess it is a problem in the driver, check the open function.
我猜这是司机的一个问题,检查打开的功能。
It shows up in /proc/devices, so all the generic device stuff seems to be ok.
它显示在/proc/devices中,所以所有的通用设备似乎都没问题。
#3
0
mknod doesn't care if there is an device corresponding to the given major/minor numbers. Are you sure insmod is installing your module? What does lsmod tell you?
mknod不关心是否有一个设备对应于给定的主要/次要数字。你确定insmod正在安装你的模块吗?lsmod告诉你什么?
I'm unfamiliar with having to add the ".ko" extension. Is that something specific to your device driver?
我不熟悉必须添加“。ko”扩展。这是你的设备驱动程序特有的吗?
#4
0
Check through lspci and make sure hardware is properly initialized. If your system supports hotplug, pci_find_device won't work. The problem with this is a refcnt. The best way to deal and learn is to dissect the API. BOL !!
检查lspci并确保正确初始化硬件。如果您的系统支持热插拔,那么pci_find_device将不起作用。这个问题是refcnt。处理和学习的最好方法是剖析API。波尔! !