diff options
| author | PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com> | 2016-08-25 13:00:49 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-08-31 08:12:35 -0400 |
| commit | ca75d601b5942e8cf5eed68f308be0526d0dac5d (patch) | |
| tree | ca411c99f5715a5976eb942a061dfa3b2b6e841d /drivers | |
| parent | 832c8232dd7be4977ae9fb9c7cbc4decce19a8fc (diff) | |
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>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/hid/uhid.c | 13 | ||||
| -rw-r--r-- | drivers/input/misc/uinput.c | 15 | ||||
| -rw-r--r-- | drivers/s390/char/sclp_ctl.c | 19 | ||||
| -rw-r--r-- | drivers/vhost/test.c | 13 |
4 files changed, 5 insertions, 55 deletions
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c index 99ec3ff7563b..7f8ff39ed44b 100644 --- a/drivers/hid/uhid.c +++ b/drivers/hid/uhid.c | |||
| @@ -779,19 +779,8 @@ static struct miscdevice uhid_misc = { | |||
| 779 | .minor = UHID_MINOR, | 779 | .minor = UHID_MINOR, |
| 780 | .name = UHID_NAME, | 780 | .name = UHID_NAME, |
| 781 | }; | 781 | }; |
| 782 | module_misc_device(uhid_misc); | ||
| 782 | 783 | ||
| 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); | ||
| 795 | MODULE_LICENSE("GPL"); | 784 | MODULE_LICENSE("GPL"); |
| 796 | MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>"); | 785 | MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>"); |
| 797 | MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem"); | 786 | MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem"); |
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 65ebbd111702..92595b98e7ed 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
| @@ -1013,23 +1013,12 @@ static struct miscdevice uinput_misc = { | |||
| 1013 | .minor = UINPUT_MINOR, | 1013 | .minor = UINPUT_MINOR, |
| 1014 | .name = UINPUT_NAME, | 1014 | .name = UINPUT_NAME, |
| 1015 | }; | 1015 | }; |
| 1016 | module_misc_device(uinput_misc); | ||
| 1017 | |||
| 1016 | MODULE_ALIAS_MISCDEV(UINPUT_MINOR); | 1018 | MODULE_ALIAS_MISCDEV(UINPUT_MINOR); |
| 1017 | MODULE_ALIAS("devname:" UINPUT_NAME); | 1019 | MODULE_ALIAS("devname:" UINPUT_NAME); |
| 1018 | 1020 | ||
| 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 | |||
| 1029 | MODULE_AUTHOR("Aristeu Sergio Rozanski Filho"); | 1021 | MODULE_AUTHOR("Aristeu Sergio Rozanski Filho"); |
| 1030 | MODULE_DESCRIPTION("User level driver support for input subsystem"); | 1022 | MODULE_DESCRIPTION("User level driver support for input subsystem"); |
| 1031 | MODULE_LICENSE("GPL"); | 1023 | MODULE_LICENSE("GPL"); |
| 1032 | MODULE_VERSION("0.3"); | 1024 | MODULE_VERSION("0.3"); |
| 1033 | |||
| 1034 | module_init(uinput_init); | ||
| 1035 | module_exit(uinput_exit); | ||
diff --git a/drivers/s390/char/sclp_ctl.c b/drivers/s390/char/sclp_ctl.c index ea607a4a1bdd..554eaa1e347d 100644 --- a/drivers/s390/char/sclp_ctl.c +++ b/drivers/s390/char/sclp_ctl.c | |||
| @@ -126,21 +126,4 @@ static struct miscdevice sclp_ctl_device = { | |||
| 126 | .name = "sclp", | 126 | .name = "sclp", |
| 127 | .fops = &sclp_ctl_fops, | 127 | .fops = &sclp_ctl_fops, |
| 128 | }; | 128 | }; |
| 129 | 129 | module_misc_device(sclp_ctl_device); | |
| 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); | ||
diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index 388eec4e1a90..70c342c987f7 100644 --- a/drivers/vhost/test.c +++ b/drivers/vhost/test.c | |||
| @@ -322,18 +322,7 @@ static struct miscdevice vhost_test_misc = { | |||
| 322 | "vhost-test", | 322 | "vhost-test", |
| 323 | &vhost_test_fops, | 323 | &vhost_test_fops, |
| 324 | }; | 324 | }; |
| 325 | 325 | module_misc_device(vhost_test_misc); | |
| 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); | ||
| 337 | 326 | ||
| 338 | MODULE_VERSION("0.0.1"); | 327 | MODULE_VERSION("0.0.1"); |
| 339 | MODULE_LICENSE("GPL v2"); | 328 | MODULE_LICENSE("GPL v2"); |
