diff mbox

[2/2] ASoC: atmel-ssc: use module_platform_driver macro

Message ID 1350359819-2461-2-git-send-email-voice.shen@atmel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bo Shen Oct. 16, 2012, 3:56 a.m. UTC
This patch removes some code duplication by using module_platform_driver

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
 drivers/misc/atmel-ssc.c |   18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

Comments

Nicolas Ferre Oct. 16, 2012, 8:07 a.m. UTC | #1
On 10/16/2012 05:56 AM, Bo Shen :
> This patch removes some code duplication by using module_platform_driver
> 
> Signed-off-by: Bo Shen <voice.shen@atmel.com>

Very good simplification but...

> ---
>  drivers/misc/atmel-ssc.c |   18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
> index 23dcb76..ac00f83 100644
> --- a/drivers/misc/atmel-ssc.c
> +++ b/drivers/misc/atmel-ssc.c
> @@ -68,7 +68,7 @@ void ssc_free(struct ssc_device *ssc)
>  }
>  EXPORT_SYMBOL(ssc_free);
>  
> -static int __init ssc_probe(struct platform_device *pdev)
> +static int ssc_probe(struct platform_device *pdev)

Here you remove the __init altogether, maybe converting to __devinit is
the proper replacement for this? I do not know myself but if anybody knows?

Bye,


>  {
>  	struct resource *regs;
>  	struct ssc_device *ssc;
> @@ -135,24 +135,14 @@ static int __devexit ssc_remove(struct platform_device *pdev)
>  }
>  
>  static struct platform_driver ssc_driver = {
> -	.remove		= __devexit_p(ssc_remove),
>  	.driver		= {
>  		.name		= "ssc",
>  		.owner		= THIS_MODULE,
>  	},
> +	.probe		= ssc_probe,
> +	.remove		= __devexit_p(ssc_remove),
>  };
> -
> -static int __init ssc_init(void)
> -{
> -	return platform_driver_probe(&ssc_driver, ssc_probe);
> -}
> -module_init(ssc_init);
> -
> -static void __exit ssc_exit(void)
> -{
> -	platform_driver_unregister(&ssc_driver);
> -}
> -module_exit(ssc_exit);
> +module_platform_driver(ssc_driver);
>  
>  MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
>  MODULE_DESCRIPTION("SSC driver for Atmel AVR32 and AT91");
>
Jean-Christophe PLAGNIOL-VILLARD Oct. 16, 2012, 8:49 a.m. UTC | #2
On 10:07 Tue 16 Oct     , Nicolas Ferre wrote:
> On 10/16/2012 05:56 AM, Bo Shen :
> > This patch removes some code duplication by using module_platform_driver
> > 
> > Signed-off-by: Bo Shen <voice.shen@atmel.com>
> 
> Very good simplification but...
> 
> > ---
> >  drivers/misc/atmel-ssc.c |   18 ++++--------------
> >  1 file changed, 4 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
> > index 23dcb76..ac00f83 100644
> > --- a/drivers/misc/atmel-ssc.c
> > +++ b/drivers/misc/atmel-ssc.c
> > @@ -68,7 +68,7 @@ void ssc_free(struct ssc_device *ssc)
> >  }
> >  EXPORT_SYMBOL(ssc_free);
> >  
> > -static int __init ssc_probe(struct platform_device *pdev)
> > +static int ssc_probe(struct platform_device *pdev)
> 
> Here you remove the __init altogether, maybe converting to __devinit is
> the proper replacement for this? I do not know myself but if anybody knows?
yes __devinit is mandatory

Best Regards,
J.
Bo Shen Oct. 16, 2012, 8:59 a.m. UTC | #3
On 10/16/2012 16:49, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:07 Tue 16 Oct     , Nicolas Ferre wrote:
>> On 10/16/2012 05:56 AM, Bo Shen :
>>> This patch removes some code duplication by using module_platform_driver
>>>
>>> Signed-off-by: Bo Shen <voice.shen@atmel.com>
>>
>> Very good simplification but...
>>
>>> ---
>>>   drivers/misc/atmel-ssc.c |   18 ++++--------------
>>>   1 file changed, 4 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
>>> index 23dcb76..ac00f83 100644
>>> --- a/drivers/misc/atmel-ssc.c
>>> +++ b/drivers/misc/atmel-ssc.c
>>> @@ -68,7 +68,7 @@ void ssc_free(struct ssc_device *ssc)
>>>   }
>>>   EXPORT_SYMBOL(ssc_free);
>>>
>>> -static int __init ssc_probe(struct platform_device *pdev)
>>> +static int ssc_probe(struct platform_device *pdev)
>>
>> Here you remove the __init altogether, maybe converting to __devinit is
>> the proper replacement for this? I do not know myself but if anybody knows?
> yes __devinit is mandatory

I will add a small patch to fix this.

Thanks.

BRs,
Bo Shen

>
> Best Regards,
> J.
>
Russell King - ARM Linux Oct. 16, 2012, 9:07 a.m. UTC | #4
On Tue, Oct 16, 2012 at 10:49:47AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:07 Tue 16 Oct     , Nicolas Ferre wrote:
> > On 10/16/2012 05:56 AM, Bo Shen :
> > > -static int __init ssc_probe(struct platform_device *pdev)
> > > +static int ssc_probe(struct platform_device *pdev)
> > 
> > Here you remove the __init altogether, maybe converting to __devinit is
> > the proper replacement for this? I do not know myself but if anybody knows?
> yes __devinit is mandatory

No it isn't.  __init is plain buggy.  __devinit is better, but there's
plans to remove all __devinit from the kernel.  Having nothing there
will make GregKH's life a lot easier when he does come to remove __devinit.
Fabio Porcedda Oct. 16, 2012, 9:32 a.m. UTC | #5
On Tue, Oct 16, 2012 at 5:56 AM, Bo Shen <voice.shen@atmel.com> wrote:
> This patch removes some code duplication by using module_platform_driver
>
> Signed-off-by: Bo Shen <voice.shen@atmel.com>
> ---
>  drivers/misc/atmel-ssc.c |   18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
> index 23dcb76..ac00f83 100644
> --- a/drivers/misc/atmel-ssc.c
> +++ b/drivers/misc/atmel-ssc.c
> @@ -68,7 +68,7 @@ void ssc_free(struct ssc_device *ssc)
>  }
>  EXPORT_SYMBOL(ssc_free);
>
> -static int __init ssc_probe(struct platform_device *pdev)
> +static int ssc_probe(struct platform_device *pdev)
>  {
>         struct resource *regs;
>         struct ssc_device *ssc;
> @@ -135,24 +135,14 @@ static int __devexit ssc_remove(struct platform_device *pdev)
>  }
>
>  static struct platform_driver ssc_driver = {
> -       .remove         = __devexit_p(ssc_remove),
>         .driver         = {
>                 .name           = "ssc",
>                 .owner          = THIS_MODULE,
>         },
> +       .probe          = ssc_probe,
> +       .remove         = __devexit_p(ssc_remove),
>  };
> -
> -static int __init ssc_init(void)
> -{
> -       return platform_driver_probe(&ssc_driver, ssc_probe);
> -}
> -module_init(ssc_init);
> -
> -static void __exit ssc_exit(void)
> -{
> -       platform_driver_unregister(&ssc_driver);
> -}
> -module_exit(ssc_exit);
> +module_platform_driver(ssc_driver);
>
>  MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
>  MODULE_DESCRIPTION("SSC driver for Atmel AVR32 and AT91");
> --
> 1.7.9.5

Maybe the module_platform_driver isn't a substitute of platform_driver_probe,
because module_platform_driver  use platform_driver_register/unregister.
Using that macro we lose the advantage of platform_driver_probe,
as stated in:

https://lkml.org/lkml/2012/1/10/335
On Tue, Jan 10, 2012 at 21:47, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> [...]
>Still, setting up platform_driver.probe and removing __init from all probe
>functions is not the right thing to do, as this make (non-__init) kernel code
>size bigger, while none of these devices are hotpluggable and thus cannot
>appear after bootup. That's why we have platform_driver_probe() in the
>first place. So I think all of this should be reverted for non-hotpluggable
>drivers.
> [...]

What do you think?

Best regards
diff mbox

Patch

diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index 23dcb76..ac00f83 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -68,7 +68,7 @@  void ssc_free(struct ssc_device *ssc)
 }
 EXPORT_SYMBOL(ssc_free);
 
-static int __init ssc_probe(struct platform_device *pdev)
+static int ssc_probe(struct platform_device *pdev)
 {
 	struct resource *regs;
 	struct ssc_device *ssc;
@@ -135,24 +135,14 @@  static int __devexit ssc_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver ssc_driver = {
-	.remove		= __devexit_p(ssc_remove),
 	.driver		= {
 		.name		= "ssc",
 		.owner		= THIS_MODULE,
 	},
+	.probe		= ssc_probe,
+	.remove		= __devexit_p(ssc_remove),
 };
-
-static int __init ssc_init(void)
-{
-	return platform_driver_probe(&ssc_driver, ssc_probe);
-}
-module_init(ssc_init);
-
-static void __exit ssc_exit(void)
-{
-	platform_driver_unregister(&ssc_driver);
-}
-module_exit(ssc_exit);
+module_platform_driver(ssc_driver);
 
 MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
 MODULE_DESCRIPTION("SSC driver for Atmel AVR32 and AT91");