diff mbox series

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

Message ID 20180529150642.5335-1-gch981213@gmail.com
State Rejected
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel,RESEND] ath79: Add compatible strings for tp-link partition parser | expand

Commit Message

Chuanhong Guo May 29, 2018, 3:06 p.m. UTC
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@gmail.com>
---
Resend this patch due to the missing commit message :(
 .../ath79/files/drivers/mtd/tplinkpart.c      | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Chuanhong Guo May 29, 2018, 3:20 p.m. UTC | #1
After reading the code I found an ugly way to pass art location by defining
meaningless nodes somewhere with only a label inside it.
So my final dts here:
     spiflash: spi-nor@0 {
         #address-cells = <1>;
         #size-cells = <1>;
         compatible = "jedec,spi-nor";
         spi-max-frequency = <104000000>;
         reg = <0>;
         partitions {
             compatible = "tp-link";

             uboot: whatever1 {
                 label = "u-boot";
             };

             art: whatever2 {
                 label = "art";
             };
         };
     };

Still wondering if there could be other better solutions for this :(
Chuanhong Guo <gch981213@gmail.com> 于2018年5月29日周二 下午11:07写道:

> 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@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@openwrt.org>");
> +MODULE_ALIAS("tp-link");
> +MODULE_ALIAS("tp-link-64k");
> --
> 2.17.0
diff mbox series

Patch

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@openwrt.org>");
+MODULE_ALIAS("tp-link");
+MODULE_ALIAS("tp-link-64k");