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.
Sam protsenko
source share