mtd: elbc nand: use drvdata to only remove the relevant chip

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Jul 6 13:59:04 EDT 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=874d72c4fe07713c4889c944d3c7ebbce352c762
Commit:     874d72c4fe07713c4889c944d3c7ebbce352c762
Parent:     9d6367f4f7835131b2b3987d134fd4c44636fa8d
Author:     Scott Wood <scottwood at freescale.com>
AuthorDate: Wed Jun 6 18:36:39 2012 -0500
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Jul 6 18:17:05 2012 +0100

    mtd: elbc nand: use drvdata to only remove the relevant chip
    
    Previously the remove method was looping and removing all chips,
    which is obviously not the right thing to do — left over from when
    the driver was organized differently and that was the remove method for
    the entire controller.  This would result in bad things happening if
    you have more than one NAND chip, and remove the module.
    
    This also fixes priv->dev to properly point to the chip's device rather than
    the controller's.  Until now priv->dev was only used for error/debug prints
    (and it's an improvement there), so this shouldn't break anything.
    
    Signed-off-by: Scott Wood <scottwood at freescale.com>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/fsl_elbc_nand.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 1d8d111..22bb5e6 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -915,7 +915,8 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)
 	elbc_fcm_ctrl->chips[bank] = priv;
 	priv->bank = bank;
 	priv->ctrl = fsl_lbc_ctrl_dev;
-	priv->dev = dev;
+	priv->dev = &pdev->dev;
+	dev_set_drvdata(priv->dev, priv);
 
 	priv->vbase = ioremap(res.start, resource_size(&res));
 	if (!priv->vbase) {
@@ -962,11 +963,10 @@ err:
 
 static int fsl_elbc_nand_remove(struct platform_device *pdev)
 {
-	int i;
 	struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = fsl_lbc_ctrl_dev->nand;
-	for (i = 0; i < MAX_BANKS; i++)
-		if (elbc_fcm_ctrl->chips[i])
-			fsl_elbc_chip_remove(elbc_fcm_ctrl->chips[i]);
+	struct fsl_elbc_mtd *priv = dev_get_drvdata(&pdev->dev);
+
+	fsl_elbc_chip_remove(priv);
 
 	mutex_lock(&fsl_elbc_nand_mutex);
 	elbc_fcm_ctrl->counter--;



More information about the linux-mtd-cvs mailing list