aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic
diff options
context:
space:
mode:
authorBirger Koblitz <git@birger-koblitz.de>2020-09-11 17:36:49 +0200
committerJohn Crispin <john@phrozen.org>2020-09-14 07:54:30 +0200
commit7bb1bd469e98ba4bfd0cf774a82c35039c9b721a (patch)
tree2df71729165bf4d828cc66865da91339b335d46f /target/linux/generic
parenta9790dff532e154a93b12abaeccd7889d9159791 (diff)
downloadupstream-7bb1bd469e98ba4bfd0cf774a82c35039c9b721a.tar.gz
upstream-7bb1bd469e98ba4bfd0cf774a82c35039c9b721a.tar.bz2
upstream-7bb1bd469e98ba4bfd0cf774a82c35039c9b721a.zip
kernel: add support for ALLNET devices in mtdsplit
Add support for uimage headers from ALLNET and provide support for the SG8208M and SG8310PM devices' magic bytes. Signed-off-by: Birger Koblitz <git@birger-koblitz.de>
Diffstat (limited to 'target/linux/generic')
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c50
1 files changed, 50 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 7a9ec8acde..281175bae7 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -319,8 +319,57 @@ static struct mtd_part_parser uimage_netgear_parser = {
.of_match_table = mtdsplit_uimage_netgear_of_match_table,
.parse_fn = mtdsplit_uimage_parse_netgear,
.type = MTD_PARSER_TYPE_FIRMWARE,
+
+};
+
+
+/**************************************************
+ * ALLNET
+ **************************************************/
+
+#define FW_MAGIC_SG8208M 0x00000006
+#define FW_MAGIC_SG8310PM 0x83000006
+
+static ssize_t uimage_verify_allnet(u_char *buf, size_t len, int *extralen)
+{
+ struct uimage_header *header = (struct uimage_header *)buf;
+
+ switch (be32_to_cpu(header->ih_magic)) {
+ case FW_MAGIC_SG8208M:
+ case FW_MAGIC_SG8310PM:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (header->ih_os != IH_OS_LINUX)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int
+mtdsplit_uimage_parse_allnet(struct mtd_info *master,
+ const struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data)
+{
+ return __mtdsplit_parse_uimage(master, pparts, data,
+ uimage_verify_allnet);
+}
+
+static const struct of_device_id mtdsplit_uimage_allnet_of_match_table[] = {
+ { .compatible = "allnet,uimage" },
+ {},
};
+static struct mtd_part_parser uimage_allnet_parser = {
+ .owner = THIS_MODULE,
+ .name = "allnet-fw",
+ .of_match_table = mtdsplit_uimage_allnet_of_match_table,
+ .parse_fn = mtdsplit_uimage_parse_allnet,
+};
+
+
/**************************************************
* Edimax
**************************************************/
@@ -505,6 +554,7 @@ static int __init mtdsplit_uimage_init(void)
{
register_mtd_parser(&uimage_generic_parser);
register_mtd_parser(&uimage_netgear_parser);
+ register_mtd_parser(&uimage_allnet_parser);
register_mtd_parser(&uimage_edimax_parser);
register_mtd_parser(&uimage_fonfxc_parser);
register_mtd_parser(&uimage_sge_parser);