Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3053990rwb; Fri, 20 Jan 2023 10:32:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXu4i24XibBT9jIBtxnQe8SKysW48jTmhE3mO5GarflxMpb2HtxkNpsQdXv5ygSM32qi/xxZ X-Received: by 2002:a17:902:e5cd:b0:192:efc2:6578 with SMTP id u13-20020a170902e5cd00b00192efc26578mr24050289plf.41.1674239567505; Fri, 20 Jan 2023 10:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674239567; cv=none; d=google.com; s=arc-20160816; b=CSaRKBVd7gkMQwgOB/T/9ZrBpshL1rZI5iUCFq3L5xtDoiGzVSkKrNi6xD1ZJx0X65 zIFYo0hl0yR04twdS6qTsRNvnFvJy5KWLOmUvZQOFy/eQZz0b9wnsWnjA0AznWFPoxMp xUQGoUBalNc+LmDqTYXEeRBrWCn81dkbWaL9URBRFblcJWwhNleIy5fOULtngmDbvnEG /euYu/eDmZKtZN9AodVBI1Hlid/YIpJknZoiUJR6/cO5p7+TGK4FoTTU1NEKQfJivQp0 /VTht+beyK6LDCxR9fzLzhdyZ/+JjyAn+1zpdt80CThE1wGWF5V1d+9VgpEAV8d+32zt +ojA== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=UNyEsjm7hTRHmPW+XmOpTTJAr6gba2jkZnI10liz/yE=; b=TDbZnILuJsODtFZIgktaK1xhh0E/6yyBiYEMZ5U4XBI4isAx0q/F7JZowZN8/J6BcY 6ylqUxtAXn+xj0znlLeF5u0jxffyMZz4bU5+of52FVrjd951gLz9LD/4NMHxJL47C0DF vIb7+TFXH/F1tryXYILkVB9RtnPk3LylKVK+QtvyXNZ/2pcPV1suUwi07VT2kR9BbDIc WV3Grno+o56lf0k5a1B2h2rgRVXS5yK5DRCUO+B5QMp/5570izI1tP5yHlYVYMp/JHav OYRcYUEkM0qYxR6T23wXrsk0h67IKZruGf3xgcIajKkqKt9fQYzQRFUMqOqCqeFmAYkW UMiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GjbiRjgq; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 e17-20020a656bd1000000b004468ff8fd57si23516446pgw.680.2023.01.20.10.32.41; Fri, 20 Jan 2023 10:32:47 -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=GjbiRjgq; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 S230356AbjATRxW (ORCPT + 50 others); Fri, 20 Jan 2023 12:53:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbjATRxT (ORCPT ); Fri, 20 Jan 2023 12:53:19 -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 58D44C16D; Fri, 20 Jan 2023 09:52:56 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 2C66C33795; Fri, 20 Jan 2023 17:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674237175; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UNyEsjm7hTRHmPW+XmOpTTJAr6gba2jkZnI10liz/yE=; b=GjbiRjgqTWyXCgMsFjtKYs9AvuDkHg49it+0qX0XS2aTMfPj7Mw2LGq4NMAoFYcaj9PVej vMAyYMvPMBYBuZ3p8DCAt5IgRAcn/Lj3Sm6fk2rJ/G7ZgTQRF8kz1VRmIiI7Mso2WhAkiI qH5MslyqTpbp47xkbnG2yy0C43RDIu8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674237175; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UNyEsjm7hTRHmPW+XmOpTTJAr6gba2jkZnI10liz/yE=; b=JKFUMRfVDlOz7Gei5bw7WnRU5/xBTxCqxl9tiG+nANWfa+RRqPUrsxile+0ykUzlS10JwM oHseEXEeJdaFmKAQ== 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 F157F2C141; Fri, 20 Jan 2023 17:52:54 +0000 (UTC) Date: Fri, 20 Jan 2023 18:52:53 +0100 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Rob Herring Cc: "Erhard F." , Thomas Zimmermann , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE" , linuxppc-dev@lists.ozlabs.org, Javier Martinez Canillas , open list , Frank Rowand Subject: Re: [PATCH v2] of: Fix of platform build on powerpc due to bad of disaply code Message-ID: <20230120175253.GW16547@kitsune.suse.cz> References: <20230118215045.5551-1-msuchanek@suse.de> <20230119095323.4659-1-msuchanek@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Hello, On Fri, Jan 20, 2023 at 11:23:39AM -0600, Rob Herring wrote: > On Thu, Jan 19, 2023 at 3:53 AM Michal Suchanek wrote: > > > > 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]; > > + char *of_display_format = "of-display.%d"; > > static const as suggested and can we just move on please... Only const, static could be dodgy > > 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++); > > The boot display is always "of-display.0". Just use the fixed string > here. Then we can get rid of the whole debate around static const. I prefer to use the same format string when the names should be consistent. Also it would resurrect the starting from 1 debate. But if you really want to have two strings I do not care all that much. > > > + if (ret >= sizeof(buf)) > > + continue; > > This only happens if display_number becomes too big. Why continue on? > The next iteration will fail too. Yes, there is no need to continue with the loop. Thanks Michal > > > + 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; > > Here too in the original change. > > > of_platform_device_create(node, buf, NULL); > > -- > > 2.35.3 > >