Skip to content

Commit b4eb6cd

Browse files
Paul Gortmakerbjorn-helgaas
Paul Gortmaker
authored andcommitted
PCI: Add builtin_pci_driver() to avoid registration boilerplate
In f309d44 ("platform_device: better support builtin boilerplate avoidance"), we introduced the builtin_driver() macro. Here we use that support and extend it to PCI driver registration, so where a driver is clearly non-modular and builtin-only, we can register it in a similar fashion. Existing code that is clearly non-modular can be updated with the simple mapping of module_pci_driver(...) ---> builtin_pci_driver(...) We've essentially cloned the former to make the latter, and taken out the remove/module_exit parts since those never get used in a non-modular build of the code. Signed-off-by: Paul Gortmaker <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 9222097 commit b4eb6cd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/pci.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,17 @@ void pci_unregister_driver(struct pci_driver *dev);
11921192
module_driver(__pci_driver, pci_register_driver, \
11931193
pci_unregister_driver)
11941194

1195+
/**
1196+
* builtin_pci_driver() - Helper macro for registering a PCI driver
1197+
* @__pci_driver: pci_driver struct
1198+
*
1199+
* Helper macro for PCI drivers which do not do anything special in their
1200+
* init code. This eliminates a lot of boilerplate. Each driver may only
1201+
* use this macro once, and calling it replaces device_initcall(...)
1202+
*/
1203+
#define builtin_pci_driver(__pci_driver) \
1204+
builtin_driver(__pci_driver, pci_register_driver)
1205+
11951206
struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
11961207
int pci_add_dynid(struct pci_driver *drv,
11971208
unsigned int vendor, unsigned int device,

0 commit comments

Comments
 (0)