Skip to contentSkip to conversation

mtd: physmap_of: Loop through all "reg" tuples for mapping

PATCH Applied Stefan Roese 2 participants 2 messages Oct 8, 2010 – Oct 12, 2010 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: physmap_of: Loop through all "reg" tuples for mapping

This patch changes the loop over the "reg" tuples to not exit directly upon of_address_to_resource() failure but to continue with the next "reg" tuple instead. This failure could be due to size = 0, which might be passed via the device-tree.

This is needed for boards, where a "reg" tuple might have size 0 (of_address_to_resource() returns with EINVAL when size = 0).

Example:

Fully equipped board:

	reg = <0 0x00000000 0x00400000
	       0 0x00400000 0x00400000>;

Partially equipped board:

	reg = <0 0x00000000 0x00400000
	       0 0x00400000 0x00000000>;

This could be the case on boards with runtime detection of multiple NOR flash configurations where the detected flash size is inserted into the dtb in U-Boot.

---
 drivers/mtd/maps/physmap_of.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/mtd/maps/physmap_of.c +5 -3
index fe63f6b..6967348 100644
@@ -267,9 +267,11 @@ static int __devinit of_flash_probe(struct platform_device *dev,
 	for (i = 0; i < count; i++) {
 		err = -ENXIO;
 		if (of_address_to_resource(dp, i, &res)) {
-			dev_err(&dev->dev, "Can't get IO address from device"
-				" tree\n");
-			goto err_out;
+			/*
+			 * Continue with next register tuple if this
+			 * one is not mappable
+			 */
+			continue;
 		}
 
 		dev_dbg(&dev->dev, "of_flash device: %.8llx-%.8llx\n",
Signature · 1 line
1.7.3.1
#1 lore raw
Quoted 20 lines · Stefan Roese

This patch changes the loop over the "reg" tuples to not exit directly upon of_address_to_resource() failure but to continue with the next "reg" tuple instead. This failure could be due to size = 0, which might be passed via the device-tree.

This is needed for boards, where a "reg" tuple might have size 0 (of_address_to_resource() returns with EINVAL when size = 0).

Example:

Fully equipped board:

	reg = <0 0x00000000 0x00400000
	       0 0x00400000 0x00400000>;

Partially equipped board:

	reg = <0 0x00000000 0x00400000
	       0 0x00400000 0x00000000>;
Quoted 8 lines

This could be the case on boards with runtime detection of multiple NOR flash configurations where the detected flash size is inserted into the dtb in U-Boot.

---
 drivers/mtd/maps/physmap_of.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

Pushed to l2-mtd-2.6.git, thanks!

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)