From nobody Sun Sep 14 14:31:13 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16650C25B4E for ; Fri, 20 Jan 2023 18:10:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbjATSKG (ORCPT ); Fri, 20 Jan 2023 13:10:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjATSKE (ORCPT ); Fri, 20 Jan 2023 13:10:04 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E6A97B2D9; Fri, 20 Jan 2023 10:10:03 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C8FCB5FBEC; Fri, 20 Jan 2023 18:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674238201; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hkN6PpdG4Lfy4P3q90hNQcwHa4prP8EZfXIbP4VPT1k=; b=0kWIhRlhN7HnSu+SxpjJGtYLQu4XcH6zs4to/NIdHtBXBculzP4PLNMAV5+yc4d71dJUaG oadi+rIkwbUZxynl0J1hzyIy902XaC9+Ri33hyLzl6K3hX/R36Pv7Q5Mvm2wRfdy2Y3xE+ w77XGUvo5bAgyWquH5lxT++OBk4wtBQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674238201; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hkN6PpdG4Lfy4P3q90hNQcwHa4prP8EZfXIbP4VPT1k=; b=pMQoSUb2TTGqCwG6jJMv4mpI6i869ypvc5S+cATJNQF48NGzaXKIy5cpIl8JIQWeK4xXo0 FcS8/7i4aLHJ0eCA== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 9E25A2C141; Fri, 20 Jan 2023 18:10:01 +0000 (UTC) From: Michal Suchanek To: Rob Herring Cc: Michal Suchanek , "Erhard F." , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , Frank Rowand , open list , Javier Martinez Canillas , Thomas Zimmermann , linuxppc-dev@lists.ozlabs.org Subject: [PATCH v3] of: Make of framebuffer devices unique Date: Fri, 20 Jan 2023 19:09:57 +0100 Message-Id: <20230120180958.30798-1-msuchanek@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3D216095 Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers") Reported-by: Erhard F. Suggested-by: Thomas Zimmermann Signed-off-by: Michal Suchanek --- 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(voi= d) if (IS_ENABLED(CONFIG_PPC)) { struct device_node *boot_display =3D NULL; struct platform_device *dev; + int display_number =3D 0; + char buf[14]; + const char *of_display_format =3D "of-display.%d"; int ret; =20 /* Check if we have a MacOS display without a node spec */ @@ -555,7 +558,10 @@ static int __init of_platform_default_populate_init(vo= id) if (!of_get_property(node, "linux,opened", NULL) || !of_get_property(node, "linux,boot-display", NULL)) continue; - dev =3D of_platform_device_create(node, "of-display", NULL); + ret =3D snprintf(buf, sizeof(buf), of_display_format, display_number++); + if (ret >=3D sizeof(buf)) + return -EOVERFLOW; + dev =3D of_platform_device_create(node, buf, NULL); if (WARN_ON(!dev)) return -ENOMEM; boot_display =3D node; @@ -564,7 +570,10 @@ static int __init of_platform_default_populate_init(vo= id) for_each_node_by_type(node, "display") { if (!of_get_property(node, "linux,opened", NULL) || node =3D=3D boot_di= splay) continue; - of_platform_device_create(node, "of-display", NULL); + ret =3D snprintf(buf, sizeof(buf), of_display_format, display_number++); + if (ret >=3D sizeof(buf)) + break; + of_platform_device_create(node, buf, NULL); } =20 } else { --=20 2.35.3