From patchwork Fri Jan 20 18:09:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michal_Such=C3=A1nek?= X-Patchwork-Id: 46560 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp353509wrn; Fri, 20 Jan 2023 10:17:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXvpb4NdV5V9sDwBvBT/JsG5ibnd6U7T2wI0FbHOcy9NjKjG0vIi8jkjXsNXBmTBurNsdm37 X-Received: by 2002:aa7:cfc5:0:b0:49e:7d83:43b8 with SMTP id r5-20020aa7cfc5000000b0049e7d8343b8mr5672143edy.32.1674238665823; Fri, 20 Jan 2023 10:17:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674238665; cv=none; d=google.com; s=arc-20160816; b=QdS1kle4KcCiNkzJXe27fVBlSRPHjAKkFCCJBdfskf0xrNZHrP5d+u8sAfAI2z09Ke riXrv0TJ1ueWEIZRG4V2caLrD0NuSPiG4GcN1NmbzUVDdKsmN+8+ysvohLL6KCZtpiDU SopCOee3b+uSmn6nTo595vW5f5/MzsO2jYK0GE1Jx9SvdGr2c6tijAVyeC2KWOOX+tHD NWExk/SUX4oSIR1uo+K0W9Sd1sv8HK45zNwtkTAeM0u3TK8KadPUojEaveuOEbE91fwz ce9aywUx6+UR3EEf520j9zhGdUX2aqJsH63D0v2cBJXMZnOoBiYEh2/YNm/8ayqVSDYP yxvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=hkN6PpdG4Lfy4P3q90hNQcwHa4prP8EZfXIbP4VPT1k=; b=LabdwO8F0cwxcS/lklbDbU8zoYcP/LV4ZPAgHcERV/I7RkL4R9eMsmAh+T5ZPvnYNV eSs/6eEgA0kc8c8RZQMI1Gv4zFLkADeuioHuGZRuGQf+4jIrKzwkJnTfibT+TeR+qmYL QVzaPSEmc8k/eLJAvE0twtJVp6acDjJKT1AGgfqZhj612hc6t9/QVmyZafTu9kXr470l l9PBkuU6OZX8lVopt+UxKSZ0slCwnCpHdB9JrUUTN6DMpyXYrfLVPNgyge87ILZ3SXQ7 T9wiFlxAVyTH2cESSJwej7dE0p94O19EBq3oGsQji4hEbLhIxApimXWRUdOapTnxMT3z qZmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=0kWIhRlh; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a05640240d000b0049e308dbbacsi17099750edb.277.2023.01.20.10.17.22; Fri, 20 Jan 2023 10:17:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=0kWIhRlh; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbjATSKF (ORCPT + 99 others); Fri, 20 Jan 2023 13:10:05 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755566483253659823?= X-GMAIL-MSGID: =?utf-8?q?1755566483253659823?= 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. 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(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 {