Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp148317pxb; Wed, 3 Feb 2021 01:53:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJyw7/ih7KjmfLPHkXTjjbfBZYboWX5/VA+YL6V8RbSWTQz4ZnJ25L4Ir2TrSo815QMAvur3 X-Received: by 2002:a17:906:509:: with SMTP id j9mr2341244eja.89.1612346003993; Wed, 03 Feb 2021 01:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612346003; cv=none; d=google.com; s=arc-20160816; b=lRH3uNXQBW89D2ShLjLNcEAMq+FlLKPOX88QqWM58N6JwwzLb5oLr/GPTBlo95GL+6 x6Qy+z3DD02G0AnNzcfShGcq58Mt8+bm39e6mX8RcVJhXmrzP6yk2HThYJW+7blmJm2i LNlj6XszAawU0m+7fq48OhQotlMLfYx+DJaPas7vC9bBj9rA31aEy873XDeKGn9HOaFw cj6ulYIzO4nAMgg+adz1o7cYd3sGEaVqIa+L3U/CtJCrmfLaukiuul2CHsUYSD2aVO6s voMdB+auRpORlfIJx+ZROrsU0IMERYKuK4reoqOfeg7p8cqMCaBPaXI4la8K0TlypINL TGng== 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; bh=wBX1VyZvqFargIbuzyCHxeXh2t3OMi+jyqk4NEoTLjM=; b=1LQ6PUmvC2Qt7s7jpslKgliAjdysUSvLp4/ycRM7LAn4rYN3EGkA4NfGBUwaKNtk/1 M3lfyp5qrsNKtkexzcycj+wtysGkslccBavmcJe2o8Pqjcb12VSM7emLouPTvHkzeXef xdYmNTvr0ecPMDBTPKL97SKOfubpIw8bxaGmJi8CXQ/zPdPz850CmhrtfD6w3oNZ2ESj fjcjGwmh+iRyjbKlEuzhAmd4aTH42EcVco53b3AFRq4dXAoRaFoT6u0bg4tGmqgwoywu GkSuICR85vCk3wmaBn4rNTj15+uGvqQGm7irDoKQQgFHVwXISwORJERHMsecrfFmn/ml arRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AiM1Z09V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si979884eji.385.2021.02.03.01.52.58; Wed, 03 Feb 2021 01:53:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AiM1Z09V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233581AbhBCJwO (ORCPT + 99 others); Wed, 3 Feb 2021 04:52:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233344AbhBCJwL (ORCPT ); Wed, 3 Feb 2021 04:52:11 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36AA8C0613ED for ; Wed, 3 Feb 2021 01:51:31 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id o20so16322429pfu.0 for ; Wed, 03 Feb 2021 01:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wBX1VyZvqFargIbuzyCHxeXh2t3OMi+jyqk4NEoTLjM=; b=AiM1Z09V1NldCLbYRQDI5f11YZ3KIFhKCp4i9BbbQEYKRZyk5uJt6ITm3vN4JZuUi0 lpLluAPvDU4g0FPWlvKTeLoBQXYd2f4xFgurRJCc6JDGjYbGbahgPThn6BWCMfWlpjlh 4L34FmhLwHwnLFpoiYa9zfkPiq+r0G6ZZ4qjRg5ITarmRd7xB5qluz72JFRiUfrSrQIX Nec9nNzmue67ZhjGvvcmH7KKAwd5Y+t9XvRotSvK2B0F6M90TnSoLn4FUSLmUkjCH82D j8bPfpMfEYMCyUR/Vcbebgq8rXZzKnh2pzlToWx8ruoAaEcJJl0NM9sszpfZpvFR3E96 HG1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wBX1VyZvqFargIbuzyCHxeXh2t3OMi+jyqk4NEoTLjM=; b=celNckvmaL/hQKMh0WkhPhKAyukrelFfBm/sv1zhJB5+peejhnNByusA6V7YoG1dBC nK+QU3iUrQZxAvW500X2jCJEH2Zgxy63di26bOFPdMUpT+n2OG2qn7BSvmjb/g5+DPxa YRy2inJrrX4OH+4p52OJqdNQBpACpYpJBUrfQjYVs9DON+16UZ1tTw990TEmKnCxlUpR Dq8Lq8Aoz1Qp69lJweDcsar+Nvm5Ec2/FAiOD3V5f5QOHcl5t2iAc2npk+Inl2P3vcdK vmE77KpEpntCAcmAyukQzhpvh62y6n4aL5vSKHzoZ56BejScaaYD5tSd4ibcbt6UU23c 4BnQ== X-Gm-Message-State: AOAM5311acozNrA7OsZM8knH/RmRq12MlRlISkIdMYRumiBchs6Wp9Z2 FC2AyeSY5/zAVokipx7/IZzN/g== X-Received: by 2002:a63:3747:: with SMTP id g7mr2700514pgn.376.1612345890802; Wed, 03 Feb 2021 01:51:30 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id h6sm1738999pfr.47.2021.02.03.01.51.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2021 01:51:29 -0800 (PST) Date: Wed, 3 Feb 2021 15:21:27 +0530 From: Viresh Kumar To: David Gibson Cc: Frank Rowand , Pantelis Antoniou , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Vincent Guittot , Bill Mills , anmar.oueja@linaro.org, Masahiro Yamada Subject: Re: [PATCH V4 0/3] scripts: dtc: Build fdtoverlay Message-ID: <20210203095127.rphegopnavk7ijhu@vireshk-i7> References: <74f8aa8f-ffab-3b0f-186f-31fb7395ebbb@gmail.com> <20210120051740.yph4v7zldvs7szdz@vireshk-i7> <20210122063455.GE4400@yekko.fritz.box> <83242f56-19a5-6d32-c050-8d9f63ac1e47@gmail.com> <20210201040748.GB2251@yekko.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210201040748.GB2251@yekko.fritz.box> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01-02-21, 15:07, David Gibson wrote: > On Mon, Jan 25, 2021 at 09:42:21PM -0600, Frank Rowand wrote: > > Before having looked at libfdt only at a cursory level while debugging the proposed > > use of fdtoverlay in Linux, my first thought was that maybe it would be possible > > to add warning and error messages within "#ifdef" blocks, or other ways that > > cause the error code to _not_ be compiled as part of library version of libfdt, > > but only be compiled as part of fdtoverlay _when built in the Linux kernel_ > > (noting that the proposed Linux patch builds the libfdt files as part of > > the fdtoverlay compile instead of as a discrete library). After looking at > > the libfdt source a tiny bit more carefully, I would probably shoot down this > > suggestion, as it makes the source code uglier and harder to understand and > > maintain for the primary purpose of being an embedded library. > > Oof. That sounds really ugly, but maybe it could be pulled off. I started looking at this and I was able to get to a not so ugly solution. Do this in dtc: -------------------------8<------------------------- --- dtc.h | 6 ++++++ fdtoverlay.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/dtc.h b/dtc.h index d3e82fb8e3db..cc1e591b3f8c 100644 --- a/dtc.h +++ b/dtc.h @@ -29,6 +29,12 @@ #define debug(...) #endif +#ifdef VERBOSE +#define pr_err(...) fprintf(stderr, __VA_ARGS__) +#else +#define pr_err(...) +#endif + #define DEFAULT_FDT_VERSION 17 /* diff --git a/fdtoverlay.c b/fdtoverlay.c index 5350af65679f..28ceac0d8079 100644 --- a/fdtoverlay.c +++ b/fdtoverlay.c @@ -16,6 +16,7 @@ #include +#include "dtc.h" #include "util.h" #define BUF_INCREMENT 65536 @@ -76,6 +77,7 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len, if (ret) { fprintf(stderr, "\nFailed to apply '%s': %s\n", name, fdt_strerror(ret)); + pr_err("New error\n"); goto fail; } -------------------------8<------------------------- And do this in kernel: -------------------------8<------------------------- diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index c8c21e0f2531..9dafb9773f06 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile @@ -13,6 +13,7 @@ dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o libfdt-objs := fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o libfdt = $(addprefix libfdt/,$(libfdt-objs)) fdtoverlay-objs := $(libfdt) fdtoverlay.o util.o +HOSTCFLAGS_fdtoverlay.o := -DVERBOSE # Source files need to get at the userspace version of libfdt_env.h to compile HOST_EXTRACFLAGS += -I $(srctree)/$(src)/libfdt -------------------------8<------------------------- Will that be acceptable ? With this we can add as many error messages to libfdt without affecting any other users of it other than Linux. -- viresh