/*
+ * $Id$
+ *
* Parse MyLoader-style flash partition tables and produce a Linux partition
* array to match.
*
#include <linux/mtd/partitions.h>
#include <linux/byteorder/generic.h>
-#include <asm/mach-adm5120/myloader.h>
+
+#include <prom/myloader.h>
#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)
{
/* 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;
/* 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;
}
num_parts++;
}
-
mtd_parts = kzalloc((num_parts*sizeof(*mtd_part) + num_parts*NAME_LEN_MAX),
GFP_KERNEL);
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;
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;
}
module_init(mylo_mtd_parser_init);
module_exit(mylo_mtd_parser_exit);
-EXPORT_SYMBOL_GPL(parse_myloader_partitions);
-
MODULE_AUTHOR("Gabor Juhos <juhosg@freemail.hu>");
MODULE_DESCRIPTION("Parsing code for MyLoader partition tables");
MODULE_LICENSE("GPL");