Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: mtdpart: Don't create platform device that'll never probe

These "nvmem-cells" platform devices never get probed because there's no
platform driver for it and it's never used anywhere else. So it's a
waste of memory. These devices also cause fw_devlink to block nvmem
consumers of "nvmem-cells" partition from probing because the supplier
device never probes.

So stop creating platform devices for nvmem-cells partitions to avoid
wasting memory and to avoid blocking probing of consumers.

Reported-by: Maxim Kiselev <bigunclemax@gmail.com>
Fixes: bcdf0315a61a ("mtd: call of_platform_populate() for MTD partitions")
Signed-off-by: Saravana Kannan <saravanak@google.com>
Tested-by: Maksim Kiselev <bigunclemax@gmail.com>
Tested-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Luca Weiss <luca.weiss@fairphone.com> # qcom/sm7225-fairphone-fp4
Link: https://lore.kernel.org/r/20230207014207.1678715-13-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Saravana Kannan and committed by
Greg Kroah-Hartman
fb42378d 96da4a99

+10
+10
drivers/mtd/mtdpart.c
··· 577 577 { 578 578 struct mtd_part_parser *parser; 579 579 struct device_node *np; 580 + struct device_node *child; 580 581 struct property *prop; 581 582 struct device *dev; 582 583 const char *compat; ··· 594 593 of_node_get(np); 595 594 else 596 595 np = of_get_child_by_name(np, "partitions"); 596 + 597 + /* 598 + * Don't create devices that are added to a bus but will never get 599 + * probed. That'll cause fw_devlink to block probing of consumers of 600 + * this partition until the partition device is probed. 601 + */ 602 + for_each_child_of_node(np, child) 603 + if (of_device_is_compatible(child, "nvmem-cells")) 604 + of_node_set_flag(child, OF_POPULATED); 597 605 598 606 of_property_for_each_string(np, "compatible", prop, compat) { 599 607 parser = mtd_part_get_compatible_parser(compat);