block2mtd.c: Make kernel boot command line arguments work (try 4)
authorVille Herva <vherva@vianova.fi>
Thu, 13 Jul 2006 21:31:16 +0000 (00:31 +0300)
committerDavid Woodhouse <dwmw2@infradead.org>
Sat, 15 Jul 2006 12:39:10 +0000 (13:39 +0100)
commitc4e7fb313771ac03dfdca26d30e8b721731c562b
treece57227007ea980dcd37e5f7af3bc6b83a91a3bf
parent9a909867d2eca7727d0d5884df96e791e3531f24
block2mtd.c: Make kernel boot command line arguments work (try 4)

Trying to pass kernel command line arguments to block2mtd at boot-time does
not work currently. block2mtd_setup() is called so early that kmalloc()
fails nevermind being able to do open_bdev_excl() (which requires rootfs to
be mounted. This patch only saves the option string at the early boot stage,
and parses them later when block2mtd_init() is called. If open_bdev_excl()
fails, open_by_devnum(name_to_dev_t()) is tried instead, which makes it
possible to initialize the driver before rootfs has been mounted. Also gets
rid of the superfluous parse_name() that only checks if name is longer than
80 chars and copies it to a string that is not kfreed.

With this patch, I can boot statically compiled block2mtd, and mount jffs2
as rootfs (without modules or initrd), with lilo config like this:

   root=/dev/mtdblock0
   append="rootfstype=jffs2 block2mtd.block2mtd=/dev/hdc2,65536"

(Note that rootfstype=jffs2 is required, since the kernel only tries
filesystems without "nodev" attribute by default, and jffs is "nodev").

Compared to first version of this patch, this one does not copy the
parameters to the global buffer if init has already been called, and the
global array is marked as __initdata.

Compared to the second version of this patch, module build is fixed.

Compared to the third version of this patch, statically compiled block2mtd
driver with no boot-time parameter no longer gives spurious error 'cannot
open device ""'

Signed-off-by: Ville Herva <vherva@vianova.fi>
Acked-by: Jörn Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
drivers/mtd/devices/block2mtd.c