What is the difference between pci_enable_device and pcim_enable_device?

This PCI chapter book explains:

int pci_enable_device(struct pci_dev *dev); 

however also:

 int pcim_enable_device (struct pci_dev * pdev); 

But besides specifying " managed pci_enable_device , it has no explanation."

  • What is the difference between the two?
  • What does it mean that he is β€œcontrolled”?
  • Which should i use?
+7
linux-kernel linux-device-driver pci pci-e
source share
1 answer

pcim_enable_device() is the managed version of pci_enable_device() . This means that if you call pci_enable_device() , you also need to call pci_disable_device() at the end. In the case of pcim_enable_device() , the managed structure will take care of the disconnect for you.

In newer versions of the kernel, it is recommended that you use these managed functions to get rid of error handling in your driver code. See this article to get an idea of the device resource management (or devres ) API. This particular function ( pcim_enable_device ) was introduced in this patch . If you want to know more about the devres structure, see Documentation / driver-model / devres.txt

There is no explanation for managed functions in the book (Linux Device Drivers 3rd Edition) since it was written before these functions were implemented.

+11
source share

All Articles