Skip to content

Commit 241d2fb

Browse files
hramrachrobherring
authored andcommitted
of: Make OF framebuffer device names unique
Since Linux 5.19 this error is observed: sysfs: cannot create duplicate filename '/devices/platform/of-display' This is because multiple devices with the same name 'of-display' are created on the same bus. Update the code to create numbered device names for the displays. Also, fix a node refcounting issue when exiting the boot display loop. cc: [email protected] References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 Fixes: 52b1b46 ("of: Create platform devices for OF framebuffers") Reported-by: Erhard F. <[email protected]> Suggested-by: Thomas Zimmermann <[email protected]> Signed-off-by: Michal Suchanek <[email protected]> Link: https://lore.kernel.org/r/[email protected] [robh: Rework to avoid node refcount leaks] Signed-off-by: Rob Herring <[email protected]>
1 parent 064e32d commit 241d2fb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/of/platform.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ static int __init of_platform_default_populate_init(void)
525525
if (IS_ENABLED(CONFIG_PPC)) {
526526
struct device_node *boot_display = NULL;
527527
struct platform_device *dev;
528+
int display_number = 0;
528529
int ret;
529530

530531
/* Check if we have a MacOS display without a node spec */
@@ -555,16 +556,23 @@ static int __init of_platform_default_populate_init(void)
555556
if (!of_get_property(node, "linux,opened", NULL) ||
556557
!of_get_property(node, "linux,boot-display", NULL))
557558
continue;
558-
dev = of_platform_device_create(node, "of-display", NULL);
559+
dev = of_platform_device_create(node, "of-display.0", NULL);
560+
of_node_put(node);
559561
if (WARN_ON(!dev))
560562
return -ENOMEM;
561563
boot_display = node;
564+
display_number++;
562565
break;
563566
}
564567
for_each_node_by_type(node, "display") {
568+
char buf[14];
569+
const char *of_display_format = "of-display.%d";
570+
565571
if (!of_get_property(node, "linux,opened", NULL) || node == boot_display)
566572
continue;
567-
of_platform_device_create(node, "of-display", NULL);
573+
ret = snprintf(buf, sizeof(buf), of_display_format, display_number++);
574+
if (ret < sizeof(buf))
575+
of_platform_device_create(node, buf, NULL);
568576
}
569577

570578
} else {

0 commit comments

Comments
 (0)