Skip to contentSkip to conversation

plat_ram: call mtd_device_register only if partition data exists

PATCH In review Ilya Yanok 2 participants 4 messages Dec 12, 2011 – Dec 18, 2011 Memory technology devices (MTD)

lore
Share & tools
lore

Ilya Yanok

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/mtd/maps/plat-ram.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
drivers/mtd/maps/plat-ram.c +8 -4
index 94f5534..45876d0 100644
@@ -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;
 
Signature · 1 line
1.7.6.4
#1 lore raw
Quoted 5 lines · Ilya Yanok

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.

This seems to be a bug-fix, right? What happens without this patch? We end up with 2 MTD equivalent MTD devices?

Signature · 2 lines
Best Regards,
Artem Bityutskiy
author
#2 lore raw

Hi Artem,

Quoted 7 lines · Artem Bityutskiy
Quoted 5 lines

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.

This seems to be a bug-fix, right? What happens without this patch?

Right.

Quoted 1 line

We end up with 2 MTD equivalent MTD devices?

Yes (only second one shown in /proc/mtd) and a warning for kobject:

kobject (cf2c10e0): tried to init an initialized object, something is seriously wrong.

Regards, Ilya.

#3 lore raw
Quoted 11 lines · Ilya Yanok

Hi Artem,

Quoted 7 lines · Artem Bityutskiy
Quoted 5 lines

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.

This seems to be a bug-fix, right? What happens without this patch?

Quoted 8 lines

Right.

Quoted 1 line

We end up with 2 MTD equivalent MTD devices?

Yes (only second one shown in /proc/mtd) and a warning for kobject:

kobject (cf2c10e0): tried to init an initialized object, something is seriously wrong.

OK, then I'll ping David Woodhouse to merge this before 3.2 release. Taken to l2-mtd-2.6.git so far, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy