X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/6493ad8f6552952b463465c19a1d7b7376409438..ae505386e5e915bcd43f9f178f379da4a5df9cad:/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c diff --git a/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c b/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c index 1bdd798e4..222245cc9 100644 --- a/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c +++ b/target/linux/adm5120-2.6/files/drivers/mtd/myloader.c @@ -1,4 +1,6 @@ /* + * $Id$ + * * Parse MyLoader-style flash partition tables and produce a Linux partition * array to match. * @@ -33,14 +35,15 @@ #include #include -#include + +#include #define NAME_LEN_MAX 20 #define NAME_MYLOADER "MyLoader" #define NAME_PARTITION_TABLE "Partition Table" #define BLOCK_LEN_MIN 0x10000 -static int parse_myloader_partitions(struct mtd_info *master, +int parse_myloader_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long origin) { @@ -68,12 +71,10 @@ static int parse_myloader_partitions(struct mtd_info *master, /* Partition Table is always located on the second erase block */ offset = blocklen; - printk(KERN_NOTICE "Searching for MyLoader partition table " - "in %s at offset 0x%lx\n", master->name, offset); - - ret = master->read(master, offset, sizeof(*tab), &retlen, - (void *)tab); + printk(KERN_NOTICE "%s: searching for MyLoader partition table at " + "offset 0x%lx\n", master->name, offset); + ret = master->read(master, offset, sizeof(*tab), &retlen, (void *)tab); if (ret) goto out; @@ -84,8 +85,8 @@ static int parse_myloader_partitions(struct mtd_info *master, /* Check for Partition Table magic number */ if (tab->magic != le32_to_cpu(MYLO_MAGIC_PARTITIONS)) { - printk(KERN_NOTICE "No MyLoader partition table detected " - "in %s\n", master->name); + printk(KERN_NOTICE "%s: no MyLoader partition table found\n", + master->name); ret = 0; goto out_free_buf; } @@ -103,7 +104,6 @@ static int parse_myloader_partitions(struct mtd_info *master, num_parts++; } - mtd_parts = kzalloc((num_parts*sizeof(*mtd_part) + num_parts*NAME_LEN_MAX), GFP_KERNEL); @@ -115,17 +115,19 @@ static int parse_myloader_partitions(struct mtd_info *master, mtd_part = mtd_parts; names = (char *)&mtd_parts[num_parts]; - strcpy(NAME_MYLOADER, names); + strncpy(names, NAME_MYLOADER, NAME_LEN_MAX-1); mtd_part->name = names; mtd_part->offset = 0; mtd_part->size = blocklen; + mtd_part->mask_flags = MTD_WRITEABLE; mtd_part++; names += NAME_LEN_MAX; - strcpy(NAME_PARTITION_TABLE, names); + strncpy(names, NAME_PARTITION_TABLE, NAME_LEN_MAX-1); mtd_part->name = names; mtd_part->offset = blocklen; mtd_part->size = blocklen; + mtd_part->mask_flags = MTD_WRITEABLE; mtd_part++; names += NAME_LEN_MAX; @@ -136,9 +138,9 @@ static int parse_myloader_partitions(struct mtd_info *master, continue; sprintf(names, "partition%d", i); - mtd_part->name = names; mtd_part->offset = le32_to_cpu(part->addr); mtd_part->size = le32_to_cpu(part->size); + mtd_part->name = names; mtd_part++; names += NAME_LEN_MAX; } @@ -171,8 +173,6 @@ static void __exit mylo_mtd_parser_exit(void) module_init(mylo_mtd_parser_init); module_exit(mylo_mtd_parser_exit); -EXPORT_SYMBOL_GPL(parse_myloader_partitions); - MODULE_AUTHOR("Gabor Juhos "); MODULE_DESCRIPTION("Parsing code for MyLoader partition tables"); MODULE_LICENSE("GPL");