mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-26 14:17:26 -04:00
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: linuxppc-dev@lists.ozlabs.org
References: https://bugzilla.kernel.org/show_bug.cgi?id=216095
Fixes: 52b1b46c39
("of: Create platform devices for OF framebuffers")
Reported-by: Erhard F. <erhard_f@mailbox.org>
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Link: https://lore.kernel.org/r/20230201162247.3575506-1-robh@kernel.org
[robh: Rework to avoid node refcount leaks]
Signed-off-by: Rob Herring <robh@kernel.org>
This commit is contained in:
parent
064e32dc5b
commit
241d2fb56a
1 changed files with 10 additions and 2 deletions
|
@ -525,6 +525,7 @@ static int __init of_platform_default_populate_init(void)
|
||||||
if (IS_ENABLED(CONFIG_PPC)) {
|
if (IS_ENABLED(CONFIG_PPC)) {
|
||||||
struct device_node *boot_display = NULL;
|
struct device_node *boot_display = NULL;
|
||||||
struct platform_device *dev;
|
struct platform_device *dev;
|
||||||
|
int display_number = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Check if we have a MacOS display without a node spec */
|
/* Check if we have a MacOS display without a node spec */
|
||||||
|
@ -555,16 +556,23 @@ static int __init of_platform_default_populate_init(void)
|
||||||
if (!of_get_property(node, "linux,opened", NULL) ||
|
if (!of_get_property(node, "linux,opened", NULL) ||
|
||||||
!of_get_property(node, "linux,boot-display", NULL))
|
!of_get_property(node, "linux,boot-display", NULL))
|
||||||
continue;
|
continue;
|
||||||
dev = of_platform_device_create(node, "of-display", NULL);
|
dev = of_platform_device_create(node, "of-display.0", NULL);
|
||||||
|
of_node_put(node);
|
||||||
if (WARN_ON(!dev))
|
if (WARN_ON(!dev))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
boot_display = node;
|
boot_display = node;
|
||||||
|
display_number++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for_each_node_by_type(node, "display") {
|
for_each_node_by_type(node, "display") {
|
||||||
|
char buf[14];
|
||||||
|
const char *of_display_format = "of-display.%d";
|
||||||
|
|
||||||
if (!of_get_property(node, "linux,opened", NULL) || node == boot_display)
|
if (!of_get_property(node, "linux,opened", NULL) || node == boot_display)
|
||||||
continue;
|
continue;
|
||||||
of_platform_device_create(node, "of-display", NULL);
|
ret = snprintf(buf, sizeof(buf), of_display_format, display_number++);
|
||||||
|
if (ret < sizeof(buf))
|
||||||
|
of_platform_device_create(node, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue