From ee926862aed998c8cb26c38dfae710ea4edc06f1 Mon Sep 17 00:00:00 2001 From: Fedor Date: Thu, 10 Dec 2009 14:43:49 -0500 Subject: [PATCH] kernel 2.6 MTD partitions init fix --- release/src-rt/linux/linux-2.6/drivers/mtd/devices/sflash.c | 4 +++- release/src-rt/linux/linux-2.6/drivers/mtd/maps/bcm947xx-flash.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/release/src-rt/linux/linux-2.6/drivers/mtd/devices/sflash.c b/release/src-rt/linux/linux-2.6/drivers/mtd/devices/sflash.c index 5d89058367..110be9fc50 100644 --- a/release/src-rt/linux/linux-2.6/drivers/mtd/devices/sflash.c +++ b/release/src-rt/linux/linux-2.6/drivers/mtd/devices/sflash.c @@ -189,6 +189,7 @@ sflash_mtd_init(void) struct pci_dev *dev = NULL; #ifdef CONFIG_MTD_PARTITIONS struct mtd_partition *parts; + int i; #endif list_for_each_entry(dev, &((pci_find_bus(0, 0))->devices), bus_list) { @@ -250,7 +251,8 @@ sflash_mtd_init(void) #ifdef CONFIG_MTD_PARTITIONS parts = init_mtd_partitions(&sflash.mtd, sflash.mtd.size); - ret = add_mtd_partitions(&sflash.mtd, parts, 4); + for (i = 0; parts[i].name; i++); + ret = add_mtd_partitions(&sflash.mtd, parts, i); if (ret) { printk(KERN_ERR "sflash: add_mtd failed\n"); goto fail; diff --git a/release/src-rt/linux/linux-2.6/drivers/mtd/maps/bcm947xx-flash.c b/release/src-rt/linux/linux-2.6/drivers/mtd/maps/bcm947xx-flash.c index 44b0b37d51..2d4cbb4657 100644 --- a/release/src-rt/linux/linux-2.6/drivers/mtd/maps/bcm947xx-flash.c +++ b/release/src-rt/linux/linux-2.6/drivers/mtd/maps/bcm947xx-flash.c @@ -83,6 +83,7 @@ init_bcm947xx_map(void) int ret = 0; #ifdef CONFIG_MTD_PARTITIONS struct mtd_partition *parts; + int i; #endif spin_lock_irqsave(&sih_lock, flags); @@ -136,7 +137,8 @@ init_bcm947xx_map(void) #ifdef CONFIG_MTD_PARTITIONS parts = init_mtd_partitions(bcm947xx_mtd, size); - ret = add_mtd_partitions(bcm947xx_mtd, parts, 4); + for (i = 0; parts[i].name; i++); + ret = add_mtd_partitions(bcm947xx_mtd, parts, i); if (ret) { printk(KERN_ERR "pflash: add_mtd_partitions failed\n"); goto fail; -- 2.11.4.GIT