Skip to content

Commit

Permalink
PNP: Add helper macro for pnp_register_driver boilerplate
Browse files Browse the repository at this point in the history
This patch introduces the module_pnp_driver macro which is a
convenience macro for PNP driver modules similar to module_pci_driver.
It is intended to be used by drivers which init/exit section does nothing
but register/unregister the PNP driver. By using this macro it is
possible to eliminate a few lines of boilerplate code per PNP driver.

Based on work done by Lars-Peter Clausen <lars@metafoo.de> for other
busses (i2c and spi) and Greg KH for PCI.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Peter Huewe authored and Rafael J. Wysocki committed Mar 18, 2015
1 parent 2eb1eb0 commit 95c0fd4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/linux/pnp.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,16 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { }

#endif /* CONFIG_PNP */

/**
* module_pnp_driver() - Helper macro for registering a PnP driver
* @__pnp_driver: pnp_driver struct
*
* Helper macro for PnP drivers which do not do anything special in module
* init/exit. This eliminates a lot of boilerplate. Each module may only
* use this macro once, and calling it replaces module_init() and module_exit()
*/
#define module_pnp_driver(__pnp_driver) \
module_driver(__pnp_driver, pnp_register_driver, \
pnp_unregister_driver)

#endif /* _LINUX_PNP_H */

0 comments on commit 95c0fd4

Please sign in to comment.