Skip to content

Commit 56477ae

Browse files
fifteenhexmiquelraynal
authored andcommitted
mtd: parsers: ofpart: Remove code/data for disabled custom parsers
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>
1 parent 8f0b4cc commit 56477ae

3 files changed

Lines changed: 8 additions & 13 deletions

File tree

drivers/mtd/parsers/ofpart_bcm4908.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
#ifdef CONFIG_MTD_OF_PARTS_BCM4908
66
int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
7-
#else
8-
static inline int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts,
9-
int nr_parts)
10-
{
11-
return -EOPNOTSUPP;
12-
}
137
#endif
148

159
#endif

drivers/mtd/parsers/ofpart_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ struct fixed_partitions_quirks {
2323
int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
2424
};
2525

26+
#ifdef CONFIG_MTD_OF_PARTS_BCM4908
2627
static struct fixed_partitions_quirks bcm4908_partitions_quirks = {
2728
.post_parse = bcm4908_partitions_post_parse,
2829
};
30+
#endif
2931

32+
#ifdef CONFIG_MTD_OF_PARTS_LINKSYS_NS
3033
static struct fixed_partitions_quirks linksys_ns_partitions_quirks = {
3134
.post_parse = linksys_ns_partitions_post_parse,
3235
};
36+
#endif
3337

3438
static const struct of_device_id parse_ofpart_match_table[];
3539

@@ -192,8 +196,12 @@ static const struct of_device_id parse_ofpart_match_table[] = {
192196
/* Generic */
193197
{ .compatible = "fixed-partitions" },
194198
/* Customized */
199+
#ifdef CONFIG_MTD_OF_PARTS_BCM4908
195200
{ .compatible = "brcm,bcm4908-partitions", .data = &bcm4908_partitions_quirks, },
201+
#endif
202+
#ifdef CONFIG_MTD_OF_PARTS_LINKSYS_NS
196203
{ .compatible = "linksys,ns-partitions", .data = &linksys_ns_partitions_quirks, },
204+
#endif
197205
{},
198206
};
199207
MODULE_DEVICE_TABLE(of, parse_ofpart_match_table);

drivers/mtd/parsers/ofpart_linksys_ns.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
int linksys_ns_partitions_post_parse(struct mtd_info *mtd,
77
struct mtd_partition *parts,
88
int nr_parts);
9-
#else
10-
static inline int linksys_ns_partitions_post_parse(struct mtd_info *mtd,
11-
struct mtd_partition *parts,
12-
int nr_parts)
13-
{
14-
return -EOPNOTSUPP;
15-
}
169
#endif
1710

1811
#endif

0 commit comments

Comments
 (0)