Re: [PATCH 57/58] move w100fb's probe function to .devinit.text

From: pHilipp Zabel
Date: Sat Mar 28 2009 - 06:01:25 EST


2009/3/28 Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>:
> A pointer to w100fb_probe is passed to the core via
> platform_driver_register and so the function must not disappear when the
> .init sections are discarded.  Otherwise (if also having HOTPLUG=y)
> unbinding and binding a device to the driver via sysfs will result in an
> oops as does a device being registered late.
>
> An alternative to this patch is using platform_driver_probe instead of
> platform_driver_register plus removing the pointer to the probe function
> from the struct platform_driver.

The ATI Imageon chips handled by this driver are not hotpluggable,
I think the proposed alternative is the right way.
Also, shouldn't w100fb_init be moved from __devinit to __init and
w100fb_remove be put into __exit?

> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> Cc: Philipp Zabel <philipp.zabel@xxxxxxxxx>
> Cc: Ian Molton <spyro@xxxxxxx>
> Cc: Richard Purdie <rpurdie@xxxxxxxxx>
> Cc: Antonino Daplas <adaplas@xxxxxxxxx>
> Cc: Alberto Mardegan <mardy@xxxxxxxxxxxxxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>

---
drivers/video/w100fb.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index d0674f1..157e7bd 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -781,7 +781,7 @@ out:
}


-static int w100fb_remove(struct platform_device *pdev)
+static int __exit w100fb_remove(struct platform_device *pdev)
{
struct fb_info *info = platform_get_drvdata(pdev);
struct w100fb_par *par=info->par;
@@ -1609,8 +1609,7 @@ static void w100_vsync(void)
}

static struct platform_driver w100fb_driver = {
- .probe = w100fb_probe,
- .remove = w100fb_remove,
+ .remove = __exit_p(w100fb_remove),
.suspend = w100fb_suspend,
.resume = w100fb_resume,
.driver = {
@@ -1618,9 +1617,9 @@ static struct platform_driver w100fb_driver = {
},
};

-int __devinit w100fb_init(void)
+int __init w100fb_init(void)
{
- return platform_driver_register(&w100fb_driver);
+ return platform_driver_probe(&w100fb_driver, w100fb_probe);
}

void __exit w100fb_cleanup(void)
--
1.6.2.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/