From: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
To: linux@armlinux.org.uk, realmz6@gmail.com, jdike@addtoit.com,
richard@nod.at, marcel@holtmann.org, gustavo@padovan.org,
johan.hedberg@gmail.com, arnd@arndb.de,
gregkh@linuxfoundation.org, dh.herrmann@googlemail.com,
jikos@kernel.org, benjamin.tissoires@redhat.com,
dmitry.torokhov@gmail.com, mb@lightnvm.io,
schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
mst@redhat.com, elias.vds@gmail.com, akpm@linux-foundation.org,
jcliang@chromium.org, holzheu@linux.vnet.ibm.com,
linux-kernel@vger.kernel.org
Cc: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Subject: [PATCH 2/2] miscdevice: Use module_misc_device() macro
Date: Sun, 21 Aug 2016 12:19:25 +0530 [thread overview]
Message-ID: <1471762165-16023-2-git-send-email-prasannatsmkumar@gmail.com> (raw)
In-Reply-To: <1471762165-16023-1-git-send-email-prasannatsmkumar@gmail.com>
This patch removes module_init()/module_exit() from driver code by using
module_misc_device() macro.
This patch removes print statements in module init method, so it is sent
as a separate patch. If print statements are necessary this patch can be
dropped entirely.
Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
---
arch/um/drivers/harddog_kern.c | 25 +------------------------
drivers/bluetooth/hci_vhci.c | 16 +---------------
drivers/char/bfin-otp.c | 40 +---------------------------------------
drivers/lightnvm/core.c | 19 +------------------
4 files changed, 4 insertions(+), 96 deletions(-)
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c
index 2d0266d..3282787 100644
--- a/arch/um/drivers/harddog_kern.c
+++ b/arch/um/drivers/harddog_kern.c
@@ -175,27 +175,4 @@ static struct miscdevice harddog_miscdev = {
.name = "watchdog",
.fops = &harddog_fops,
};
-
-static char banner[] __initdata = KERN_INFO "UML Watchdog Timer\n";
-
-static int __init harddog_init(void)
-{
- int ret;
-
- ret = misc_register(&harddog_miscdev);
-
- if (ret)
- return ret;
-
- printk(banner);
-
- return 0;
-}
-
-static void __exit harddog_exit(void)
-{
- misc_deregister(&harddog_miscdev);
-}
-
-module_init(harddog_init);
-module_exit(harddog_exit);
+module_misc_device(harddog_miscdev);
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 3ff229b..c4a75a1 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -377,21 +377,7 @@ static struct miscdevice vhci_miscdev = {
.fops = &vhci_fops,
.minor = VHCI_MINOR,
};
-
-static int __init vhci_init(void)
-{
- BT_INFO("Virtual HCI driver ver %s", VERSION);
-
- return misc_register(&vhci_miscdev);
-}
-
-static void __exit vhci_exit(void)
-{
- misc_deregister(&vhci_miscdev);
-}
-
-module_init(vhci_init);
-module_exit(vhci_exit);
+module_misc_device(vhci_miscdev);
module_param(amp, bool, 0644);
MODULE_PARM_DESC(amp, "Create AMP controller device");
diff --git a/drivers/char/bfin-otp.c b/drivers/char/bfin-otp.c
index 44660f1..35d46da 100644
--- a/drivers/char/bfin-otp.c
+++ b/drivers/char/bfin-otp.c
@@ -230,45 +230,7 @@ static struct miscdevice bfin_otp_misc_device = {
.name = DRIVER_NAME,
.fops = &bfin_otp_fops,
};
-
-/**
- * bfin_otp_init - Initialize module
- *
- * Registers the device and notifier handler. Actual device
- * initialization is handled by bfin_otp_open().
- */
-static int __init bfin_otp_init(void)
-{
- int ret;
-
- stampit();
-
- ret = misc_register(&bfin_otp_misc_device);
- if (ret) {
- pr_init(KERN_ERR PFX "unable to register a misc device\n");
- return ret;
- }
-
- pr_init(KERN_INFO PFX "initialized\n");
-
- return 0;
-}
-
-/**
- * bfin_otp_exit - Deinitialize module
- *
- * Unregisters the device and notifier handler. Actual device
- * deinitialization is handled by bfin_otp_close().
- */
-static void __exit bfin_otp_exit(void)
-{
- stampit();
-
- misc_deregister(&bfin_otp_misc_device);
-}
-
-module_init(bfin_otp_init);
-module_exit(bfin_otp_exit);
+module_misc_device(bfin_otp_misc_device);
MODULE_AUTHOR("Mike Frysinger <vapier@gentoo.org>");
MODULE_DESCRIPTION("Blackfin OTP Memory Interface");
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 9ebd2cf..c784ddc 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -1171,27 +1171,10 @@ static struct miscdevice _nvm_misc = {
.nodename = "lightnvm/control",
.fops = &_ctl_fops,
};
+module_misc_device(_nvm_misc);
MODULE_ALIAS_MISCDEV(MISC_DYNAMIC_MINOR);
-static int __init nvm_mod_init(void)
-{
- int ret;
-
- ret = misc_register(&_nvm_misc);
- if (ret)
- pr_err("nvm: misc_register failed for control device");
-
- return ret;
-}
-
-static void __exit nvm_mod_exit(void)
-{
- misc_deregister(&_nvm_misc);
-}
-
MODULE_AUTHOR("Matias Bjorling <m@bjorling.me>");
MODULE_LICENSE("GPL v2");
MODULE_VERSION("0.1");
-module_init(nvm_mod_init);
-module_exit(nvm_mod_exit);
--
2.5.0
next prev parent reply other threads:[~2016-08-21 6:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-21 6:49 [PATCH 1/2] drivercore: Add helper macro for misc device boilerplate PrasannaKumar Muralidharan
2016-08-21 6:49 ` PrasannaKumar Muralidharan [this message]
2016-08-22 8:50 ` kbuild test robot
2016-08-23 22:19 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1471762165-16023-2-git-send-email-prasannatsmkumar@gmail.com \
--to=prasannatsmkumar@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=benjamin.tissoires@redhat.com \
--cc=dh.herrmann@googlemail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=elias.vds@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo@padovan.org \
--cc=heiko.carstens@de.ibm.com \
--cc=holzheu@linux.vnet.ibm.com \
--cc=jcliang@chromium.org \
--cc=jdike@addtoit.com \
--cc=jikos@kernel.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=marcel@holtmann.org \
--cc=mb@lightnvm.io \
--cc=mst@redhat.com \
--cc=realmz6@gmail.com \
--cc=richard@nod.at \
--cc=schwidefsky@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.