diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2007-10-01 09:51:32 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2007-10-01 09:51:32 +0000 |
commit | ffec4f291341a1e158b8c13d51219fa7ecfae244 (patch) | |
tree | e9b3ff24cbab3de0861886ef146a54661bc97a10 | |
parent | 693077d7d5df84f5cf72239effbb514a478daf96 (diff) | |
download | master-31e0f0ae-ffec4f291341a1e158b8c13d51219fa7ecfae244.tar.gz master-31e0f0ae-ffec4f291341a1e158b8c13d51219fa7ecfae244.tar.bz2 master-31e0f0ae-ffec4f291341a1e158b8c13d51219fa7ecfae244.zip |
prepare trxsplit to support sysupgrade
SVN-Revision: 9085
-rw-r--r-- | target/linux/adm5120/files/arch/mips/adm5120/Makefile | 2 | ||||
-rw-r--r-- | target/linux/adm5120/files/drivers/mtd/trxsplit.c (renamed from target/linux/adm5120/files/arch/mips/adm5120/trxsplit.c) | 109 | ||||
-rw-r--r-- | target/linux/adm5120/patches-2.6.22/103-mtd_trxsplit.patch | 28 | ||||
-rw-r--r-- | target/linux/adm5120/router_be/config-2.6.22 | 1 | ||||
-rw-r--r-- | target/linux/adm5120/router_le/config-2.6.22 | 3 |
5 files changed, 95 insertions, 48 deletions
diff --git a/target/linux/adm5120/files/arch/mips/adm5120/Makefile b/target/linux/adm5120/files/arch/mips/adm5120/Makefile index 583d1d12c1..2a5f391f25 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/Makefile +++ b/target/linux/adm5120/files/arch/mips/adm5120/Makefile @@ -9,5 +9,3 @@ obj-y += gpio.o obj-y += platform.o obj-y += reset.o obj-y += time.o - -obj-y += trxsplit.o diff --git a/target/linux/adm5120/files/arch/mips/adm5120/trxsplit.c b/target/linux/adm5120/files/drivers/mtd/trxsplit.c index 941f306950..ad0e25a113 100644 --- a/target/linux/adm5120/files/arch/mips/adm5120/trxsplit.c +++ b/target/linux/adm5120/files/drivers/mtd/trxsplit.c @@ -59,7 +59,9 @@ static int trx_nr_parts = 0; static struct mtd_partition trx_parts[TRX_MAX_OFFSET]; static struct trx_header trx_hdr; -static int __init trxsplit_checktrx(struct mtd_info *mtd, unsigned long offset) +static int trxsplit_refresh_partitions(struct mtd_info *mtd); + +static int trxsplit_checktrx(struct mtd_info *mtd, unsigned long offset) { size_t retlen; int err; @@ -98,17 +100,39 @@ err_out: return -1; } -static int __init trxsplit_create_partitions(void) +static void trxsplit_findtrx(struct mtd_info *mtd) { - struct mtd_partition *part = trx_parts; - int ret = 0; - int i; + unsigned long offset; + unsigned long blocklen; + int err; - if (trx_mtd == NULL) - goto out; + blocklen = mtd->erasesize; + if (blocklen < BLOCK_LEN_MIN) + blocklen = BLOCK_LEN_MIN; - printk(KERN_INFO PFX "creating TRX partitions in '%s' (%d,%d)\n", - trx_mtd->name, MTD_BLOCK_MAJOR, trx_mtd->index); + printk(KERN_INFO PFX "searching TRX header in '%s'\n", mtd->name); + + err = 0; + for (offset=0; offset < mtd->size; offset+=blocklen) { + err = trxsplit_checktrx(mtd, offset); + if (err == 0) + break; + } + + if (err) + return; + + printk(KERN_INFO PFX "TRX header found at 0x%lX\n", offset); + + trx_mtd = mtd; + trx_offset = offset; +} + +static void trxsplit_create_partitions(struct mtd_info *mtd) +{ + struct mtd_partition *part = trx_parts; + int err; + int i; for (i=0; i<TRX_MAX_OFFSET;i++) { part = &trx_parts[i]; @@ -121,7 +145,7 @@ static int __init trxsplit_create_partitions(void) for (i=0; i<trx_nr_parts-1; i++) { trx_parts[i].size = trx_parts[i+1].offset - trx_parts[i].offset; } - trx_parts[i].size = trx_mtd->size - trx_parts[i].offset; + trx_parts[i].size = mtd->size - trx_parts[i].offset; i=0; part = &trx_parts[i]; @@ -137,46 +161,38 @@ static int __init trxsplit_create_partitions(void) part = &trx_parts[i]; part->name = "rootfs"; - ret = add_mtd_partitions(trx_mtd, trx_parts, trx_nr_parts); - if (ret) { - printk(KERN_ALERT PFX "creating TRX partitions failed\n"); + err = add_mtd_partitions(mtd, trx_parts, trx_nr_parts); + if (err) { + printk(KERN_ALERT PFX "adding TRX partitions failed\n"); + return; } -out: - return ret; + mtd->refresh_device = trxsplit_refresh_partitions; } -static void __init trxsplit_add_mtd(struct mtd_info *mtd) +static int trxsplit_refresh_partitions(struct mtd_info *mtd) { - unsigned long offset; - unsigned long blocklen; - int err; + printk(KERN_INFO PFX "refreshing TRX partitions in '%s' (%d,%d)\n", + mtd->name, MTD_BLOCK_MAJOR, mtd->index); - if (trx_mtd) - return; + /* remove old partitions */ + del_mtd_partitions(mtd); - blocklen = mtd->erasesize; - if (blocklen < BLOCK_LEN_MIN) - blocklen = BLOCK_LEN_MIN; - - printk(KERN_INFO PFX "searching TRX header in '%s'\n", mtd->name); - - err = 0; - for (offset=0; offset < mtd->size; offset+=blocklen) { - err = trxsplit_checktrx(mtd, offset); - if (err == 0) - break; - } + trxsplit_findtrx(mtd); + if (!trx_mtd) + goto err; - if (err) { - printk(KERN_ALERT PFX "no TRX header found\n"); - return; - } + trxsplit_create_partitions(trx_mtd); + return 1; - printk(KERN_INFO PFX "TRX header found at 0x%lX\n", offset); +err: + return 0; +} - trx_mtd = mtd; - trx_offset = offset; +static void __init trxsplit_add_mtd(struct mtd_info *mtd) +{ + if (!trx_mtd) + trxsplit_findtrx(mtd); } static void __init trxsplit_remove_mtd(struct mtd_info *mtd) @@ -189,7 +205,7 @@ static struct mtd_notifier trxsplit_notifier __initdata = { .remove = trxsplit_remove_mtd, }; -static void __init trxsplit_find_trx(void) +static void __init trxsplit_scan(void) { register_mtd_user(&trxsplit_notifier); unregister_mtd_user(&trxsplit_notifier); @@ -197,12 +213,15 @@ static void __init trxsplit_find_trx(void) static int __init trxsplit_init(void) { - int ret; + trxsplit_scan(); - trxsplit_find_trx(); + if (trx_mtd) { + printk(KERN_INFO PFX "creating TRX partitions in '%s' (%d,%d)\n", + trx_mtd->name, MTD_BLOCK_MAJOR, trx_mtd->index); + trxsplit_create_partitions(trx_mtd); + } - ret = trxsplit_create_partitions(); - return ret; + return 0; } late_initcall(trxsplit_init); diff --git a/target/linux/adm5120/patches-2.6.22/103-mtd_trxsplit.patch b/target/linux/adm5120/patches-2.6.22/103-mtd_trxsplit.patch new file mode 100644 index 0000000000..c623bc42e4 --- /dev/null +++ b/target/linux/adm5120/patches-2.6.22/103-mtd_trxsplit.patch @@ -0,0 +1,28 @@ +Index: linux-2.6.22.4/drivers/mtd/Kconfig +=================================================================== +--- linux-2.6.22.4.orig/drivers/mtd/Kconfig ++++ linux-2.6.22.4/drivers/mtd/Kconfig +@@ -57,6 +57,11 @@ config MTD_ROOTFS_SPLIT + depends on MTD_PARTITIONS + default y + ++config MTD_TRXSPLIT ++ bool "Automatically find and split TRX partitions" ++ depends on MTD_PARTITIONS ++ default n ++ + config MTD_REDBOOT_PARTS + tristate "RedBoot partition table parsing" + depends on MTD_PARTITIONS +Index: linux-2.6.22.4/drivers/mtd/Makefile +=================================================================== +--- linux-2.6.22.4.orig/drivers/mtd/Makefile ++++ linux-2.6.22.4/drivers/mtd/Makefile +@@ -8,6 +8,7 @@ mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart. + obj-$(CONFIG_MTD) += $(mtd-y) + + obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o ++obj-$(CONFIG_MTD_TRXSPLIT) += trxsplit.o + obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o + obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o + obj-$(CONFIG_MTD_AFS_PARTS) += afs.o diff --git a/target/linux/adm5120/router_be/config-2.6.22 b/target/linux/adm5120/router_be/config-2.6.22 index 85aad4ea71..43476e2321 100644 --- a/target/linux/adm5120/router_be/config-2.6.22 +++ b/target/linux/adm5120/router_be/config-2.6.22 @@ -164,6 +164,7 @@ CONFIG_MTD_PARTITIONS=y # CONFIG_MTD_REDBOOT_PARTS is not set # CONFIG_MTD_ROM is not set # CONFIG_MTD_SLRAM is not set +CONFIG_MTD_TRXSPLIT=y CONFIG_NETDEV_1000=y CONFIG_NET_KEY=y # CONFIG_NET_PCI is not set diff --git a/target/linux/adm5120/router_le/config-2.6.22 b/target/linux/adm5120/router_le/config-2.6.22 index c67e1404c6..a331c2a134 100644 --- a/target/linux/adm5120/router_le/config-2.6.22 +++ b/target/linux/adm5120/router_le/config-2.6.22 @@ -123,7 +123,7 @@ CONFIG_MTD=y CONFIG_MTD_ADM5120=y CONFIG_MTD_BLKDEVS=y CONFIG_MTD_BLOCK=y -CONFIG_MTD_BLOCK2MTD=y +# CONFIG_MTD_BLOCK2MTD is not set CONFIG_MTD_CFI=y # CONFIG_MTD_CFI_ADV_OPTIONS is not set CONFIG_MTD_CFI_AMDSTD=y @@ -174,6 +174,7 @@ CONFIG_MTD_PARTITIONS=y # CONFIG_MTD_REDBOOT_PARTS is not set # CONFIG_MTD_ROM is not set # CONFIG_MTD_SLRAM is not set +CONFIG_MTD_TRXSPLIT=y # CONFIG_NETDEV_1000 is not set CONFIG_NET_KEY=y # CONFIG_NET_PCI is not set |