Messages in this thread Patch in this message | | | From | Michal Suchanek <> | Subject | [PATCH v3] of: Make of framebuffer devices unique | Date | Fri, 20 Jan 2023 19:09:57 +0100 |
| |
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 non-boot disaplay.
cc: linuxppc-dev@lists.ozlabs.org References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 Fixes: 52b1b46c39ae ("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> --- v3: - merge fix into original patch - Update the device name format - add missing const - do not continue with iterating display devices when formatting device name fails --- drivers/of/platform.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 81c8c227ab6b..4d3a4d9f79f2 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -525,6 +525,9 @@ static int __init of_platform_default_populate_init(void) if (IS_ENABLED(CONFIG_PPC)) { struct device_node *boot_display = NULL; struct platform_device *dev; + int display_number = 0; + char buf[14]; + const char *of_display_format = "of-display.%d"; int ret; /* Check if we have a MacOS display without a node spec */ @@ -555,7 +558,10 @@ static int __init of_platform_default_populate_init(void) if (!of_get_property(node, "linux,opened", NULL) || !of_get_property(node, "linux,boot-display", NULL)) continue; - dev = of_platform_device_create(node, "of-display", NULL); + ret = snprintf(buf, sizeof(buf), of_display_format, display_number++); + if (ret >= sizeof(buf)) + return -EOVERFLOW; + dev = of_platform_device_create(node, buf, NULL); if (WARN_ON(!dev)) return -ENOMEM; boot_display = node; @@ -564,7 +570,10 @@ static int __init of_platform_default_populate_init(void) for_each_node_by_type(node, "display") { if (!of_get_property(node, "linux,opened", NULL) || node == boot_display) continue; - of_platform_device_create(node, "of-display", NULL); + ret = snprintf(buf, sizeof(buf), of_display_format, display_number++); + if (ret >= sizeof(buf)) + break; + of_platform_device_create(node, buf, NULL); } } else { -- 2.35.3
| |