]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mtd: parsers: ofpart: Remove code/data for disabled custom parsers
authorDaniel Palmer <daniel@thingy.jp>
Sun, 4 Jan 2026 10:01:51 +0000 (19:01 +0900)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 19 Jan 2026 10:16:23 +0000 (11:16 +0100)
Currently even if none of the custom parsers are selected a struct
of_device_id and a dummy function that just returns -EOPNOTSUPP is
compiled in for each of them.

Its not obvious from the code but struct of_device_id is massive,
196 or 200 bytes (see link), so this is a lot more wasteful than you'd
think just skimming the code and assuming the wasted size is just the
length of the string with some small overhead.

If they aren't enabled use ifdef's to avoid anything being compiled
in and remove the dummy functions.

Link: https://lore.kernel.org/all/ef59d6fd3b2201b912d5eaa7f7a037d8f9adb744.1636561068.git.geert+renesas@glider.be/
Signed-off-by: Daniel Palmer <daniel@thingy.jp>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/parsers/ofpart_bcm4908.h
drivers/mtd/parsers/ofpart_core.c
drivers/mtd/parsers/ofpart_linksys_ns.h

index 80f8c086641fb0cc6dbcbecc22352067fa66c5bf..f96dcd5275a7eac2653e012ff45b358265b6629f 100644 (file)
@@ -4,12 +4,6 @@
 
 #ifdef CONFIG_MTD_OF_PARTS_BCM4908
 int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
-#else
-static inline int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts,
-                                               int nr_parts)
-{
-       return -EOPNOTSUPP;
-}
 #endif
 
 #endif
index abfa687989182f03a7207decae5337135c1b40c8..e04eee028f63c5f450f0fe9c891e344941f9cc94 100644 (file)
@@ -23,13 +23,17 @@ struct fixed_partitions_quirks {
        int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
 };
 
+#ifdef CONFIG_MTD_OF_PARTS_BCM4908
 static struct fixed_partitions_quirks bcm4908_partitions_quirks = {
        .post_parse = bcm4908_partitions_post_parse,
 };
+#endif
 
+#ifdef CONFIG_MTD_OF_PARTS_LINKSYS_NS
 static struct fixed_partitions_quirks linksys_ns_partitions_quirks = {
        .post_parse = linksys_ns_partitions_post_parse,
 };
+#endif
 
 static const struct of_device_id parse_ofpart_match_table[];
 
@@ -192,8 +196,12 @@ static const struct of_device_id parse_ofpart_match_table[] = {
        /* Generic */
        { .compatible = "fixed-partitions" },
        /* Customized */
+#ifdef CONFIG_MTD_OF_PARTS_BCM4908
        { .compatible = "brcm,bcm4908-partitions", .data = &bcm4908_partitions_quirks, },
+#endif
+#ifdef CONFIG_MTD_OF_PARTS_LINKSYS_NS
        { .compatible = "linksys,ns-partitions", .data = &linksys_ns_partitions_quirks, },
+#endif
        {},
 };
 MODULE_DEVICE_TABLE(of, parse_ofpart_match_table);
index 730c46812ebfd38eba98a231c3f4fe94271c6a0b..6537aa37c0aa159346a8082c349477b7a0676909 100644 (file)
@@ -6,13 +6,6 @@
 int linksys_ns_partitions_post_parse(struct mtd_info *mtd,
                                     struct mtd_partition *parts,
                                     int nr_parts);
-#else
-static inline int linksys_ns_partitions_post_parse(struct mtd_info *mtd,
-                                                  struct mtd_partition *parts,
-                                                  int nr_parts)
-{
-       return -EOPNOTSUPP;
-}
 #endif
 
 #endif