diff mbox series

cpufreq: bmips-cpufreq: Use module_init and add module_exit

Message ID 20220826021845.2283648-1-chris.zjh@huawei.com (mailing list archive)
State Superseded, archived
Headers show
Series cpufreq: bmips-cpufreq: Use module_init and add module_exit | expand

Commit Message

Zhang Jianhua Aug. 26, 2022, 2:18 a.m. UTC
- Use module_init instead of device_initcall.
- Add a function for module_exit to unregister driver.

Signed-off-by: Zhang Jianhua <chris.zjh@huawei.com>
---
 drivers/cpufreq/bmips-cpufreq.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Viresh Kumar Aug. 30, 2022, 5:29 a.m. UTC | #1
On 26-08-22, 10:18, Zhang Jianhua wrote:
> - Use module_init instead of device_initcall.
> - Add a function for module_exit to unregister driver.
> 
> Signed-off-by: Zhang Jianhua <chris.zjh@huawei.com>
> ---
>  drivers/cpufreq/bmips-cpufreq.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/bmips-cpufreq.c b/drivers/cpufreq/bmips-cpufreq.c
> index f7c23fa468f0..21c0417c95e1 100644
> --- a/drivers/cpufreq/bmips-cpufreq.c
> +++ b/drivers/cpufreq/bmips-cpufreq.c
> @@ -156,7 +156,7 @@ static struct cpufreq_driver bmips_cpufreq_driver = {
>  	.name		= BMIPS_CPUFREQ_PREFIX,
>  };
>  
> -static int __init bmips_cpufreq_probe(void)
> +static int __init bmips_cpufreq_driver_init(void)
>  {
>  	struct cpufreq_compat *cc;
>  	struct device_node *np;
> @@ -176,7 +176,13 @@ static int __init bmips_cpufreq_probe(void)
>  
>  	return cpufreq_register_driver(&bmips_cpufreq_driver);
>  }
> -device_initcall(bmips_cpufreq_probe);
> +module_init(bmips_cpufreq_driver_init);
> +
> +static void __exit bmips_cpufreq_driver_exit(void)
> +{
> +	cpufreq_unregister_driver(&bmips_cpufreq_driver);
> +}
> +module_exit(bmips_cpufreq_driver_exit)

Semicolon ? Did you even compile this ? :)

>  
>  MODULE_AUTHOR("Markus Mayer <mmayer@broadcom.com>");
>  MODULE_DESCRIPTION("CPUfreq driver for Broadcom BMIPS SoCs");
> -- 
> 2.31.0
Zhang Jianhua Aug. 30, 2022, 8:01 a.m. UTC | #2
在 2022/8/30 13:29, Viresh Kumar 写道:
> On 26-08-22, 10:18, Zhang Jianhua wrote:
>> - Use module_init instead of device_initcall.
>> - Add a function for module_exit to unregister driver.
>>
>> Signed-off-by: Zhang Jianhua <chris.zjh@huawei.com>
>> ---
>>   drivers/cpufreq/bmips-cpufreq.c | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpufreq/bmips-cpufreq.c b/drivers/cpufreq/bmips-cpufreq.c
>> index f7c23fa468f0..21c0417c95e1 100644
>> --- a/drivers/cpufreq/bmips-cpufreq.c
>> +++ b/drivers/cpufreq/bmips-cpufreq.c
>> @@ -156,7 +156,7 @@ static struct cpufreq_driver bmips_cpufreq_driver = {
>>   	.name		= BMIPS_CPUFREQ_PREFIX,
>>   };
>>   
>> -static int __init bmips_cpufreq_probe(void)
>> +static int __init bmips_cpufreq_driver_init(void)
>>   {
>>   	struct cpufreq_compat *cc;
>>   	struct device_node *np;
>> @@ -176,7 +176,13 @@ static int __init bmips_cpufreq_probe(void)
>>   
>>   	return cpufreq_register_driver(&bmips_cpufreq_driver);
>>   }
>> -device_initcall(bmips_cpufreq_probe);
>> +module_init(bmips_cpufreq_driver_init);
>> +
>> +static void __exit bmips_cpufreq_driver_exit(void)
>> +{
>> +	cpufreq_unregister_driver(&bmips_cpufreq_driver);
>> +}
>> +module_exit(bmips_cpufreq_driver_exit)
> Semicolon ? Did you even compile this ? :)

Semicolon is not necessary for module_exit, and it can be compiled. I will send v2 patch to keep the format consistent, thanks.

>>   
>>   MODULE_AUTHOR("Markus Mayer <mmayer@broadcom.com>");
>>   MODULE_DESCRIPTION("CPUfreq driver for Broadcom BMIPS SoCs");
>> -- 
>> 2.31.0
Viresh Kumar Aug. 30, 2022, 8:06 a.m. UTC | #3
On 30-08-22, 16:01, zhangjianhua (E) wrote:
> 
> 在 2022/8/30 13:29, Viresh Kumar 写道:
> > On 26-08-22, 10:18, Zhang Jianhua wrote:
> > > - Use module_init instead of device_initcall.
> > > - Add a function for module_exit to unregister driver.
> > > 
> > > Signed-off-by: Zhang Jianhua <chris.zjh@huawei.com>
> > > ---
> > >   drivers/cpufreq/bmips-cpufreq.c | 10 ++++++++--
> > >   1 file changed, 8 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/cpufreq/bmips-cpufreq.c b/drivers/cpufreq/bmips-cpufreq.c
> > > index f7c23fa468f0..21c0417c95e1 100644
> > > --- a/drivers/cpufreq/bmips-cpufreq.c
> > > +++ b/drivers/cpufreq/bmips-cpufreq.c
> > > @@ -156,7 +156,7 @@ static struct cpufreq_driver bmips_cpufreq_driver = {
> > >   	.name		= BMIPS_CPUFREQ_PREFIX,
> > >   };
> > > -static int __init bmips_cpufreq_probe(void)
> > > +static int __init bmips_cpufreq_driver_init(void)
> > >   {
> > >   	struct cpufreq_compat *cc;
> > >   	struct device_node *np;
> > > @@ -176,7 +176,13 @@ static int __init bmips_cpufreq_probe(void)
> > >   	return cpufreq_register_driver(&bmips_cpufreq_driver);
> > >   }
> > > -device_initcall(bmips_cpufreq_probe);
> > > +module_init(bmips_cpufreq_driver_init);
> > > +
> > > +static void __exit bmips_cpufreq_driver_exit(void)
> > > +{
> > > +	cpufreq_unregister_driver(&bmips_cpufreq_driver);
> > > +}
> > > +module_exit(bmips_cpufreq_driver_exit)
> > Semicolon ? Did you even compile this ? :)
> 
> Semicolon is not necessary for module_exit, and it can be compiled. I will send v2 patch to keep the format consistent, thanks.

Ahh, because module exit is defined as:

#define module_exit(x)	__exitcall(x);

Yeah, please send V2 with a semicolon in place.
diff mbox series

Patch

diff --git a/drivers/cpufreq/bmips-cpufreq.c b/drivers/cpufreq/bmips-cpufreq.c
index f7c23fa468f0..21c0417c95e1 100644
--- a/drivers/cpufreq/bmips-cpufreq.c
+++ b/drivers/cpufreq/bmips-cpufreq.c
@@ -156,7 +156,7 @@  static struct cpufreq_driver bmips_cpufreq_driver = {
 	.name		= BMIPS_CPUFREQ_PREFIX,
 };
 
-static int __init bmips_cpufreq_probe(void)
+static int __init bmips_cpufreq_driver_init(void)
 {
 	struct cpufreq_compat *cc;
 	struct device_node *np;
@@ -176,7 +176,13 @@  static int __init bmips_cpufreq_probe(void)
 
 	return cpufreq_register_driver(&bmips_cpufreq_driver);
 }
-device_initcall(bmips_cpufreq_probe);
+module_init(bmips_cpufreq_driver_init);
+
+static void __exit bmips_cpufreq_driver_exit(void)
+{
+	cpufreq_unregister_driver(&bmips_cpufreq_driver);
+}
+module_exit(bmips_cpufreq_driver_exit)
 
 MODULE_AUTHOR("Markus Mayer <mmayer@broadcom.com>");
 MODULE_DESCRIPTION("CPUfreq driver for Broadcom BMIPS SoCs");