aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-02-12 07:23:40 +0000
committerRafał Miłecki <zajec5@gmail.com>2015-02-12 07:23:40 +0000
commit8f970a79ae18422f46bc073416d6575ac863e998 (patch)
tree65290a118e3eb026b4a8aba8872674b5595dc833
parentf43fbf249693c8c93de5c877b8668020f4c1952d (diff)
downloadmaster-187ad058-8f970a79ae18422f46bc073416d6575ac863e998.tar.gz
master-187ad058-8f970a79ae18422f46bc073416d6575ac863e998.tar.bz2
master-187ad058-8f970a79ae18422f46bc073416d6575ac863e998.zip
kernel: mtdsplit_uimage: add parser for Edimax devices
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@44413 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index fa89f33ac0..04a0eb47d7 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -295,10 +295,63 @@ static struct mtd_part_parser uimage_netgear_parser = {
.type = MTD_PARSER_TYPE_FIRMWARE,
};
+/**************************************************
+ * Edimax
+ **************************************************/
+
+#define FW_EDIMAX_OFFSET 20
+#define FW_MAGIC_EDIMAX 0x43535953
+
+static ssize_t uimage_find_edimax(u_char *buf, size_t len)
+{
+ struct uimage_header *header;
+
+ if (len < FW_EDIMAX_OFFSET + sizeof(*header)) {
+ pr_err("Buffer too small for checking Edimax header\n");
+ return -ENOSPC;
+ }
+
+ header = (struct uimage_header *)(buf + FW_EDIMAX_OFFSET);
+
+ switch be32_to_cpu(header->ih_magic) {
+ case FW_MAGIC_EDIMAX:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (header->ih_os != IH_OS_LINUX ||
+ header->ih_type != IH_TYPE_FILESYSTEM)
+ return -EINVAL;
+
+ return FW_EDIMAX_OFFSET;
+}
+
+static int
+mtdsplit_uimage_parse_edimax(struct mtd_info *master,
+ struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data)
+{
+ return __mtdsplit_parse_uimage(master, pparts, data,
+ uimage_find_edimax);
+}
+
+static struct mtd_part_parser uimage_edimax_parser = {
+ .owner = THIS_MODULE,
+ .name = "edimax-fw",
+ .parse_fn = mtdsplit_uimage_parse_edimax,
+ .type = MTD_PARSER_TYPE_FIRMWARE,
+};
+
+/**************************************************
+ * Init
+ **************************************************/
+
static int __init mtdsplit_uimage_init(void)
{
register_mtd_parser(&uimage_generic_parser);
register_mtd_parser(&uimage_netgear_parser);
+ register_mtd_parser(&uimage_edimax_parser);
return 0;
}