[less intrusive PATCH,RFC] don't load physmap if length is zero

Lennert Buytenhek buytenh at wantstofly.org
Tue Feb 28 14:16:42 EST 2006

OK, so if the previous patch (which converted physmap into a platform
driver) was too nonobvious, can we at least apply a patch like this so
that it's possible to compile in physmap without using it?

This is useful for example on the Technologic Systems TS-72xx boards,
where some models in the series have NOR flash while others have NAND
flash, and you'd like to be able to compile a single kernel that works
on all models.  (So for the NOR models, you call physmap_configure at
run time, while for the NAND models, you initialise the board-specific
NAND driver (which I shall submit later.))

I'd still prefer the platform driver patch to be applied, but having
some kind of solution merged is better than no solution at all :-)

-- CUT HERE --
Allow compiling in the physmap mtd map driver without using it --
this is useful for multi-machine kernels where some of the supported
machines need physmap while others do not.

Signed-off-by: Lennert Buytenhek <buytenh at wantstofly.org>

diff -urN linux-2.6.15.orig/drivers/mtd/maps/Kconfig linux-2.6.15/drivers/mtd/maps/Kconfig
--- linux-2.6.15.orig/drivers/mtd/maps/Kconfig	2006-02-12 10:22:16.000000000 +0100
+++ linux-2.6.15/drivers/mtd/maps/Kconfig	2006-02-28 20:03:36.000000000 +0100
@@ -37,7 +37,7 @@
 	hex "Physical length of flash mapping"
 	depends on MTD_PHYSMAP
-	default "0x4000000"
+	default "0"
 	  This is the total length of the mapping of the flash chips on
 	  your particular board. If there is space, or aliases, in the
diff -urN linux-2.6.15.orig/drivers/mtd/maps/physmap.c linux-2.6.15/drivers/mtd/maps/physmap.c
--- linux-2.6.15.orig/drivers/mtd/maps/physmap.c	2006-02-12 10:22:16.000000000 +0100
+++ linux-2.6.15/drivers/mtd/maps/physmap.c	2006-02-20 21:14:23.000000000 +0100
@@ -51,6 +51,9 @@
 	static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", NULL };
 	const char **type;
+	if (!physmap_map.size)
+		return -EIO;
        	printk(KERN_NOTICE "physmap flash device: %lx at %lx\n", physmap_map.size, physmap_map.phys);
 	physmap_map.virt = ioremap(physmap_map.phys, physmap_map.size);

More information about the linux-mtd mailing list