remove squashfs repartitioning hacks from spiflash driver - will be ported to redboot parsing code later
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6308 3c298f89-4303-0410-b956-a3cf2f4a3e73master
parent
b7e5e78ae6
commit
6f56a219b4
|
@ -396,15 +396,9 @@ static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
|
|||
|
||||
static int spiflash_probe(struct platform_device *pdev)
|
||||
{
|
||||
int result = -1, i, j;
|
||||
u32 len;
|
||||
int result = -1;
|
||||
int index, num_parts;
|
||||
struct mtd_info *mtd;
|
||||
struct mtd_partition *mtd_parts;
|
||||
char *buf;
|
||||
struct mtd_partition *part;
|
||||
struct squashfs_super_block *sb;
|
||||
u32 config_start;
|
||||
|
||||
spidata->spiflash_mmraddr = ioremap_nocache(SPI_FLASH_MMR, SPI_FLASH_MMR_SIZE);
|
||||
|
||||
|
@ -476,73 +470,17 @@ static int spiflash_probe(struct platform_device *pdev)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* parse redboot partitions */
|
||||
num_parts = parse_mtd_partitions(mtd, part_probe_types, &spidata->parsed_parts, 0);
|
||||
|
||||
mtd_parts = kzalloc(sizeof(struct mtd_partition) * MAX_PARTS, GFP_KERNEL);
|
||||
buf = kmalloc(mtd->erasesize, GFP_KERNEL);
|
||||
sb = (struct squashfs_super_block *) buf;
|
||||
for (i = j = 0; i < num_parts; i++, j++) {
|
||||
part = &mtd_parts[j];
|
||||
memcpy(part, &spidata->parsed_parts[i], sizeof(struct mtd_partition));
|
||||
|
||||
if (!strcmp(part->name, ROOTFS_NAME)) {
|
||||
/* create the root device */
|
||||
ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, i);
|
||||
|
||||
part->size -= mtd->erasesize;
|
||||
config_start = part->offset + part->size;
|
||||
|
||||
while ((mtd->read(mtd, part->offset, mtd->erasesize, &len, buf) == 0) &&
|
||||
(len == mtd->erasesize) &&
|
||||
(*((u32 *) buf) == SQUASHFS_MAGIC) &&
|
||||
(sb->bytes_used > 0)) {
|
||||
|
||||
/* this is squashfs, allocate another partition starting from the end of filesystem data */
|
||||
memcpy(&mtd_parts[j + 1], part, sizeof(struct mtd_partition));
|
||||
|
||||
len = (u32) sb->bytes_used;
|
||||
len += (part->offset & 0x000fffff);
|
||||
len += (mtd->erasesize - 1);
|
||||
len &= ~(mtd->erasesize - 1);
|
||||
len -= (part->offset & 0x000fffff);
|
||||
|
||||
if (len + mtd->erasesize > part->size)
|
||||
break;
|
||||
|
||||
part = &mtd_parts[++j];
|
||||
|
||||
part->offset += len;
|
||||
part->size -= len;
|
||||
|
||||
part->name = kmalloc(10, GFP_KERNEL);
|
||||
sprintf(part->name, "rootfs%d", j - i);
|
||||
}
|
||||
}
|
||||
if (!strcmp(part->name, "RedBoot config")) {
|
||||
/* add anoterh partition for the board config data */
|
||||
memcpy(&mtd_parts[j + 1], part, sizeof(struct mtd_partition));
|
||||
j++;
|
||||
part = &mtd_parts[j];
|
||||
part->offset += part->size;
|
||||
part->size = mtd->erasesize;
|
||||
|
||||
part->name = kmalloc(16, GFP_KERNEL);
|
||||
sprintf(part->name, "board_config");
|
||||
}
|
||||
}
|
||||
num_parts += j - i;
|
||||
kfree(buf);
|
||||
|
||||
#ifdef SPIFLASH_DEBUG
|
||||
printk (KERN_DEBUG "Found %d redboot partitions\n", num_parts);
|
||||
printk (KERN_DEBUG "Found %d partitions\n", num_parts);
|
||||
#endif
|
||||
if (num_parts) {
|
||||
result = add_mtd_partitions(mtd, mtd_parts, num_parts);
|
||||
result = add_mtd_partitions(mtd, spidata->parsed_parts, num_parts);
|
||||
} else {
|
||||
#ifdef SPIFLASH_DEBUG
|
||||
printk (KERN_DEBUG "Did not find any redboot partitions\n");
|
||||
printk (KERN_DEBUG "Did not find any partitions\n");
|
||||
#endif
|
||||
kfree(mtd);
|
||||
kfree(spidata);
|
||||
|
|
Loading…
Reference in New Issue