File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,16 +56,4 @@ static struct miscdevice bL_switcher_device = {
5656 "b.L_switcher" ,
5757 & bL_switcher_fops
5858};
59-
60- static int __init bL_switcher_dummy_if_init (void )
61- {
62- return misc_register (& bL_switcher_device );
63- }
64-
65- static void __exit bL_switcher_dummy_if_exit (void )
66- {
67- misc_deregister (& bL_switcher_device );
68- }
69-
70- module_init (bL_switcher_dummy_if_init );
71- module_exit (bL_switcher_dummy_if_exit );
59+ module_misc_device (bL_switcher_device );
Original file line number Diff line number Diff line change @@ -59,18 +59,7 @@ static struct miscdevice coreb_dev = {
5959 .name = "coreb" ,
6060 .fops = & coreb_fops ,
6161};
62-
63- static int __init bf561_coreb_init (void )
64- {
65- return misc_register (& coreb_dev );
66- }
67- module_init (bf561_coreb_init );
68-
69- static void __exit bf561_coreb_exit (void )
70- {
71- misc_deregister (& coreb_dev );
72- }
73- module_exit (bf561_coreb_exit );
62+ module_misc_device (coreb_dev );
7463
7564MODULE_AUTHOR ("Bas Vermeulen <bvermeul@blackstar.xs4all.nl>" );
7665MODULE_DESCRIPTION ("BF561 Core B Support" );
Original file line number Diff line number Diff line change @@ -779,19 +779,8 @@ static struct miscdevice uhid_misc = {
779779 .minor = UHID_MINOR ,
780780 .name = UHID_NAME ,
781781};
782+ module_misc_device (uhid_misc );
782783
783- static int __init uhid_init (void )
784- {
785- return misc_register (& uhid_misc );
786- }
787-
788- static void __exit uhid_exit (void )
789- {
790- misc_deregister (& uhid_misc );
791- }
792-
793- module_init (uhid_init );
794- module_exit (uhid_exit );
795784MODULE_LICENSE ("GPL" );
796785MODULE_AUTHOR ("David Herrmann <dh.herrmann@gmail.com>" );
797786MODULE_DESCRIPTION ("User-space I/O driver support for HID subsystem" );
Original file line number Diff line number Diff line change @@ -1013,23 +1013,12 @@ static struct miscdevice uinput_misc = {
10131013 .minor = UINPUT_MINOR ,
10141014 .name = UINPUT_NAME ,
10151015};
1016+ module_misc_device (uinput_misc );
1017+
10161018MODULE_ALIAS_MISCDEV (UINPUT_MINOR );
10171019MODULE_ALIAS ("devname:" UINPUT_NAME );
10181020
1019- static int __init uinput_init (void )
1020- {
1021- return misc_register (& uinput_misc );
1022- }
1023-
1024- static void __exit uinput_exit (void )
1025- {
1026- misc_deregister (& uinput_misc );
1027- }
1028-
10291021MODULE_AUTHOR ("Aristeu Sergio Rozanski Filho" );
10301022MODULE_DESCRIPTION ("User level driver support for input subsystem" );
10311023MODULE_LICENSE ("GPL" );
10321024MODULE_VERSION ("0.3" );
1033-
1034- module_init (uinput_init );
1035- module_exit (uinput_exit );
Original file line number Diff line number Diff line change @@ -126,21 +126,4 @@ static struct miscdevice sclp_ctl_device = {
126126 .name = "sclp" ,
127127 .fops = & sclp_ctl_fops ,
128128};
129-
130- /*
131- * Register sclp_ctl misc device
132- */
133- static int __init sclp_ctl_init (void )
134- {
135- return misc_register (& sclp_ctl_device );
136- }
137- module_init (sclp_ctl_init );
138-
139- /*
140- * Deregister sclp_ctl misc device
141- */
142- static void __exit sclp_ctl_exit (void )
143- {
144- misc_deregister (& sclp_ctl_device );
145- }
146- module_exit (sclp_ctl_exit );
129+ module_misc_device (sclp_ctl_device );
Original file line number Diff line number Diff line change @@ -322,18 +322,7 @@ static struct miscdevice vhost_test_misc = {
322322 "vhost-test" ,
323323 & vhost_test_fops ,
324324};
325-
326- static int vhost_test_init (void )
327- {
328- return misc_register (& vhost_test_misc );
329- }
330- module_init (vhost_test_init );
331-
332- static void vhost_test_exit (void )
333- {
334- misc_deregister (& vhost_test_misc );
335- }
336- module_exit (vhost_test_exit );
325+ module_misc_device (vhost_test_misc );
337326
338327MODULE_VERSION ("0.0.1" );
339328MODULE_LICENSE ("GPL v2" );
Original file line number Diff line number Diff line change 33#include <linux/major.h>
44#include <linux/list.h>
55#include <linux/types.h>
6+ #include <linux/device.h>
67
78/*
89 * These allocations are managed by device@lanana.org. If you use an
@@ -70,6 +71,13 @@ struct miscdevice {
7071extern int misc_register (struct miscdevice * misc );
7172extern void misc_deregister (struct miscdevice * misc );
7273
74+ /*
75+ * Helper macro for drivers that don't do anything special in module init / exit
76+ * call. This helps in eleminating of boilerplate code.
77+ */
78+ #define module_misc_device (__misc_device ) \
79+ module_driver(__misc_device, misc_register, misc_deregister)
80+
7381#define MODULE_ALIAS_MISCDEV (minor ) \
7482 MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \
7583 "-" __stringify(minor))
You can’t perform that action at this time.
0 commit comments