kernel: add DT binding support to the TRX and minor parsers
[openwrt/openwrt.git] / target / linux / generic / files / drivers / mtd / mtdsplit / mtdsplit_trx.c
index 6efffce1965bfae291389a2dacf060f22c585df4..d5e33727b5f777b8ce5355e42ac64f2fc37672f1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
 /*
  *  Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
- *  Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
+ *  Copyright (C) 2014 Felix Fietkau <nbd@nbd.name>
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms of the GNU General Public License version 2 as published
@@ -56,7 +56,7 @@ read_trx_header(struct mtd_info *mtd, size_t offset,
 
 static int
 mtdsplit_parse_trx(struct mtd_info *master,
 
 static int
 mtdsplit_parse_trx(struct mtd_info *master,
-                  struct mtd_partition **pparts,
+                  const struct mtd_partition **pparts,
                   struct mtd_part_parser_data *data)
 {
        struct mtd_partition *parts;
                   struct mtd_part_parser_data *data)
 {
        struct mtd_partition *parts;
@@ -130,9 +130,22 @@ err:
        return ret;
 }
 
        return ret;
 }
 
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+static const struct of_device_id trx_parser_of_match_table[] = {
+       { .compatible = "openwrt,trx" },
+       {},
+};
+MODULE_DEVICE_TABLE(of, trx_parser_of_match_table);
+#endif
+
 static struct mtd_part_parser trx_parser = {
        .owner = THIS_MODULE,
        .name = "trx-fw",
 static struct mtd_part_parser trx_parser = {
        .owner = THIS_MODULE,
        .name = "trx-fw",
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+       .of_match_table = trx_parser_of_match_table,
+#endif
        .parse_fn = mtdsplit_parse_trx,
        .type = MTD_PARSER_TYPE_FIRMWARE,
 };
        .parse_fn = mtdsplit_parse_trx,
        .type = MTD_PARSER_TYPE_FIRMWARE,
 };