mtd: plat_ram: call mtd_device_register only if partition data exists
authorIlya Yanok <yanok@emcraft.com>
Mon, 12 Dec 2011 23:37:56 +0000 (00:37 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 19 Dec 2011 11:13:52 +0000 (11:13 +0000)
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@emcraft.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/maps/plat-ram.c

index 94f553489725280d2ec851023f17745e86c48d9a..45876d0e5b8e500b321466fad5789d7a9bfbe182 100644 (file)
@@ -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;