Patchwork register orion_nand using platform_driver_probe

login
register
mail settings
Submitter Uwe Kleine-König
Date July 21, 2009, 8:46 p.m.
Message ID <1248209196-15705-1-git-send-email-u.kleine-koenig@pengutronix.de>
Download mbox | patch
Permalink /patch/30054/
State Accepted
Commit f33dabbe79fdf7a8568c65faa1db7794c87ac4d3
Headers show

Comments

Uwe Kleine-König - July 21, 2009, 8:46 p.m.
orion_nand_probe lives in .init.text, so using platform_driver_register
to register it is wrong because binding a device after the init memory
is discarded (e.g. via sysfs) results in an oops.

As requested by Nicolas Pitre platform_driver_probe is used instead of
moving the probe function to .devinit.text as proposed initially.
This saves some memory, but devices registered after the driver is
probed are not bound (probably there are none) and binding via sysfs
isn't possible.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Lennert Buytenhek <buytenh@marvell.com>
Cc: Saeed Bishara <saeed@marvell.com>
Cc: Jörn Engel <joern@logfs.org>
Cc: Nicolas Pitre <nico@marvell.com>
Cc: Tzachi Perelstein <tzachi@marvell.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: linux-mtd@lists.infradead.org

---
 drivers/mtd/nand/orion_nand.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Nicolas Pitre - July 21, 2009, 10:26 p.m.
On Tue, 21 Jul 2009, Uwe Kleine-König wrote:

> orion_nand_probe lives in .init.text, so using platform_driver_register
> to register it is wrong because binding a device after the init memory
> is discarded (e.g. via sysfs) results in an oops.
> 
> As requested by Nicolas Pitre platform_driver_probe is used instead of
> moving the probe function to .devinit.text as proposed initially.
> This saves some memory, but devices registered after the driver is
> probed are not bound (probably there are none) and binding via sysfs
> isn't possible.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Lennert Buytenhek <buytenh@marvell.com>
> Cc: Saeed Bishara <saeed@marvell.com>
> Cc: Jörn Engel <joern@logfs.org>
> Cc: Nicolas Pitre <nico@marvell.com>
> Cc: Tzachi Perelstein <tzachi@marvell.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: linux-mtd@lists.infradead.org

Acked-by: Nicolas Pitre <nico@marvell.com>

Thanks.  BTW Tzachi's email address is no longer valid.

> ---
>  drivers/mtd/nand/orion_nand.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
> index 7ad9722..cb9d13b 100644
> --- a/drivers/mtd/nand/orion_nand.c
> +++ b/drivers/mtd/nand/orion_nand.c
> @@ -171,7 +171,6 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
>  }
>  
>  static struct platform_driver orion_nand_driver = {
> -	.probe		= orion_nand_probe,
>  	.remove		= __devexit_p(orion_nand_remove),
>  	.driver		= {
>  		.name	= "orion_nand",
> @@ -181,7 +180,7 @@ static struct platform_driver orion_nand_driver = {
>  
>  static int __init orion_nand_init(void)
>  {
> -	return platform_driver_register(&orion_nand_driver);
> +	return platform_driver_probe(&orion_nand_driver, orion_nand_probe);
>  }
>  
>  static void __exit orion_nand_exit(void)
> -- 
> tg: (4b0a840..) t/platsection/orion_nand_driver (depends on: linus/master)
>
Uwe Kleine-König - July 22, 2009, 5:17 a.m.
Hi Nicolas,

On Tue, Jul 21, 2009 at 06:26:50PM -0400, Nicolas Pitre wrote:
> On Tue, 21 Jul 2009, Uwe Kleine-König wrote:
> 
> > orion_nand_probe lives in .init.text, so using platform_driver_register
> > to register it is wrong because binding a device after the init memory
> > is discarded (e.g. via sysfs) results in an oops.
> > 
> > As requested by Nicolas Pitre platform_driver_probe is used instead of
> > moving the probe function to .devinit.text as proposed initially.
> > This saves some memory, but devices registered after the driver is
> > probed are not bound (probably there are none) and binding via sysfs
> > isn't possible.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Cc: Lennert Buytenhek <buytenh@marvell.com>
> > Cc: Saeed Bishara <saeed@marvell.com>
> > Cc: Jörn Engel <joern@logfs.org>
> > Cc: Nicolas Pitre <nico@marvell.com>
> > Cc: Tzachi Perelstein <tzachi@marvell.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Greg Kroah-Hartman <gregkh@suse.de>
> > Cc: David Woodhouse <dwmw2@infradead.org>
> > Cc: linux-mtd@lists.infradead.org
> 
> Acked-by: Nicolas Pitre <nico@marvell.com>
Did you test if all devices bind as expected?
 
> Thanks.  BTW Tzachi's email address is no longer valid.
Yes, I got a mail from Marvell's mailer daemon stating the same.  :-)

Best regards
Uwe

Patch

diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 7ad9722..cb9d13b 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -171,7 +171,6 @@  static int __devexit orion_nand_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver orion_nand_driver = {
-	.probe		= orion_nand_probe,
 	.remove		= __devexit_p(orion_nand_remove),
 	.driver		= {
 		.name	= "orion_nand",
@@ -181,7 +180,7 @@  static struct platform_driver orion_nand_driver = {
 
 static int __init orion_nand_init(void)
 {
-	return platform_driver_register(&orion_nand_driver);
+	return platform_driver_probe(&orion_nand_driver, orion_nand_probe);
 }
 
 static void __exit orion_nand_exit(void)