Hi,
I'm writing a custom PCI driver for some in-house hardware (porting across to Linux). I've gotten hold of "Linux Device Drivers 3rd edition" which covers everything I need, but I'm still having problems getting my driver off the ground.
Here is what I'm doing in the driver code:
(init entry point) (exported with module_init(...) macro)
* register_chrdev_region - allocate my major and minor numbers ok
* pci_register_driver - returns 0 (success), and my driver is visible in /sys/bus/pci/drivers
PCI probe function (included in pci_driver struct)
Checks that the pci_dev struct passed to it matches the custom hardware, and returns 0 on success. It enables the device using pci_enable_device.
PCI remove function (included in pci_driver struct)
Frees internal memory, then disables device with pci_disable_device.
Exit entry point (exported with module_exit(...) macro)
de-registers major/minor numbers using unregister_chrdev_region, then de-registers the driver using pci_unregister_driver.
I also export the pci_driver struct using the MODULE_DEVICE_TABLE(pci, custom_ids) macro.
I have a script that creates nodes in the /dev directory
mknod -m 666 /dev/customdevice c 104, 0
and I can see the device files. I can also see the device in /proc/devices (listed under character devices)
Unfortunately, when I call int fd = open("/dev/custom_device",0) from user space I get an error 6: No such device or address
What am I doing wrong/forgetting?
Many thanks