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:

committed by
Greg Kroah-Hartman

parent
832c8232dd
commit
ca75d601b5
@@ -126,21 +126,4 @@ static struct miscdevice sclp_ctl_device = {
|
||||
.name = "sclp",
|
||||
.fops = &sclp_ctl_fops,
|
||||
};
|
||||
|
||||
/*
|
||||
* Register sclp_ctl misc device
|
||||
*/
|
||||
static int __init sclp_ctl_init(void)
|
||||
{
|
||||
return misc_register(&sclp_ctl_device);
|
||||
}
|
||||
module_init(sclp_ctl_init);
|
||||
|
||||
/*
|
||||
* Deregister sclp_ctl misc device
|
||||
*/
|
||||
static void __exit sclp_ctl_exit(void)
|
||||
{
|
||||
misc_deregister(&sclp_ctl_device);
|
||||
}
|
||||
module_exit(sclp_ctl_exit);
|
||||
module_misc_device(sclp_ctl_device);
|
||||
|
Reference in New Issue
Block a user