lkml.org 
[lkml]   [2012]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/4] Input: RMI4 - introduce rmi_module_driver() macro
On 11/27/2012 01:21 AM, Dmitry Torokhov wrote:
> This also allows us to cut down on the boilerplate code in the function
> handler modules.

I like this idea a lot. We'll adopt it.

Thanks!
Chris

>
> 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
>


--

Christopher Heiny
Senior Staff Firmware Engineer
Synaptics Incorporated


\
 
 \ /
  Last update: 2012-11-28 01:21    [W:0.106 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site