linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* several wrong sections for probe functions of platform drivers
@ 2008-09-02 21:05 Uwe Kleine-König
  2008-09-02 21:15 ` [PATCH] Fix section for probe and remove function for Apple SMU Controller Uwe Kleine-König
  2008-09-08 12:13 ` [PATCH] Fix section for sa11xx-uda1341 platform driver Uwe Kleine-König
  0 siblings, 2 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2008-09-02 21:05 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

Hello,

I wrote a small python script that extracts the section specifier for
probe functions of platform drivers and warns if it's != __devinit.
The script is attached.

It's not always an error if the probe function is defined using __init,
but then (AFAIK) it should not be passed in the struct platform_driver!?

With Linus' current tree (v2.6.27-rc5-55-gafa153f) I get 215 matches
with

	1x __devexit
	67x __init
	146x no section

and one match that isn't interpreted correctly by my script.

I think the __devexit case is definitly wrong.  I will do a deeper look
and then probably send a patch for that one as a follow up to this mail.

I didn't (yet) checked the other cases, but I expect that most of them
need fixing.

Would it make sense to start collecting such scripts in the vanilla
tree?

I appreciate any constructive feedback.

Best regards
Uwe

-- 
Uwe Kleine-König

If a lawyer and an IRS agent were both drowning, and you could only save
one of them, would you go to lunch or read the paper?

[-- Attachment #2: probe_in_init.py --]
[-- Type: text/x-python, Size: 1020 bytes --]

#! /usr/bin/python

import os
import re

re_probename = re.compile('struct\s+platform_driver\s+(?P<drivername>\S+)\s*=\s*{.*\.probe\s*=\s*(?P<probefunction>[A-Za-z0-9_]*)', re.S)

for dirpath, dirnames, filenames in os.walk('.'):
    for f in filter(lambda s: s.endswith('.c'), filenames):
        fullf = os.path.join(dirpath, f)
        content = open(fullf).read()
        matchdict = dict(filename=fullf)

        mo = re_probename.search(content)
        if mo:
            matchdict.update(mo.groupdict())
        else:
            continue

        re_section = re.compile('int\s+(?:(?P<probesection>__(?:dev)?(?:init|exit)+)\s+)?%(probefunction)s\s*\(' % matchdict)
        mo = re_section.search(content)
        if mo:
            matchdict.update(mo.groupdict())
        else:
            matchdict['probesection'] = ''

        if matchdict['probesection'] != '__devinit':
            print 'probe function %(probefunction)r for %(drivername)r (%(filename)s) defined in section %(probesection)r' % matchdict

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Fix section for probe and remove function for Apple SMU Controller
  2008-09-02 21:05 several wrong sections for probe functions of platform drivers Uwe Kleine-König
@ 2008-09-02 21:15 ` Uwe Kleine-König
  2008-09-05 14:38   ` Jean Delvare
  2008-09-08 12:13 ` [PATCH] Fix section for sa11xx-uda1341 platform driver Uwe Kleine-König
  1 sibling, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2008-09-02 21:15 UTC (permalink / raw)
  To: linux-kernel; +Cc: Benjamin Herrenschmidt, Paul Mackerras, Jean Delvare

__devexit for i2c_powermac_probe is obviously wrong.  In the definition
of struct platform_driver i2c_powermac_driver the remove function
i2c_powermac_remove is wrapped in __devexit_p, so it should be defined
using __devexit.

Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Jean Delvare <khali@linux-fr.org>
---
 drivers/i2c/busses/i2c-powermac.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 22f6d5c..0e7b1c6 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -180,7 +180,7 @@ static const struct i2c_algorithm i2c_powermac_algorithm = {
 };
 
 
-static int i2c_powermac_remove(struct platform_device *dev)
+static int __devexit i2c_powermac_remove(struct platform_device *dev)
 {
 	struct i2c_adapter	*adapter = platform_get_drvdata(dev);
 	struct pmac_i2c_bus	*bus = i2c_get_adapdata(adapter);
@@ -200,7 +200,7 @@ static int i2c_powermac_remove(struct platform_device *dev)
 }
 
 
-static int __devexit i2c_powermac_probe(struct platform_device *dev)
+static int __devinit i2c_powermac_probe(struct platform_device *dev)
 {
 	struct pmac_i2c_bus *bus = dev->dev.platform_data;
 	struct device_node *parent = NULL;
-- 
1.5.6.5

-- 
Uwe Kleine-König

http://www.google.com/search?q=5%2B7

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix section for probe and remove function for Apple SMU Controller
  2008-09-02 21:15 ` [PATCH] Fix section for probe and remove function for Apple SMU Controller Uwe Kleine-König
@ 2008-09-05 14:38   ` Jean Delvare
  0 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2008-09-05 14:38 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-kernel, Benjamin Herrenschmidt, Paul Mackerras, Linux I2C

Hi Uwe,

Note: patches to i2c bus drivers are better sent to the i2c mailing
list (Cc'd.)

On Tue, 2 Sep 2008 23:15:56 +0200, Uwe Kleine-König wrote:
> __devexit for i2c_powermac_probe is obviously wrong.  In the definition
> of struct platform_driver i2c_powermac_driver the remove function
> i2c_powermac_remove is wrapped in __devexit_p, so it should be defined
> using __devexit.
> 
> Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Jean Delvare <khali@linux-fr.org>
> ---
>  drivers/i2c/busses/i2c-powermac.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
> index 22f6d5c..0e7b1c6 100644
> --- a/drivers/i2c/busses/i2c-powermac.c
> +++ b/drivers/i2c/busses/i2c-powermac.c
> @@ -180,7 +180,7 @@ static const struct i2c_algorithm i2c_powermac_algorithm = {
>  };
>  
>  
> -static int i2c_powermac_remove(struct platform_device *dev)
> +static int __devexit i2c_powermac_remove(struct platform_device *dev)
>  {
>  	struct i2c_adapter	*adapter = platform_get_drvdata(dev);
>  	struct pmac_i2c_bus	*bus = i2c_get_adapdata(adapter);
> @@ -200,7 +200,7 @@ static int i2c_powermac_remove(struct platform_device *dev)
>  }
>  
>  
> -static int __devexit i2c_powermac_probe(struct platform_device *dev)
> +static int __devinit i2c_powermac_probe(struct platform_device *dev)
>  {
>  	struct pmac_i2c_bus *bus = dev->dev.platform_data;
>  	struct device_node *parent = NULL;

Looks good, patch applied. Thanks for your contribution.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Fix section for sa11xx-uda1341 platform driver
  2008-09-02 21:05 several wrong sections for probe functions of platform drivers Uwe Kleine-König
  2008-09-02 21:15 ` [PATCH] Fix section for probe and remove function for Apple SMU Controller Uwe Kleine-König
@ 2008-09-08 12:13 ` Uwe Kleine-König
  2008-09-08 18:51   ` [RESEND, PATCH] " Uwe Kleine-König
  1 sibling, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2008-09-08 12:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Uwe Kleine-König

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1192 bytes --]

Don't use __init but __devinit to define probe function.  A pointer to
sa11xx_uda1341_probe is passed to the core via platform_driver_register and
so the function must not disappear after the module is loaded.  Using __init
and having HOTPLUG=y and SND_SA11XX_UDA1341=m the following probably oopses:

	echo -n sa11xx_uda1341.1 > /sys/bus/platform/driver/sa11xx_uda1341/unbind
	echo -n sa11xx_uda1341.1 > /sys/bus/platform/driver/sa11xx_uda1341/bind

Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>

---
 sound/arm/sa11xx-uda1341.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index b9c51bf..da25b41 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -879,7 +879,7 @@ void snd_sa11xx_uda1341_free(struct snd_card *card)
 	audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]);
 }
 
-static int __init sa11xx_uda1341_probe(struct platform_device *devptr)
+static int __devinit sa11xx_uda1341_probe(struct platform_device *devptr)
 {
 	int err;
 	struct snd_card *card;
-- 
tg: (7686ad5..) t/sectionfixes/sa11xx_uda1341 (depends on: t/sectionfixes/sa11xx_uda1341)

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RESEND, PATCH] Fix section for sa11xx-uda1341 platform driver
  2008-09-08 12:13 ` [PATCH] Fix section for sa11xx-uda1341 platform driver Uwe Kleine-König
@ 2008-09-08 18:51   ` Uwe Kleine-König
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2008-09-08 18:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Russell King, Jaroslav Kysela, Brian Avery, alsa-devel, Andrew Morton

Don't use __init but __devinit to define probe function.  A pointer to
sa11xx_uda1341_probe is passed to the core via platform_driver_register and
so the function must not disappear after the module is loaded.  Using __init
and having HOTPLUG=y and SND_SA11XX_UDA1341=m the following probably oopses:

	echo -n sa11xx_uda1341.1 > /sys/bus/platform/driver/sa11xx_uda1341/unbind
	echo -n sa11xx_uda1341.1 > /sys/bus/platform/driver/sa11xx_uda1341/bind

Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Brian Avery <b.avery@hp.com>
Cc: alsa-devel@alsa-project.org
Cc: Andrew Morton <akpm@linux-foundation.org>

---
Hello,

uups, I forgot to add the right cc:.  Sorry.

@Andrew,  I have a few more patches of this type pending.  Is it OK for
you if they go via you?  This would ease the process a bit for me.

Uwe

 sound/arm/sa11xx-uda1341.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index b9c51bf..da25b41 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -879,7 +879,7 @@ void snd_sa11xx_uda1341_free(struct snd_card *card)
 	audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]);
 }
 
-static int __init sa11xx_uda1341_probe(struct platform_device *devptr)
+static int __devinit sa11xx_uda1341_probe(struct platform_device *devptr)
 {
 	int err;
 	struct snd_card *card;
-- 
tg: (7686ad5..) t/sectionfixes/sa11xx_uda1341 (depends on: t/sectionfixes/sa11xx_uda1341)

-- 
Uwe Kleine-König

http://www.google.com/search?q=1+electron+mass%3D

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-09-08 18:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-02 21:05 several wrong sections for probe functions of platform drivers Uwe Kleine-König
2008-09-02 21:15 ` [PATCH] Fix section for probe and remove function for Apple SMU Controller Uwe Kleine-König
2008-09-05 14:38   ` Jean Delvare
2008-09-08 12:13 ` [PATCH] Fix section for sa11xx-uda1341 platform driver Uwe Kleine-König
2008-09-08 18:51   ` [RESEND, PATCH] " Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).