diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-18 13:12:49 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-02-09 11:36:05 -0500 |
commit | aad4f4000cecec9c80b5f9aff91043dc104d61a0 (patch) | |
tree | 26fcb531c54106ccf6548a156c2bb42f667fec9f /include/linux/pci.h | |
parent | e250b34e57888ebe829a0b89cfa8ad303ad5ae74 (diff) |
PCI: Add helper macro for pci_register_driver boilerplate
This patch introduces the module_pci_driver macro which is a convenience
macro for PCI driver modules similar to module_platform_driver. It is
intended to be used by drivers which init/exit section does nothing but
register/unregister the PCI driver. By using this macro it is possible
to eliminate a few lines of boilerplate code per PCI driver.
Based on work done by Lars-Peter Clausen <lars@metafoo.de> for other
busses (i2c and spi).
Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r-- | include/linux/pci.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h index a16b1df3deff..d4afd703e948 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -946,6 +946,19 @@ int __must_check __pci_register_driver(struct pci_driver *, struct module *, | |||
946 | __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) | 946 | __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME) |
947 | 947 | ||
948 | void pci_unregister_driver(struct pci_driver *dev); | 948 | void pci_unregister_driver(struct pci_driver *dev); |
949 | |||
950 | /** | ||
951 | * module_pci_driver() - Helper macro for registering a PCI driver | ||
952 | * @__pci_driver: pci_driver struct | ||
953 | * | ||
954 | * Helper macro for PCI drivers which do not do anything special in module | ||
955 | * init/exit. This eliminates a lot of boilerplate. Each module may only | ||
956 | * use this macro once, and calling it replaces module_init() and module_exit() | ||
957 | */ | ||
958 | #define module_pci_driver(__pci_driver) \ | ||
959 | module_driver(__pci_driver, pci_register_driver, \ | ||
960 | pci_unregister_driver) | ||
961 | |||
949 | void pci_remove_behind_bridge(struct pci_dev *dev); | 962 | void pci_remove_behind_bridge(struct pci_dev *dev); |
950 | struct pci_driver *pci_dev_driver(const struct pci_dev *dev); | 963 | struct pci_driver *pci_dev_driver(const struct pci_dev *dev); |
951 | int pci_add_dynid(struct pci_driver *drv, | 964 | int pci_add_dynid(struct pci_driver *drv, |