From patchwork Thu Jan 19 09:53:23 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: 45669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp240200wrn; Thu, 19 Jan 2023 02:04:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXs71aA4JOMIwy0E4vS74oT12cFqK8WL0TRd+6a6jt55qrqF8o7tUAyeJUkyR3Olv3ZUEpJ3 X-Received: by 2002:a17:906:a21a:b0:877:7157:9358 with SMTP id r26-20020a170906a21a00b0087771579358mr1997148ejy.10.1674122649317; Thu, 19 Jan 2023 02:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674122649; cv=none; d=google.com; s=arc-20160816; b=sP/4dWImyM9Bf9uJg+92oDz6vndRFPMAaUR90lbEgFFHoCt0/ZTHOKr7vtuQtk/mgA xUH9kE1H+w6QDvDRY8Y9Eq7ZxvMpQgTEq5ineGeIAeXMPI9tk9MnZE0q+FLryu6tP0uu 1YR6gBLW0Sr5geUvteoxoV6jWqDM35Cvyyf+XIwpcUYIEC6wS6TGRHpLrWOMby8Lv5oH Vunu9KK6fDsOSq+/bEHNGbV3qCxdJ18YTJR1pXF/VZvBWHSU5nXbjWRfd4qNnPh/GFsm UT9cj2T3hpd9EIIzpGkxKhwbFFPyySwc1cqob1Y10PWQab6YZoK5txbS96IgmGXeJFm2 EIfQ== 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=K5Wjtf9hLzRkuQgSxBaDv2x2hWptBx8DnMTdLdxBFys=; b=XnwaKPLT1eGQRfHwB3//v3i2aQbbTPVH4IiOA/ViXwNrnVa0pTvpkEMZCLk4KP85pu cdfziypXE/GTB0u6KiG0zXR+hasoqQpx+9sXoZPHpcAl2ElYqYY0wp1S9TXh78/TAoLi Do/DX+6FwBE9/pOv0NeZzrqcTKTclMy5kq27qdhvKiygnjygxakxltYfnRk5LYEzITm0 Zuvq4tH/cmOUE3H17n0RbKBO20SutyHFjI50ZhLWIOH/xuxUrPhuzv9u9xVY4WDA9jgY 89XxQFiIVgm6oP/oFiiyIjnWLQZfWoAnT6CGlindtYf4mh9LXpecjeRhWJ0FlWydFN6b +LzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=JmeRmKIx; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=W4gz9+a1; 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 gb36-20020a170907962400b0086c7dc4fd9bsi21095102ejc.538.2023.01.19.02.03.45; Thu, 19 Jan 2023 02:04:09 -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=JmeRmKIx; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=W4gz9+a1; 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 S230194AbjASJxv (ORCPT + 99 others); Thu, 19 Jan 2023 04:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjASJxs (ORCPT ); Thu, 19 Jan 2023 04:53:48 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 315D15D106; Thu, 19 Jan 2023 01:53:47 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D8E7E38562; Thu, 19 Jan 2023 09:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674122025; 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=K5Wjtf9hLzRkuQgSxBaDv2x2hWptBx8DnMTdLdxBFys=; b=JmeRmKIxA6LcTyfKL46wUKQQNW++j5YCwI2EWzrWqc5lJBCJIisF2fK988F9sSL9hOiPLb 7VDN++/nwTj39/JeiH2rRbyjjJ3Lybm1hAjvfdiXu1dj6hmt2KO/8opk+B/kYdfQBKc4K1 hK5CGO2UJtE0+0SnXEbldehQ/6TlDAY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674122025; 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=K5Wjtf9hLzRkuQgSxBaDv2x2hWptBx8DnMTdLdxBFys=; b=W4gz9+a1bRbUTmeUmj43HT5F78l511dttU0eg+3fYuLsqWanKN8UgFIovvKDV5LDR+eYhH +5jwqSM1gnnDzMDw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id A9E912C141; Thu, 19 Jan 2023 09:53:45 +0000 (UTC) From: Michal Suchanek To: "Erhard F." , Thomas Zimmermann , Rob Herring Cc: Michal Suchanek , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , linuxppc-dev@lists.ozlabs.org, Javier Martinez Canillas , open list , Frank Rowand Subject: [PATCH v2] of: Fix of platform build on powerpc due to bad of disaply code Date: Thu, 19 Jan 2023 10:53:23 +0100 Message-Id: <20230119095323.4659-1-msuchanek@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230118215045.5551-1-msuchanek@suse.de> 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?1755399609663748161?= X-GMAIL-MSGID: =?utf-8?q?1755444831152122433?= The commit 2d681d6a23a1 ("of: Make of framebuffer devices unique") breaks build because of wrong argument to snprintf. That certainly avoids the runtime error but is not the intended outcome. Also use standard device name format of-display.N for all created devices. Fixes: 2d681d6a23a1 ("of: Make of framebuffer devices unique") Signed-off-by: Michal Suchanek Reviewed-by: Thomas Zimmermann --- v2: Update the device name format --- drivers/of/platform.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index f2a5d679a324..8c1b1de22036 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -525,7 +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 = 1; + int display_number = 0; + char buf[14]; + char *of_display_format = "of-display.%d"; int ret; /* Check if we have a MacOS display without a node spec */ @@ -556,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)) + continue; + dev = of_platform_device_create(node, buf, NULL); if (WARN_ON(!dev)) return -ENOMEM; boot_display = node; @@ -564,10 +569,9 @@ static int __init of_platform_default_populate_init(void) } for_each_node_by_type(node, "display") { - char *buf[14]; if (!of_get_property(node, "linux,opened", NULL) || node == boot_display) continue; - ret = snprintf(buf, "of-display-%d", display_number++); + ret = snprintf(buf, sizeof(buf), of_display_format, display_number++); if (ret >= sizeof(buf)) continue; of_platform_device_create(node, buf, NULL);