powerpc/via-pmu: Fix section mismatch warning

Message ID 20180207194439.32680-1-malat@debian.org
State New
Headers show
Series
  • powerpc/via-pmu: Fix section mismatch warning
Related show

Commit Message

Mathieu Malaterre Feb. 7, 2018, 7:44 p.m.
Remove the __init annotation from pmu_init() to avoid the
following warning.

WARNING: vmlinux.o(.data+0x4739c): Section mismatch in reference from the variable via_pmu_driver to the function .init.text:pmu_init()
The variable via_pmu_driver references
the function __init pmu_init()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
 drivers/macintosh/via-pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Vivier Feb. 13, 2018, 6:54 p.m. | #1
On 07/02/2018 20:44, Mathieu Malaterre wrote:
> Remove the __init annotation from pmu_init() to avoid the
> following warning.
> 
> WARNING: vmlinux.o(.data+0x4739c): Section mismatch in reference from the variable via_pmu_driver to the function .init.text:pmu_init()
> The variable via_pmu_driver references
> the function __init pmu_init()
> If the reference is valid then annotate the
> variable with __init* or __refdata (see linux/init.h) or name the variable:
> *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
> 
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
>  drivers/macintosh/via-pmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
> index 08849e33c567..5f378272d5b2 100644
> --- a/drivers/macintosh/via-pmu.c
> +++ b/drivers/macintosh/via-pmu.c
> @@ -378,7 +378,7 @@ static int pmu_probe(void)
>  	return vias == NULL? -ENODEV: 0;
>  }
>  
> -static int __init pmu_init(void)
> +static int pmu_init(void)
>  {
>  	if (vias == NULL)
>  		return -ENODEV;
> 

pmu_init() is really an init function only called by another init
function (adb_init()).

So I think it could be good to let the __init marker.

Did you try:

--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -198,7 +198,7 @@ static const struct file_operations
pmu_battery_proc_fops;
 static const struct file_operations pmu_options_proc_fops;

 #ifdef CONFIG_ADB
-struct adb_driver via_pmu_driver = {
+const struct adb_driver via_pmu_driver = {
        "PMU",
        pmu_probe,
        pmu_init,


Thanks,
Laurent
Mathieu Malaterre Feb. 14, 2018, 9:16 p.m. | #2
On Tue, Feb 13, 2018 at 7:54 PM, Laurent Vivier <lvivier@redhat.com> wrote:
> On 07/02/2018 20:44, Mathieu Malaterre wrote:
>> Remove the __init annotation from pmu_init() to avoid the
>> following warning.
>>
>> WARNING: vmlinux.o(.data+0x4739c): Section mismatch in reference from the variable via_pmu_driver to the function .init.text:pmu_init()
>> The variable via_pmu_driver references
>> the function __init pmu_init()
>> If the reference is valid then annotate the
>> variable with __init* or __refdata (see linux/init.h) or name the variable:
>> *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
>>
>> Signed-off-by: Mathieu Malaterre <malat@debian.org>
>> ---
>>  drivers/macintosh/via-pmu.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
>> index 08849e33c567..5f378272d5b2 100644
>> --- a/drivers/macintosh/via-pmu.c
>> +++ b/drivers/macintosh/via-pmu.c
>> @@ -378,7 +378,7 @@ static int pmu_probe(void)
>>       return vias == NULL? -ENODEV: 0;
>>  }
>>
>> -static int __init pmu_init(void)
>> +static int pmu_init(void)
>>  {
>>       if (vias == NULL)
>>               return -ENODEV;
>>
>
> pmu_init() is really an init function only called by another init
> function (adb_init()).
>
> So I think it could be good to let the __init marker.
>
> Did you try:
>
> --- a/drivers/macintosh/via-pmu.c
> +++ b/drivers/macintosh/via-pmu.c
> @@ -198,7 +198,7 @@ static const struct file_operations
> pmu_battery_proc_fops;
>  static const struct file_operations pmu_options_proc_fops;
>
>  #ifdef CONFIG_ADB
> -struct adb_driver via_pmu_driver = {
> +const struct adb_driver via_pmu_driver = {
>         "PMU",
>         pmu_probe,
>         pmu_init,
>
>

Indeed much better !

Thanks

Patch

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 08849e33c567..5f378272d5b2 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -378,7 +378,7 @@  static int pmu_probe(void)
 	return vias == NULL? -ENODEV: 0;
 }
 
-static int __init pmu_init(void)
+static int pmu_init(void)
 {
 	if (vias == NULL)
 		return -ENODEV;