Open () returns with the error "There is no such device", but there is such a device (linux)

I'm trying to use some old DAQs, and I had to jump over several hoops to get the old (around 2004) device driver to compile it ( DTI-DT340 Linux-DAQ-PCI ).

I got to the point where it compiles, I can load the kernel module, it finds a map, and I can create personal devices using mknod.

But I can’t open these devices and keep getting errno 19 (ENODEV) “There is no such device” when I try

open("/dev/dt340/0",O_RDWR);

but mknod did not complain about its creation, and he is there:

# 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 that I neglect to do? What reason could be the cause of failure?

Here I use the script to load the driver and create 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]

:

#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

: , -ENODEV open().

while ((pdev = pci_find_device(PCI_VENDOR_ID_DTI, PCI_ANY_ID, pdev)))

( ), if(!pdev) true -ENODEV.

- , pci, ...

+5
4

/proc/devices, , mknod, . open() - " ", , .

+8

, , .

/proc/devices, .

+1

mknod , , / . , insmod ? lsmod?

".ko". - ?

0

lspci , . hotplug, pci_find_device . - refcnt. - API. BOL!!

0

All Articles