mtd: plat_ram: call mtd_device_register only if partition data exists

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Dec 19 06:59:02 EST 2011


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=c32987918efaa6949c5b2f3e43b654a742b18f7d
Commit:     c32987918efaa6949c5b2f3e43b654a742b18f7d
Parent:     7148b7999277e2794cec90d8cb47d2a238e0bd0d
Author:     Ilya Yanok <yanok at emcraft.com>
AuthorDate: Tue Dec 13 00:37:56 2011 +0100
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Dec 19 11:13:52 2011 +0000

    mtd: plat_ram: call mtd_device_register only if partition data exists
    
    mtd_device_parse_register() registers the device as a whole if no
    partition data is passed so there is no reason to call
    mtd_device_register() after that.
    
    Signed-off-by: Ilya Yanok <yanok at emcraft.com>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/maps/plat-ram.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index 94f5534..45876d0 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -227,10 +227,14 @@ static int platram_probe(struct platform_device *pdev)
 	if (!err)
 		dev_info(&pdev->dev, "registered mtd device\n");
 
-	/* add the whole device. */
-	err = mtd_device_register(info->mtd, NULL, 0);
-	if (err)
-		dev_err(&pdev->dev, "failed to register the entire device\n");
+	if (pdata->nr_partitions) {
+		/* add the whole device. */
+		err = mtd_device_register(info->mtd, NULL, 0);
+		if (err) {
+			dev_err(&pdev->dev,
+				"failed to register the entire device\n");
+		}
+	}
 
 	return err;
 



More information about the linux-mtd-cvs mailing list