Patchwork [MTD] MXC NAND driver fixes (v4)

login
register
mail settings
Submitter Vladimir Barinov
Date April 22, 2009, 3:31 p.m.
Message ID <1240414310-9245-1-git-send-email-vbarinov@embeddedalley.com>
Download mbox | patch
Permalink /patch/26318/
State New
Headers show

Comments

Vladimir Barinov - April 22, 2009, 3:31 p.m.
The following patch fixes:
 - re-initialization of host->col_addr which is used as byte index
   between the successive READID flash commands.
 - compile error when CONFIG_PM is enabled
 - pass on the error code from clk_get()
 - return -ENOMEM in case of failed ioremap()
 - pass on the return value of platform_driver_probe() directly
 - remove excessive printk
 - let command line partition table parsing with mxc_nand name.
   The cmd_line parsing is done via <mtd-id> name that differs
   from mxc_nand by default and looks like "NAND 256MiB 1,8V 8-bit"

Signed-off-by: Vladimir Barinov <vbarinov@embeddedalley.com>
Signed-off-by: Lothar Wassmann <LW@KARO-electronics.de>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/mxc_nand.c |   43 +++++++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 20 deletions(-)
Artem Bityutskiy - April 23, 2009, 6:46 a.m.
On Wed, 2009-04-22 at 19:31 +0400, Vladimir Barinov wrote:
> The following patch fixes:
>  - re-initialization of host->col_addr which is used as byte index
>    between the successive READID flash commands.
>  - compile error when CONFIG_PM is enabled
>  - pass on the error code from clk_get()
>  - return -ENOMEM in case of failed ioremap()
>  - pass on the return value of platform_driver_probe() directly
>  - remove excessive printk
>  - let command line partition table parsing with mxc_nand name.
>    The cmd_line parsing is done via <mtd-id> name that differs
>    from mxc_nand by default and looks like "NAND 256MiB 1,8V 8-bit"
> 
> Signed-off-by: Vladimir Barinov <vbarinov@embeddedalley.com>
> Signed-off-by: Lothar Wassmann <LW@KARO-electronics.de>
> Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/mtd/nand/mxc_nand.c |   43 +++++++++++++++++++++++--------------------
>  1 files changed, 23 insertions(+), 20 deletions(-)

Your patch does not apply to the latest mtd-2.6.git

[dedekind@eru l2-mtd-2.6.git]$ git-am vova                                                                                                                                             
Applying: MXC NAND driver fixes (v4)                                                                                                                                                   
error: patch failed: drivers/mtd/nand/mxc_nand.c:866                                                                                                                                   
error: drivers/mtd/nand/mxc_nand.c: patch does not apply                                                                                                                               
Patch failed at 0001.                                                                                                                                                                  
When you have resolved this problem run "git am --resolved".                                                                                                                           
If you would prefer to skip this patch, instead run "git am --skip".                                                                                                                   
To restore the original branch and stop patching run "git am --abort".                                                                                                                 
                                                                                                                                                     
[dedekind@eru l2-mtd-2.6.git]$ patch -p1 < vova                                                                                                                                        
patching file drivers/mtd/nand/mxc_nand.c                                                                                                                                              
Hunk #2 FAILED at 867.                                                                                                                                                                 
Hunk #3 succeeded at 884 (offset 1 line).                                                                                                                                              
Hunk #5 succeeded at 1015 (offset 1 line).                                                                                                                                             
1 out of 6 hunks FAILED -- saving rejects to file drivers/mtd/nand/mxc_nand.c.rej                                                                                                      

[dedekind@eru l2-mtd-2.6.git]$ cat drivers/mtd/nand/mxc_nand.c.rej
***************
*** 866,871 ****
        mtd = &host->mtd;
        mtd->priv = this;
        mtd->owner = THIS_MODULE;

        /* 50 us command delay time */
        this->chip_delay = 5;
--- 867,873 ----
        mtd = &host->mtd;
        mtd->priv = this;
        mtd->owner = THIS_MODULE;
+       mtd->name = "mxc_nand";

        /* 50 us command delay time */
        this->chip_delay = 5;
Vladimir Barinov - April 23, 2009, 11:31 a.m.
Hello Artem,

Artem Bityutskiy wrote:
> On Wed, 2009-04-22 at 19:31 +0400, Vladimir Barinov wrote:
>   
>> The following patch fixes:
>>  - re-initialization of host->col_addr which is used as byte index
>>    between the successive READID flash commands.
>>  - compile error when CONFIG_PM is enabled
>>  - pass on the error code from clk_get()
>>  - return -ENOMEM in case of failed ioremap()
>>  - pass on the return value of platform_driver_probe() directly
>>  - remove excessive printk
>>  - let command line partition table parsing with mxc_nand name.
>>    The cmd_line parsing is done via <mtd-id> name that differs
>>    from mxc_nand by default and looks like "NAND 256MiB 1,8V 8-bit"
>>
>> Signed-off-by: Vladimir Barinov <vbarinov@embeddedalley.com>
>> Signed-off-by: Lothar Wassmann <LW@KARO-electronics.de>
>> Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
>> ---
>>  drivers/mtd/nand/mxc_nand.c |   43 +++++++++++++++++++++++--------------------
>>  1 files changed, 23 insertions(+), 20 deletions(-)
>>     
>
> Your patch does not apply to the latest mtd-2.6.git
>   
Sorry, my fault, I didn't verified the patch after the latest merge.
Will remake to apply cleanly in V5.

Vladimir

Patch

diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index bad048a..d4dbcbe 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -831,6 +831,7 @@  static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
 		break;
 
 	case NAND_CMD_READID:
+		host->col_addr = 0;
 		send_read_id(host);
 		break;
 
@@ -866,6 +867,7 @@  static int __init mxcnd_probe(struct platform_device *pdev)
 	mtd = &host->mtd;
 	mtd->priv = this;
 	mtd->owner = THIS_MODULE;
+	mtd->name = "mxc_nand";
 
 	/* 50 us command delay time */
 	this->chip_delay = 5;
@@ -881,8 +883,10 @@  static int __init mxcnd_probe(struct platform_device *pdev)
 	this->verify_buf = mxc_nand_verify_buf;
 
 	host->clk = clk_get(&pdev->dev, "nfc");
-	if (IS_ERR(host->clk))
+	if (IS_ERR(host->clk)) {
+		err = PTR_ERR(host->clk);
 		goto eclk;
+	}
 
 	clk_enable(host->clk);
 	host->clk_act = 1;
@@ -895,7 +899,7 @@  static int __init mxcnd_probe(struct platform_device *pdev)
 
 	host->regs = ioremap(res->start, res->end - res->start + 1);
 	if (!host->regs) {
-		err = -EIO;
+		err = -ENOMEM;
 		goto eres;
 	}
 
@@ -1010,30 +1014,35 @@  static int __devexit mxcnd_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM
 static int mxcnd_suspend(struct platform_device *pdev, pm_message_t state)
 {
-	struct mtd_info *info = platform_get_drvdata(pdev);
+	struct mtd_info *mtd = platform_get_drvdata(pdev);
+	struct nand_chip *nand_chip = mtd->priv;
+	struct mxc_nand_host *host = nand_chip->priv;
 	int ret = 0;
 
 	DEBUG(MTD_DEBUG_LEVEL0, "MXC_ND : NAND suspend\n");
-	if (info)
-		ret = info->suspend(info);
-
-	/* Disable the NFC clock */
-	clk_disable(nfc_clk);	/* FIXME */
+	if (mtd) {
+		ret = mtd->suspend(mtd);
+		/* Disable the NFC clock */
+		clk_disable(host->clk);
+	}
 
 	return ret;
 }
 
 static int mxcnd_resume(struct platform_device *pdev)
 {
-	struct mtd_info *info = platform_get_drvdata(pdev);
+	struct mtd_info *mtd = platform_get_drvdata(pdev);
+	struct nand_chip *nand_chip = mtd->priv;
+	struct mxc_nand_host *host = nand_chip->priv;
 	int ret = 0;
 
 	DEBUG(MTD_DEBUG_LEVEL0, "MXC_ND : NAND resume\n");
-	/* Enable the NFC clock */
-	clk_enable(nfc_clk);	/* FIXME */
 
-	if (info)
-		info->resume(info);
+	if (mtd) {
+		/* Enable the NFC clock */
+		clk_enable(host->clk);
+		mtd->resume(mtd);
+	}
 
 	return ret;
 }
@@ -1054,13 +1063,7 @@  static struct platform_driver mxcnd_driver = {
 
 static int __init mxc_nd_init(void)
 {
-	/* Register the device driver structure. */
-	pr_info("MXC MTD nand Driver\n");
-	if (platform_driver_probe(&mxcnd_driver, mxcnd_probe) != 0) {
-		printk(KERN_ERR "Driver register failed for mxcnd_driver\n");
-		return -ENODEV;
-	}
-	return 0;
+	return platform_driver_probe(&mxcnd_driver, mxcnd_probe);
 }
 
 static void __exit mxc_nd_cleanup(void)