Skip to contentSkip to conversation

apbuart: fix section mismatch warning

PATCH Applied Sam Ravnborg 2 participants 4 messages Dec 27, 2011 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 apbuart: fix section mismatch warning

From b82ccce349dee62fe5acd3167a19490bbe9a7e18 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <[email protected]>
Date: Tue, 27 Dec 2011 22:07:23 +0100
Subject: [PATCH] apbuart: fix section mismatch warning

Fix following warnings:

WARNING: drivers/tty/serial/built-in.o(.text+0x7370): Section mismatch in reference from the function grlib_apbuart_configure() to the variable .init.data:apbuart_match The function grlib_apbuart_configure() references
the variable __initdata apbuart_match.
This is often because grlib_apbuart_configure lacks a __initdata
annotation or the annotation of apbuart_match is wrong.

+ 3 more warnings like this.

There is no guarantee that grlib_apbuart_of_driver.of_match_table is only used at __init time - so drop the __initdata annotation.

grlib_apbuart_configure() is only used during __init so add __init to this method too.

Cc Daniel Hellstrom <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/tty/serial/apbuart.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/apbuart.c +2 -2
index 77554fd..7162f70 100644
@@ -577,7 +577,7 @@ static int __devinit apbuart_probe(struct platform_device *op)
 	return 0;
 }
 
-static struct of_device_id __initdata apbuart_match[] = {
+static struct of_device_id apbuart_match[] = {
 	{
 	 .name = "GAISLER_APBUART",
 	 },
@@ -597,7 +597,7 @@ static struct platform_driver grlib_apbuart_of_driver = {
 };
 
 
-static int grlib_apbuart_configure(void)
+static int __init grlib_apbuart_configure(void)
 {
 	struct device_node *np;
 	int line = 0;
Signature · 1 line
1.6.0.6
Applied
#1 lore raw

From: Sam Ravnborg <[email protected]>
Date: Tue, 27 Dec 2011 22:22:53 +0100

Quoted 18 lines
Quoted 1 line

From b82ccce349dee62fe5acd3167a19490bbe9a7e18 Mon Sep 17 00:00:00 2001

From: Sam Ravnborg <[email protected]>
Date: Tue, 27 Dec 2011 22:07:23 +0100
Subject: [PATCH] apbuart: fix section mismatch warning

Fix following warnings:

WARNING: drivers/tty/serial/built-in.o(.text+0x7370): Section mismatch in reference from the function grlib_apbuart_configure() to the variable .init.data:apbuart_match The function grlib_apbuart_configure() references
the variable __initdata apbuart_match.
This is often because grlib_apbuart_configure lacks a __initdata
annotation or the annotation of apbuart_match is wrong.

+ 3 more warnings like this.

There is no guarantee that grlib_apbuart_of_driver.of_match_table is only used at __init time - so drop the __initdata annotation.

Quoted 6 lines

grlib_apbuart_configure() is only used during __init so add __init to this method too.

Cc Daniel Hellstrom <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

Applied to sparc-next, thanks.

Taking a look at the output of "git grep of_device_id | grep __initdata" shows that a lot of drivers take liberties in this area, perhaps assuming that they are built in or something like that.

But that isn't even a safe situation, because even built-in drivers can have their of_device_id accessed later after we bootup, for example when a bus is hot-plugged in or even via sysfs dumps of the avaialble drivers.

Probably the thing to do is to remove all of these __initdata tags, because as far as I can tell they are _all_ wrong. And perhaps add 'const' where missing as well.

#2 lore raw
In reply to Sam Ravnborg
Quoted 28 lines · David Miller

From: Sam Ravnborg <[email protected]>
Date: Tue, 27 Dec 2011 22:22:53 +0100

Quoted 18 lines
Quoted 1 line
Quoted 1 line

From b82ccce349dee62fe5acd3167a19490bbe9a7e18 Mon Sep 17 00:00:00 2001

From: Sam Ravnborg <[email protected]>
Date: Tue, 27 Dec 2011 22:07:23 +0100
Subject: [PATCH] apbuart: fix section mismatch warning

Fix following warnings:

WARNING: drivers/tty/serial/built-in.o(.text+0x7370): Section mismatch in reference from the function grlib_apbuart_configure() to the variable .init.data:apbuart_match The function grlib_apbuart_configure() references
the variable __initdata apbuart_match.
This is often because grlib_apbuart_configure lacks a __initdata
annotation or the annotation of apbuart_match is wrong.

+ 3 more warnings like this.

There is no guarantee that grlib_apbuart_of_driver.of_match_table is only used at __init time - so drop the __initdata annotation.

Quoted 6 lines

grlib_apbuart_configure() is only used during __init so add __init to this method too.

Cc Daniel Hellstrom <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 5 lines

Applied to sparc-next, thanks.

Taking a look at the output of "git grep of_device_id | grep __initdata" shows that a lot of drivers take liberties in this area, perhaps assuming that they are built in or something like that.

I took a quick look at this.
In the places I found the of_device_id() was passed to for example of_platform_bus_probe() which was only called at __init time. And the function did not save the argument.

So at least some call sites are OK.
But I did not audit nearly all of them - so some bugs are lingering here.

Sam

#3 lore raw
In reply to Sam Ravnborg

From: Sam Ravnborg <[email protected]>
Date: Tue, 27 Dec 2011 23:20:46 +0100

Quoted 5 lines

In the places I found the of_device_id() was passed to for example of_platform_bus_probe() which was only called at __init time. And the function did not save the argument.

So at least some call sites are OK.

Ok, good to know.