linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Frank Rowand <frowand.list@gmail.com>,
	Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
	Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kbuild@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Bill Mills <bill.mills@linaro.org>,
	anmar.oueja@linaro.org, Masahiro Yamada <masahiroy@kernel.org>
Subject: Re: [PATCH V4 0/3] scripts: dtc: Build fdtoverlay
Date: Wed, 3 Feb 2021 15:21:27 +0530	[thread overview]
Message-ID: <20210203095127.rphegopnavk7ijhu@vireshk-i7> (raw)
In-Reply-To: <20210201040748.GB2251@yekko.fritz.box>

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 <libfdt.h>
 
+#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

  reply	other threads:[~2021-02-03  9:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12  8:28 [PATCH V4 0/3] scripts: dtc: Build fdtoverlay Viresh Kumar
2021-01-12  8:29 ` [PATCH V4 1/3] scripts: dtc: Add fdtoverlay.c to DTC_SOURCE Viresh Kumar
2021-01-19 16:32   ` Frank Rowand
2021-01-12  8:29 ` [PATCH V4 2/3] scripts: dtc: Build fdtoverlay tool Viresh Kumar
2021-01-19 16:37   ` Frank Rowand
2021-01-20 15:47     ` Rob Herring
2021-01-12  8:29 ` [PATCH V4 3/3] scripts: dtc: Remove the unused fdtdump.c file Viresh Kumar
2021-01-19 17:12 ` [PATCH V4 0/3] scripts: dtc: Build fdtoverlay Frank Rowand
2021-01-20  5:17   ` Viresh Kumar
2021-01-22  6:34     ` David Gibson
2021-01-26  3:42       ` Frank Rowand
2021-02-01  4:07         ` David Gibson
2021-02-03  9:51           ` Viresh Kumar [this message]
2021-02-04 14:25           ` Rob Herring
2021-02-22  6:17             ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210203095127.rphegopnavk7ijhu@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=anmar.oueja@linaro.org \
    --cc=bill.mills@linaro.org \
    --cc=david@gibson.dropbear.id.au \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=robh+dt@kernel.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).