All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: most: Use module_platform_driver
@ 2015-10-03 12:01 Shraddha Barke
  2015-10-04 19:30 ` [Outreachy kernel] " Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Shraddha Barke @ 2015-10-03 12:01 UTC (permalink / raw)
  To: outreachy-kernel

Use module_platform_driver for drivers whose init and exit functions
only register and unregister, respectively. Thus remove some
boilerplate code.

A simplified version of Coccinelle patch -

@a@
identifier f, x;
@@
-static f(...) { return platform_driver_register(&x); }
@b depends on a@
identifier e, a.x;
@@
-static e(...) { platform_driver_unregister(&x); }
@c depends on a && b@
identifier a.f;
declarer name module_init;
@@
-module_init(f);

@d depends on a && b && c@
identifier b.e, a.x;
declarer name module_exit;
declarer name module_platform_driver;
@@
-module_exit(e);
+module_platform_driver(x);

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
 drivers/staging/most/hdm-dim2/dim2_hdm.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/staging/most/hdm-dim2/dim2_hdm.c b/drivers/staging/most/hdm-dim2/dim2_hdm.c
index 1bb70b7..c7e956f 100644
--- a/drivers/staging/most/hdm-dim2/dim2_hdm.c
+++ b/drivers/staging/most/hdm-dim2/dim2_hdm.c
@@ -926,26 +926,7 @@ static struct platform_driver dim2_driver = {
 	},
 };
 
-/**
- * dim2_hdm_init - Driver Registration Routine
- */
-static int __init dim2_hdm_init(void)
-{
-	pr_info("dim2_hdm_init()\n");
-	return platform_driver_register(&dim2_driver);
-}
-
-/**
- * dim2_hdm_exit - Driver Cleanup Routine
- **/
-static void __exit dim2_hdm_exit(void)
-{
-	pr_info("dim2_hdm_exit()\n");
-	platform_driver_unregister(&dim2_driver);
-}
-
-module_init(dim2_hdm_init);
-module_exit(dim2_hdm_exit);
+module_platform_driver(dim2_driver);
 
 MODULE_AUTHOR("Jain Roy Ambi <JainRoy.Ambi@microchip.com>");
 MODULE_AUTHOR("Andrey Shvetsov <andrey.shvetsov@k2l.de>");
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: most: Use module_platform_driver
  2015-10-03 12:01 [PATCH] Staging: most: Use module_platform_driver Shraddha Barke
@ 2015-10-04 19:30 ` Arnd Bergmann
       [not found]   ` <20151004194144.GA23542@kroah.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2015-10-04 19:30 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: Shraddha Barke

On Saturday 03 October 2015 17:31:30 Shraddha Barke wrote:
> 
> -/**
> - * dim2_hdm_init - Driver Registration Routine
> - */
> -static int __init dim2_hdm_init(void)
> -{
> -       pr_info("dim2_hdm_init()\n");
> -       return platform_driver_register(&dim2_driver);
> -}
> -
> 

Your changelog does not mention that you are removing the pr_info() lines
in the process of the conversion.

Removing those lines is a good idea, but that should better be done as
a separate patch upfront, possibly removing other debug statements
from the same driver as well.

	Arnd


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: most: Use module_platform_driver
       [not found]   ` <20151004194144.GA23542@kroah.com>
@ 2015-10-04 19:47     ` Arnd Bergmann
  2015-10-05  3:20       ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2015-10-04 19:47 UTC (permalink / raw)
  To: Greg KH; +Cc: outreachy-kernel, Shraddha Barke

On Sunday 04 October 2015 20:41:44 Greg KH wrote:
> On Sun, Oct 04, 2015 at 09:30:50PM +0200, Arnd Bergmann wrote:
> > On Saturday 03 October 2015 17:31:30 Shraddha Barke wrote:
> > > 
> > > -/**
> > > - * dim2_hdm_init - Driver Registration Routine
> > > - */
> > > -static int __init dim2_hdm_init(void)
> > > -{
> > > -       pr_info("dim2_hdm_init()\n");
> > > -       return platform_driver_register(&dim2_driver);
> > > -}
> > > -
> > > 
> > 
> > Your changelog does not mention that you are removing the pr_info() lines
> > in the process of the conversion.
> > 
> > Removing those lines is a good idea, but that should better be done as
> > a separate patch upfront, possibly removing other debug statements
> > from the same driver as well.
> 
> No, this is how we converted all of the other drivers to this api a long
> time ago, no need to break it up into 2 patches.  This is also one of
> the main reasons to use this api, to keep things "quiet".
> 

Ok, fair enough. It's probably worth mentioning that in the changelog though.

	Arnd


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: most: Use module_platform_driver
  2015-10-04 19:47     ` Arnd Bergmann
@ 2015-10-05  3:20       ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2015-10-05  3:20 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: outreachy-kernel, Shraddha Barke

On Sun, Oct 04, 2015 at 09:47:16PM +0200, Arnd Bergmann wrote:
> On Sunday 04 October 2015 20:41:44 Greg KH wrote:
> > On Sun, Oct 04, 2015 at 09:30:50PM +0200, Arnd Bergmann wrote:
> > > On Saturday 03 October 2015 17:31:30 Shraddha Barke wrote:
> > > > 
> > > > -/**
> > > > - * dim2_hdm_init - Driver Registration Routine
> > > > - */
> > > > -static int __init dim2_hdm_init(void)
> > > > -{
> > > > -       pr_info("dim2_hdm_init()\n");
> > > > -       return platform_driver_register(&dim2_driver);
> > > > -}
> > > > -
> > > > 
> > > 
> > > Your changelog does not mention that you are removing the pr_info() lines
> > > in the process of the conversion.
> > > 
> > > Removing those lines is a good idea, but that should better be done as
> > > a separate patch upfront, possibly removing other debug statements
> > > from the same driver as well.
> > 
> > No, this is how we converted all of the other drivers to this api a long
> > time ago, no need to break it up into 2 patches.  This is also one of
> > the main reasons to use this api, to keep things "quiet".
> > 
> 
> Ok, fair enough. It's probably worth mentioning that in the changelog though.

I don't think I ever did that when I converted drivers to this api, so I
wouldn't expect a new developer to do something I wasn't willing to do
:)

thanks,

greg k-h


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-05  3:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-03 12:01 [PATCH] Staging: most: Use module_platform_driver Shraddha Barke
2015-10-04 19:30 ` [Outreachy kernel] " Arnd Bergmann
     [not found]   ` <20151004194144.GA23542@kroah.com>
2015-10-04 19:47     ` Arnd Bergmann
2015-10-05  3:20       ` Greg KH

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.