Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1082195rwb; Thu, 19 Jan 2023 06:28:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXtqLG6x3kwk1PYboQp3TShWWAOmaRR8YgV9UxbzN6nHEL4SllyVyKvjRcfA8KTZ5CUDtLyL X-Received: by 2002:a17:902:988e:b0:189:acee:7aa4 with SMTP id s14-20020a170902988e00b00189acee7aa4mr10175704plp.65.1674138491375; Thu, 19 Jan 2023 06:28:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674138491; cv=none; d=google.com; s=arc-20160816; b=JD5bt4CqWaP6npnp0xgYOR5JCir65h19hwOzextBXNfsNMSH5gWeiscmmyZrYg/qqy VAs3ICa8K9V0Sew2N1sTdivV0lnZGW/ledjRgzu/xZrqoYyY6bQMjVO3P8qkHzMriuDg xvSi/SKm7AfVfYw9z8D8yx4UpB+N2QJQykQjIa2qP8DHUZBw6I2feTSjKIl6JCFUpEb0 9zJwFvXGj3oWZv2+jp6BvHxYbptKElZiUl+gCCw4Sl7FQoQaVEE8JfueF/J0DYGrrjO5 GfUn/GXPb0RfkB8slQdyfeORgRIx7s2B+G8DJ0a6DKuyVlDL4IVNkmyepUjyvZHpW3+M bsfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=7SU3rQc/6KT2OT+CNuvmsp7JyhHd1jX5deqXc9F/9wA=; b=iz5JV/EMKey2nZcf5Pxam/1Qy9HxQTJQucBOb93oEImw3MGSMFs0D5bJ/wISMClH1h HwixbBFDyej7g9azJLoXEZLZPfg2O7Cb62Cn/IwugEIxRf9pyPT/7bNPapksriftQX2X jGR3GowSy7E2AYF5VAB73rt/IpANpzVR8LMglsGlRIVyoZx0UitRFRzl4t8DnNm9sCYs nGfp5SN/kI4zLaRgH1R+nOudxrInOyz8YCMJ9TDg04mt/SPip40LxRUduj6UHHi6lmSn dsGco20IVxQubAPjKbscw8hbliSyw7BRzI6qXGyqXUwjU9Zz6/WoXSW6R2Ndg8Xoryrs WmtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=iI07z7Bl; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=WFHyP+E9; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a1709029a8e00b00194ac38bcc2si7593684plp.294.2023.01.19.06.28.05; Thu, 19 Jan 2023 06:28:11 -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=iI07z7Bl; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=WFHyP+E9; 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 S230218AbjASNXg (ORCPT + 44 others); Thu, 19 Jan 2023 08:23:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbjASNXe (ORCPT ); Thu, 19 Jan 2023 08:23:34 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45BCC83; Thu, 19 Jan 2023 05:23:33 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id EA88E5CE24; Thu, 19 Jan 2023 13:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674134611; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7SU3rQc/6KT2OT+CNuvmsp7JyhHd1jX5deqXc9F/9wA=; b=iI07z7Blumf+H21YP2Mkk2ClWk78WRME3oLbSOOFV/v4BOWBRybqtzAwUEGhtJa98uOp+V gdPNXpxmVXBXQ+lJqBacxUrwGxP0sQSKA2q+UbhEy6kQhDJL5VQBDq6hdOZaDmZKHLkeWV LFyHklh8vHoXmn7OKFGEmVz7u1Zbg64= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674134611; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7SU3rQc/6KT2OT+CNuvmsp7JyhHd1jX5deqXc9F/9wA=; b=WFHyP+E9iU1XvgkR3PtCE6TnVRXhNO8Ezz3UaOX08tobrcUA+H73ECL7O37u4RPh4pZa/l LdACLQbVs6HPquBg== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 9AFC82C141; Thu, 19 Jan 2023 13:23:31 +0000 (UTC) Date: Thu, 19 Jan 2023 14:23:30 +0100 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Thomas Zimmermann Cc: Christophe Leroy , "Erhard F." , Rob Herring , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , Frank Rowand , Javier Martinez Canillas , open list , "linuxppc-dev@lists.ozlabs.org" Subject: Re: [PATCH v2] of: Fix of platform build on powerpc due to bad of disaply code Message-ID: <20230119132330.GP16547@kitsune.suse.cz> References: <20230119095323.4659-1-msuchanek@suse.de> <8a9f7ba5-37a4-0927-4ab2-d212f1b098a9@csgroup.eu> <57e026bf-c412-0c47-8956-b565894948e0@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <57e026bf-c412-0c47-8956-b565894948e0@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) 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 On Thu, Jan 19, 2023 at 02:11:13PM +0100, Thomas Zimmermann wrote: > Hi > > Am 19.01.23 um 11:24 schrieb Christophe Leroy: > > > > > > Le 19/01/2023 ? 10:53, Michal Suchanek a ?crit?: > > > 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 > > > --- > > > 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]; > > > > Can you declare that in the for block where it is used instead ? > > > > > + char *of_display_format = "of-display.%d"; > > > > Should be const ? > > That should be static const of_display_format[] = then Why? It sounds completely fine to have a const pointer to a string constatnt. Thanks Michal > > > > > > 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; > > > > > > Can you make buf big enough to avoid that ? > > > > And by the way could it be called something else than 'buf' ? > > > > See exemple here : > > https://elixir.bootlin.com/linux/v6.1/source/drivers/fsi/fsi-occ.c#L690 > > > > > > > + 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); > > -- > Thomas Zimmermann > Graphics Driver Developer > SUSE Software Solutions Germany GmbH > Maxfeldstr. 5, 90409 N?rnberg, Germany > (HRB 36809, AG N?rnberg) > Gesch?ftsf?hrer: Ivo Totev