c - Write a custom PCIe hotplug Linux 2.6.x driver -


I am writing a PCIE driver / module for a custom device, since the device is hot pluggable, it can disappear at any time is.

Here I can set the pci_driver structure:

  struct pci_driver my_pci_driver = {.name = "my_pci_driver", .id_table = Id, .probe = "my_pci_driver_probe", .remove = "my_pci_driver_remove"};  

But I do not know how to properly arrange the event to remove. When the .remove function is called, I have several processes which are opened with the driver and many are doing ioctl.

So what's the right way to remove the device? How can I safely wait for the current Iioctl running and then remove the device properly from my driver?

It is a very widespread question, you need to design a code that will support the removal of the device. You can take an example from any USB driver / usr / src / linux / drivers / usb / ... which is removable by nature.

Give feedback: No, it is not, the USB subsystem is not responsible for synchronizing your driver. There are several ways to synchronize the number of regiments, you can use the interlocked operation or use the spinlock or ...
A good description on Windows is primitives synonyms, terminology is slightly different but concepts Are the same, so I recommend.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -