Patchwork [1/7] usb: gadget: fsl_udc: simplify driver init

login
register
mail settings
Submitter Christoph Fritz
Date Oct. 19, 2012, 10:24 a.m.
Message ID <1350642285-8145-1-git-send-email-chf.fritz@googlemail.com>
Download mbox | patch
Permalink /patch/192636/
State Not Applicable
Headers show

Comments

Felipe Balbi - Oct. 19, 2012, 10:24 a.m.
Hi,

On Fri, Oct 19, 2012 at 12:24:39PM +0200, Christoph Fritz wrote:
> To initialize this driver use 'module_platform_driver' instead
> of '__init' and '__exit'.
> 
> Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
> ---
>  drivers/usb/gadget/fsl_udc_core.c |   37 +++++++++++--------------------------
>  1 files changed, 11 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
> index 6ae70cb..340451d 100644
> --- a/drivers/usb/gadget/fsl_udc_core.c
> +++ b/drivers/usb/gadget/fsl_udc_core.c
> @@ -49,13 +49,14 @@
>  
>  #include "fsl_usb2_udc.h"
>  
> +#define	DRIVER_NAME	"fsl-usb2-udc"
>  #define	DRIVER_DESC	"Freescale High-Speed USB SOC Device Controller driver"
>  #define	DRIVER_AUTHOR	"Li Yang/Jiang Bo"
>  #define	DRIVER_VERSION	"Apr 20, 2007"
>  
>  #define	DMA_ADDR_INVALID	(~(dma_addr_t)0)
>  
> -static const char driver_name[] = "fsl-usb2-udc";
> +static const char driver_name[] = DRIVER_NAME;
>  static const char driver_desc[] = DRIVER_DESC;
>  
>  static struct usb_dr_device *dr_regs;
> @@ -2761,35 +2762,19 @@ static int fsl_udc_otg_resume(struct device *dev)
>  	Register entry point for the peripheral controller driver
>  --------------------------------------------------------------------------*/
>  
> -static struct platform_driver udc_driver = {
> -	.remove  = __exit_p(fsl_udc_remove),
> -	/* these suspend and resume are not usb suspend and resume */
> -	.suspend = fsl_udc_suspend,
> -	.resume  = fsl_udc_resume,
> -	.driver  = {
> -		.name = (char *)driver_name,
> -		.owner = THIS_MODULE,
> -		/* udc suspend/resume called from OTG driver */
> +static struct platform_driver fsl_udc_driver = {
> +	.probe		= fsl_udc_probe,

NAK, probe() lies in .init.text section. You need to change __init to
__devinit. Likewise for all functions which are only called during
probe() and for remove() which needs s/__exit/__devexit.
Christoph Fritz - Oct. 19, 2012, 10:24 a.m.
To initialize this driver use 'module_platform_driver' instead
of '__init' and '__exit'.

Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com>
---
 drivers/usb/gadget/fsl_udc_core.c |   37 +++++++++++--------------------------
 1 files changed, 11 insertions(+), 26 deletions(-)

Patch

diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index 6ae70cb..340451d 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -49,13 +49,14 @@ 
 
 #include "fsl_usb2_udc.h"
 
+#define	DRIVER_NAME	"fsl-usb2-udc"
 #define	DRIVER_DESC	"Freescale High-Speed USB SOC Device Controller driver"
 #define	DRIVER_AUTHOR	"Li Yang/Jiang Bo"
 #define	DRIVER_VERSION	"Apr 20, 2007"
 
 #define	DMA_ADDR_INVALID	(~(dma_addr_t)0)
 
-static const char driver_name[] = "fsl-usb2-udc";
+static const char driver_name[] = DRIVER_NAME;
 static const char driver_desc[] = DRIVER_DESC;
 
 static struct usb_dr_device *dr_regs;
@@ -2761,35 +2762,19 @@  static int fsl_udc_otg_resume(struct device *dev)
 	Register entry point for the peripheral controller driver
 --------------------------------------------------------------------------*/
 
-static struct platform_driver udc_driver = {
-	.remove  = __exit_p(fsl_udc_remove),
-	/* these suspend and resume are not usb suspend and resume */
-	.suspend = fsl_udc_suspend,
-	.resume  = fsl_udc_resume,
-	.driver  = {
-		.name = (char *)driver_name,
-		.owner = THIS_MODULE,
-		/* udc suspend/resume called from OTG driver */
+static struct platform_driver fsl_udc_driver = {
+	.probe		= fsl_udc_probe,
+	.remove		= __devexit_p(fsl_udc_remove),
+	.suspend	= fsl_udc_suspend,
+	.resume		= fsl_udc_resume,
+	.driver		= {
+		.name	= DRIVER_NAME,
+		.owner	= THIS_MODULE,
 		.suspend = fsl_udc_otg_suspend,
 		.resume  = fsl_udc_otg_resume,
 	},
 };
-
-static int __init udc_init(void)
-{
-	printk(KERN_INFO "%s (%s)\n", driver_desc, DRIVER_VERSION);
-	return platform_driver_probe(&udc_driver, fsl_udc_probe);
-}
-
-module_init(udc_init);
-
-static void __exit udc_exit(void)
-{
-	platform_driver_unregister(&udc_driver);
-	printk(KERN_WARNING "%s unregistered\n", driver_desc);
-}
-
-module_exit(udc_exit);
+module_platform_driver(fsl_udc_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR(DRIVER_AUTHOR);