Skip to contentSkip to conversation

Change linking order of SPI and MTD.

PATCH NAK Shawn J. Goff 3 participants 5 messages May 1, 2012 – May 2, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Change linking order of SPI and MTD.

From: "Shawn J. Goff" <[email protected]>

Currently, UBI initializes before SPI. This is a problem if you intend to boot to a UBI volume on an SPI device. UBI will fail to initialize with the following message:

UBI error: ubi_init: UBI error: cannot initialize UBI, error -19

The initialization order is determined by the order the modules are linked into the kernel, so the fix was to change this order. UBI is under the MTD tree, so SPI is now linked in before MTD.

---
 drivers/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/Makefile +1 -1
index c07be02..0ccc4b1 100644
@@ -51,8 +51,8 @@ obj-$(CONFIG_IDE)		+= ide/
 obj-$(CONFIG_SCSI)		+= scsi/
 obj-$(CONFIG_ATA)		+= ata/
 obj-$(CONFIG_TARGET_CORE)	+= target/
-obj-$(CONFIG_MTD)		+= mtd/
 obj-$(CONFIG_SPI)		+= spi/
+obj-$(CONFIG_MTD)		+= mtd/
 obj-y				+= net/
 obj-$(CONFIG_ATM)		+= atm/
 obj-$(CONFIG_FUSION)		+= message/
Signature · 1 line
1.7.10
#1 lore raw
Quoted 11 lines · Shawn J. Goff

From: "Shawn J. Goff" <[email protected]>

Currently, UBI initializes before SPI. This is a problem if you intend to boot to a UBI volume on an SPI device.  UBI will fail to initialize with the following message:

UBI error: ubi_init: UBI error: cannot initialize UBI, error -19

The initialization order is determined by the order the modules are linked into the kernel, so the fix was to change this order. UBI is under the MTD tree, so SPI is now linked in before MTD.

Could EPROBE_DEFER help in this case?

#2 lore raw
Quoted 7 lines · Fabio Estevam
Quoted 6 lines · Shawn J. Goff

From: "Shawn J. Goff" <[email protected]>

Currently, UBI initializes before SPI. This is a problem if you intend to boot to a UBI volume on an SPI device.  UBI will fail to initialize with the following message:

Quoted 7 lines
Quoted 5 lines

UBI error: ubi_init: UBI error: cannot initialize UBI, error -19

The initialization order is determined by the order the modules are linked into the kernel, so the fix was to change this order. UBI is under the MTD tree, so SPI is now linked in before MTD.

Could EPROBE_DEFER help in this case?

I hadn't known about EPROBE_DEFER until now. If it does help, that's probably a better solution. I'll look into it, but it'll be at least a few days before I'm able to spend time on it.

#3 lore raw
Quoted 5 lines · Shawn J. Goff
Quoted 1 line

Could EPROBE_DEFER help in this case?

I hadn't known about EPROBE_DEFER until now. If it does help, that's probably a better solution. I'll look into it, but it'll be at least a few days before I'm able to spend time on it.

If you have a chance, please try the patch below:

drivers/mtd/ubi/build.c +1 -1
@@ -1223,7 +1223,7 @@ static int __init ubi_init(void)
 
                mtd = open_mtd_device(p->name);
                if (IS_ERR(mtd)) {
-                       err = PTR_ERR(mtd);
+                       err = -EPROBE_DEFER;
                        goto out_detach;
                }
#4 lore raw
In reply to Shawn J. Goff
Quoted 3 lines · Shawn J. Goff

Currently, UBI initializes before SPI. This is a problem if you intend to boot to a UBI volume on an SPI device.  UBI will fail to initialize with the following message:

this is why many SPI bus masters use subsys_initcall() now

Quoted 3 lines

The initialization order is determined by the order the modules are linked into the kernel, so the fix was to change this order. UBI is under the MTD tree, so SPI is now linked in before MTD.

NAK: linking order is arbitrary and always has been -mike