Message ID | 20230120180958.30798-1-msuchanek@suse.de |
---|---|
State | Accepted, archived |
Headers | show |
Series | [v3] of: Make of framebuffer devices unique | expand |
Context | Check | Description |
---|---|---|
robh/checkpatch | warning | total: 0 errors, 1 warnings, 31 lines checked |
robh/patch-applied | fail | build log |
On Fri, 20 Jan 2023 19:09:57 +0100, Michal Suchanek wrote: > 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(-) > Applied, thanks!
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 {
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(-)