-diff -Nur linux-2.6.12.5/drivers/mtd/maps/bcm47xx-flash.c linux-2.6.12.5-flash/drivers/mtd/maps/bcm47xx-flash.c
---- linux-2.6.12.5/drivers/mtd/maps/bcm47xx-flash.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.12.5-flash/drivers/mtd/maps/bcm47xx-flash.c 2005-11-06 20:36:42.553198500 +0100
-@@ -0,0 +1,329 @@
+diff -Nur linux-2.6.15-rc5/drivers/mtd/maps/bcm47xx-flash.c linux-2.6.15-rc5-flash/drivers/mtd/maps/bcm47xx-flash.c
+--- linux-2.6.15-rc5/drivers/mtd/maps/bcm47xx-flash.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.15-rc5-flash/drivers/mtd/maps/bcm47xx-flash.c 2005-12-18 23:40:45.060006250 +0100
+@@ -0,0 +1,321 @@
+/*
+ * Copyright (C) 2004 Florian Schirmer (jolt@tuxbox.org)
+ * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
-+ * $Id: bcm47xx-flash.c,v 1.1 2004/10/21 07:18:31 jolt Exp $
-+ *
+ * Flash mapping for BCM947XX boards
+ */
+
+#include <asm/io.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
++#ifdef CONFIG_MTD_PARTITIONS
+#include <linux/mtd/partitions.h>
++#endif
+#include <linux/config.h>
-+#include <typedefs.h>
-+#include <bcmutils.h>
-+#include <bcmnvram.h>
-+#include <trxhdr.h>
-+
+
-+#ifdef CONFIG_MTD_PARTITIONS
-+extern struct mtd_partition * init_mtd_partitions(struct mtd_info *mtd, size_t size);
-+#endif
++#include <trxhdr.h>
+
+#define WINDOW_ADDR 0x1c000000
+#define WINDOW_SIZE (0x400000*2)
+
+ int cfe_size_flag;
+
-+ cfe_size_flag = find_cfe_size(mtd,size);
-+
+ /* if cfe_size_flag=0, cfe size is 256 kb, else 384 kb */
++ cfe_size_flag = find_cfe_size(mtd, size);
+
+ /* boot loader */
+ bcm947xx_parts[0].offset = 0;
+ /* nvram */
+ if (cfe_size_flag == 0) {
+ bcm947xx_parts[3].offset = size - mtd->erasesize;
-+ bcm947xx_parts[3].size = mtd->erasesize;
+ } else {
+ /* nvram (old 128kb config partition on netgear wgt634u) */
+ bcm947xx_parts[3].offset = bcm947xx_parts[0].size;
-+ bcm947xx_parts[3].size = 1024*128;
+ }
++ bcm947xx_parts[3].size = mtd->erasesize;
+
+ /* linux (kernel and rootfs) */
+ if (cfe_size_flag == 0) {
+ bcm947xx_parts[1].size = bcm947xx_parts[3].offset -
+ bcm947xx_parts[1].offset;
+ } else {
-+ /* do not count the elf loader, which is on one sector */
++ /* do not count the elf loader, which is on one block */
+ bcm947xx_parts[1].offset = bcm947xx_parts[0].size +
+ bcm947xx_parts[3].size + mtd->erasesize;
+ bcm947xx_parts[1].size = size -
+ /* entirely jffs2 */
+ bcm947xx_parts[4].name = NULL;
+ if (cfe_size_flag == 0) {
-+ bcm947xx_parts[2].size = bcm947xx_parts[3].offset -
-+ bcm947xx_parts[2].offset;
++ bcm947xx_parts[2].size = size - bcm947xx_parts[2].offset -
++ bcm947xx_parts[3].size;
+ } else {
+ bcm947xx_parts[2].size = size - bcm947xx_parts[2].offset -
+ bcm947xx_parts[3].size;
+ if (cfe_size_flag == 0) {
+ bcm947xx_parts[4].offset = bcm947xx_parts[2].offset +
+ bcm947xx_parts[2].size;
++ if ((bcm947xx_parts[4].offset % mtd->erasesize) > 0) {
++ bcm947xx_parts[4].offset += mtd->erasesize -
++ (bcm947xx_parts[4].offset % mtd->erasesize);
++ }
+ bcm947xx_parts[4].size = bcm947xx_parts[3].offset -
+ bcm947xx_parts[4].offset;
+ } else {
+
+ return bcm947xx_parts;
+}
-+
-+EXPORT_SYMBOL(init_mtd_partitions);
+#endif
+
+int __init init_bcm947xx_map(void)
+
+ size = bcm947xx_mtd->size;
+
-+ printk(KERN_NOTICE "Flash device: 0x%x at 0x%x\n", bcm947xx_mtd->size, WINDOW_ADDR);
++ printk(KERN_NOTICE "Flash device: 0x%x at 0x%x\n", size, WINDOW_ADDR);
+
+#ifdef CONFIG_MTD_PARTITIONS
+ parts = init_mtd_partitions(bcm947xx_mtd, size);
+ goto fail;
+ }
+#endif
-+
+ return 0;
+
+ fail:
+ if (bcm947xx_mtd)
+ map_destroy(bcm947xx_mtd);
-+ if (bcm947xx_map.map_priv_1)
-+ iounmap((void *) bcm947xx_map.map_priv_1);
-+ bcm947xx_map.map_priv_1 = 0;
++ if (bcm947xx_map.virt)
++ iounmap((void *)bcm947xx_map.virt);
++ bcm947xx_map.virt = 0;
+ return ret;
+}
+
+
+module_init(init_bcm947xx_map);
+module_exit(cleanup_bcm947xx_map);
-diff -Nur linux-2.6.12.5/drivers/mtd/maps/Kconfig linux-2.6.12.5-flash/drivers/mtd/maps/Kconfig
---- linux-2.6.12.5/drivers/mtd/maps/Kconfig 2005-08-15 02:20:18.000000000 +0200
-+++ linux-2.6.12.5-flash/drivers/mtd/maps/Kconfig 2005-09-16 22:27:36.000000000 +0200
-@@ -357,6 +357,12 @@
+diff -Nur linux-2.6.15-rc5/drivers/mtd/maps/Kconfig linux-2.6.15-rc5-flash/drivers/mtd/maps/Kconfig
+--- linux-2.6.15-rc5/drivers/mtd/maps/Kconfig 2005-12-04 06:10:42.000000000 +0100
++++ linux-2.6.15-rc5-flash/drivers/mtd/maps/Kconfig 2005-12-18 19:36:11.555087000 +0100
+@@ -299,6 +299,12 @@
Mapping for the Flaga digital module. If you don't have one, ignore
this setting.
+
config MTD_BEECH
tristate "CFI Flash device mapped on IBM 405LP Beech"
- depends on MTD_CFI && PPC32 && 40x && BEECH
-diff -Nur linux-2.6.12.5/drivers/mtd/maps/Makefile linux-2.6.12.5-flash/drivers/mtd/maps/Makefile
---- linux-2.6.12.5/drivers/mtd/maps/Makefile 2005-08-15 02:20:18.000000000 +0200
-+++ linux-2.6.12.5-flash/drivers/mtd/maps/Makefile 2005-09-16 22:27:01.000000000 +0200
+ depends on MTD_CFI && BEECH
+diff -Nur linux-2.6.15-rc5/drivers/mtd/maps/Makefile linux-2.6.15-rc5-flash/drivers/mtd/maps/Makefile
+--- linux-2.6.15-rc5/drivers/mtd/maps/Makefile 2005-12-04 06:10:42.000000000 +0100
++++ linux-2.6.15-rc5-flash/drivers/mtd/maps/Makefile 2005-12-18 19:36:11.555087000 +0100
@@ -31,6 +31,7 @@
obj-$(CONFIG_MTD_PCMCIA) += pcmciamtd.o
obj-$(CONFIG_MTD_RPXLITE) += rpxlite.o