From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Christopher Heiny <cheiny@synaptics.com>
Cc: Linus Walleij <linus.walleij@stericsson.com>,
Linux Input <linux-input@vger.kernel.org>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Allie Xiong <axiong@synaptics.com>, Vivian Ly <vly@synaptics.com>,
Daniel Rosenberg <daniel.rosenberg@synaptics.com>,
Alexandra Chin <alexandra.chin@tw.synaptics.com>,
Joerie de Gram <j.de.gram@gmail.com>,
Wolfram Sang <w.sang@pengutronix.de>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
Subject: [PATCH 4/4] Input: RMI4 - introduce rmi_module_driver() macro
Date: Tue, 27 Nov 2012 01:21:38 -0800 [thread overview]
Message-ID: <1354008098-26346-4-git-send-email-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <1354008098-26346-1-git-send-email-dmitry.torokhov@gmail.com>
This also allows us to cut down on the boilerplate code in the function
handler modules.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/rmi4/rmi_f11.c | 13 +------------
include/linux/rmi.h | 14 ++++++++++++++
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index dbb6060..8457ab4 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -2756,18 +2756,7 @@ static struct rmi_function_handler rmi_f11_handler = {
#endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
};
-static int __init rmi_f11_module_init(void)
-{
- return rmi_register_function_handler(&rmi_f11_handler);
-}
-
-static void __exit rmi_f11_module_exit(void)
-{
- rmi_unregister_function_handler(&rmi_f11_handler);
-}
-
-module_init(rmi_f11_module_init);
-module_exit(rmi_f11_module_exit);
+module_rmi_driver(rmi_f11_handler);
MODULE_AUTHOR("Christopher Heiny <cheiny@synaptics.com");
MODULE_DESCRIPTION("RMI F11 module");
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 8a74066..daca41b 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -600,4 +600,18 @@ int rmi_register_phys_device(struct rmi_phys_device *phys);
void rmi_unregister_phys_device(struct rmi_phys_device *phys);
int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));
+/**
+ * module_serio_driver() - Helper macro for registering a serio driver
+ * @__serio_driver: serio_driver struct
+ *
+ * Helper macro for serio drivers which do not do anything special in
+ * module init/exit. This eliminates a lot of boilerplate. Each module
+ * may only use this macro once, and calling it replaces module_init()
+ * and module_exit().
+ */
+#define module_rmi_driver(__rmi_driver) \
+ module_driver(__rmi_driver, \
+ rmi_register_function_handler, \
+ rmi_unregister_function_handler)
+
#endif
--
1.7.11.7
next prev parent reply other threads:[~2012-11-27 9:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-27 9:21 [PATCH 1/4] Input RMI4 - rename rmi_function_container to rmi_function Dmitry Torokhov
2012-11-27 9:21 ` [PATCH 2/4] Input: RMI4 - move sensor driver and F01 handler into the core Dmitry Torokhov
2012-11-29 4:54 ` Christopher Heiny
2012-11-29 17:21 ` Dmitry Torokhov
2012-12-02 2:36 ` Christopher Heiny
2012-11-27 9:21 ` [PATCH 3/4] Input: RMI4 - move function registration " Dmitry Torokhov
2012-11-27 9:21 ` Dmitry Torokhov [this message]
2012-11-27 23:46 ` [PATCH 4/4] Input: RMI4 - introduce rmi_module_driver() macro Christopher Heiny
2012-11-27 23:43 ` [PATCH 1/4] Input RMI4 - rename rmi_function_container to rmi_function Christopher Heiny
2012-11-28 7:09 ` Dmitry Torokhov
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=1354008098-26346-4-git-send-email-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=alexandra.chin@tw.synaptics.com \
--cc=axiong@synaptics.com \
--cc=cheiny@synaptics.com \
--cc=daniel.rosenberg@synaptics.com \
--cc=j.de.gram@gmail.com \
--cc=linus.walleij@stericsson.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=naveen.gaddipati@stericsson.com \
--cc=vly@synaptics.com \
--cc=w.sang@pengutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®