mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
miscdevice: Add helper macro for misc device boilerplate
Many modules call misc_register and misc_deregister in its module init and exit methods without any additional code. This ends up being boilerplate. This patch adds helper macro module_misc_device(), that replaces module_init()/ module_exit() with template functions. This patch also converts drivers to use new macro. Change since v1: Add device.h include in miscdevice.h as module_driver macro was not available from other include files in some architectures. Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
832c8232dd
commit
ca75d601b5
7 changed files with 15 additions and 80 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <linux/major.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/device.h>
|
||||
|
||||
/*
|
||||
* These allocations are managed by device@lanana.org. If you use an
|
||||
|
@ -70,6 +71,13 @@ struct miscdevice {
|
|||
extern int misc_register(struct miscdevice *misc);
|
||||
extern void misc_deregister(struct miscdevice *misc);
|
||||
|
||||
/*
|
||||
* Helper macro for drivers that don't do anything special in module init / exit
|
||||
* call. This helps in eleminating of boilerplate code.
|
||||
*/
|
||||
#define module_misc_device(__misc_device) \
|
||||
module_driver(__misc_device, misc_register, misc_deregister)
|
||||
|
||||
#define MODULE_ALIAS_MISCDEV(minor) \
|
||||
MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \
|
||||
"-" __stringify(minor))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue