kernel: add support for enabling fit firmware partition parser via cmdline
[openwrt/staging/noltari.git] / target / linux / generic / files / drivers / mtd / mtdsplit / mtdsplit_fit.c
index 67ee33d085c74aa07f57f2e981ecfc6235183b41..5cc1658dbde61996156741da52eddaf5044f0f52 100644 (file)
@@ -49,6 +49,8 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
                   const struct mtd_partition **pparts,
                   struct mtd_part_parser_data *data)
 {
+       struct device_node *np = mtd_get_of_node(mtd);
+       const char *cmdline_match = NULL;
        struct fdt_header hdr;
        size_t hdr_len, retlen;
        size_t offset;
@@ -57,6 +59,10 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
        struct mtd_partition *parts;
        int ret;
 
+       of_property_read_string(np, "openwrt,cmdline-match", &cmdline_match);
+       if (cmdline_match && !strstr(saved_command_line, cmdline_match))
+               return -ENODEV;
+
        hdr_len = sizeof(struct fdt_header);
 
        /* Parse the MTD device & search for the FIT image location */