[OpenWrt-Devel] [PATCH][RESEND] ath79: Add compatible strings for tp-link partition parser

Chuanhong Guo gch981213 at gmail.com
Tue May 29 11:06:42 EDT 2018


This patch allows using tp-link parser by defining 'partitions' node inside m25p80 node as follow:
partitions {
	compatible = "tp-link";
};

Signed-off-by: Chuanhong Guo <gch981213 at gmail.com>
---
Resend this patch due to the missing commit message :(
 .../ath79/files/drivers/mtd/tplinkpart.c      | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/target/linux/ath79/files/drivers/mtd/tplinkpart.c b/target/linux/ath79/files/drivers/mtd/tplinkpart.c
index 1b94163b83..8da5c4168e 100644
--- a/target/linux/ath79/files/drivers/mtd/tplinkpart.c
+++ b/target/linux/ath79/files/drivers/mtd/tplinkpart.c
@@ -9,6 +9,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/magic.h>
@@ -209,16 +210,36 @@ static int tplink_parse_64k_partitions(struct mtd_info *master,
 		                              TPLINK_64K_KERNEL_OFFS);
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id parse_tplink_match_table[] = {
+	{ .compatible = "tp-link" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, parse_tplink_match_table);
+
+static const struct of_device_id parse_tplink_64k_match_table[] = {
+	{ .compatible = "tp-link-64k" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, parse_tplink_64k_match_table);
+#endif
+
 static struct mtd_part_parser tplink_parser = {
 	.owner		= THIS_MODULE,
 	.parse_fn	= tplink_parse_partitions,
 	.name		= "tp-link",
+#ifdef CONFIG_OF
+	.of_match_table = parse_tplink_match_table,
+#endif
 };
 
 static struct mtd_part_parser tplink_64k_parser = {
 	.owner		= THIS_MODULE,
 	.parse_fn	= tplink_parse_64k_partitions,
 	.name		= "tp-link-64k",
+#ifdef CONFIG_OF
+	.of_match_table = parse_tplink_64k_match_table,
+#endif
 };
 
 static int __init tplink_parser_init(void)
@@ -233,3 +254,5 @@ module_init(tplink_parser_init);
 
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
+MODULE_ALIAS("tp-link");
+MODULE_ALIAS("tp-link-64k");
-- 
2.17.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/listinfo/openwrt-devel



More information about the openwrt-devel mailing list