All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Bin Meng <bmeng.cn@gmail.com>, Tom Rini <trini@konsulko.com>,
	Alexandru Gagniuc <mr.nuke.me@gmail.com>,
	Simon Glass <sjg@chromium.org>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Marek Vasut <marex@denx.de>
Subject: [PATCH v3 12/15] image: Split host code out into its own file
Date: Sun,  1 Aug 2021 15:00:29 -0600	[thread overview]
Message-ID: <20210801150024.v3.12.I11a7579429bf01e00fef3b1d9454f1e102236015@changeid> (raw)
In-Reply-To: <20210801210032.2203104-1-sjg@chromium.org>

To avoid having #ifdefs in a few functions which are completely different
in the board and host code, create a new image-host.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/image-board.c | 17 +++++++++++++++++
 common/image-host.c  | 27 +++++++++++++++++++++++++++
 common/image.c       | 38 +-------------------------------------
 tools/Makefile       |  1 +
 4 files changed, 46 insertions(+), 37 deletions(-)
 create mode 100644 common/image-host.c

diff --git a/common/image-board.c b/common/image-board.c
index 5d3eafb5245..b46062c86b9 100644
--- a/common/image-board.c
+++ b/common/image-board.c
@@ -15,6 +15,7 @@
 #include <fpga.h>
 #include <image.h>
 #include <mapmem.h>
+#include <rtc.h>
 #include <watchdog.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
@@ -925,3 +926,19 @@ int image_setup_linux(bootm_headers_t *images)
 	return 0;
 }
 #endif /* CONFIG_LMB */
+
+void genimg_print_size(uint32_t size)
+{
+	printf("%d Bytes = ", size);
+	print_size(size, "\n");
+}
+
+void genimg_print_time(time_t timestamp)
+{
+	struct rtc_time tm;
+
+	rtc_to_tm(timestamp, &tm);
+	printf("%4d-%02d-%02d  %2d:%02d:%02d UTC\n",
+	       tm.tm_year, tm.tm_mon, tm.tm_mday,
+	       tm.tm_hour, tm.tm_min, tm.tm_sec);
+}
diff --git a/common/image-host.c b/common/image-host.c
new file mode 100644
index 00000000000..20a9521948b
--- /dev/null
+++ b/common/image-host.c
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Image code used by host tools (and not boards)
+ *
+ * (C) Copyright 2008 Semihalf
+ *
+ * (C) Copyright 2000-2006
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ */
+
+#include <time.h>
+
+void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
+{
+	memmove(to, from, len);
+}
+
+void genimg_print_size(uint32_t size)
+{
+	printf("%d Bytes = %.2f KiB = %.2f MiB\n", size, (double)size / 1.024e3,
+	       (double)size / 1.048576e6);
+}
+
+void genimg_print_time(time_t timestamp)
+{
+	printf("%s", ctime(&timestamp));
+}
diff --git a/common/image.c b/common/image.c
index e9658e3ab1b..0ef8f30fcfa 100644
--- a/common/image.c
+++ b/common/image.c
@@ -18,8 +18,6 @@
 #include <status_led.h>
 #endif
 
-#include <rtc.h>
-
 #if IMAGE_ENABLE_FIT || IMAGE_ENABLE_OF_LIBFDT
 #include <linux/libfdt.h>
 #include <fdt_support.h>
@@ -60,6 +58,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #include <abuf.h>
 #include <bzlib.h>
+#include <display_options.h>
 #include <gzip.h>
 #include <image.h>
 #include <lz4.h>
@@ -526,41 +525,6 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 	return 0;
 }
 
-#ifdef USE_HOSTCC
-void memmove_wd(void *to, void *from, size_t len, ulong chunksz)
-{
-	memmove(to, from, len);
-}
-#endif /* !USE_HOSTCC */
-
-void genimg_print_size(uint32_t size)
-{
-#ifndef USE_HOSTCC
-	printf("%d Bytes = ", size);
-	print_size(size, "\n");
-#else
-	printf("%d Bytes = %.2f KiB = %.2f MiB\n",
-			size, (double)size / 1.024e3,
-			(double)size / 1.048576e6);
-#endif
-}
-
-#if IMAGE_ENABLE_TIMESTAMP
-void genimg_print_time(time_t timestamp)
-{
-#ifndef USE_HOSTCC
-	struct rtc_time tm;
-
-	rtc_to_tm(timestamp, &tm);
-	printf("%4d-%02d-%02d  %2d:%02d:%02d UTC\n",
-			tm.tm_year, tm.tm_mon, tm.tm_mday,
-			tm.tm_hour, tm.tm_min, tm.tm_sec);
-#else
-	printf("%s", ctime(&timestamp));
-#endif
-}
-#endif
-
 const table_entry_t *get_table_entry(const table_entry_t *table, int id)
 {
 	for (; table->id >= 0; ++table) {
diff --git a/tools/Makefile b/tools/Makefile
index 4a86321f646..999fd465316 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -113,6 +113,7 @@ dumpimage-mkimage-objs := aisimage.o \
 			lib/fdtdec_common.o \
 			lib/fdtdec.o \
 			common/image.o \
+			common/image-host.o \
 			imagetool.o \
 			imximage.o \
 			imx8image.o \
-- 
2.32.0.554.ge1b32706d8-goog


  parent reply	other threads:[~2021-08-01 21:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-01 21:00 [PATCH v3 00/15] image: A partial series for the image clean-up Simon Glass
2021-08-01 21:00 ` [PATCH v3 01/15] lib: Add memdup() Simon Glass
2021-08-01 21:25   ` Heinrich Schuchardt
2021-08-01 21:00 ` [PATCH v3 02/15] Add support for an owned buffer Simon Glass
2021-08-01 21:00 ` [PATCH v3 03/15] compiler: Add a comment to host_build() Simon Glass
2021-08-01 21:00 ` [PATCH v3 04/15] zstd: Create a function for use from U-Boot Simon Glass
2021-08-01 21:00 ` [PATCH v3 05/15] btrfs: Use U-Boot API for decompression Simon Glass
2021-08-01 21:00 ` [PATCH v3 06/15] image: Avoid switch default in image_decomp() Simon Glass
2021-08-01 21:00 ` [PATCH v3 07/15] image: Update zstd to avoid reporting error twice Simon Glass
2021-08-01 21:00 ` [PATCH v3 08/15] gzip: Avoid use of u64 Simon Glass
2021-08-01 21:00 ` [PATCH v3 09/15] image: Update image_decomp() to avoid ifdefs Simon Glass
2021-08-01 21:00 ` [PATCH v3 10/15] image: Split board code out into its own file Simon Glass
2021-08-01 21:00 ` [PATCH v3 11/15] image: Fix up checkpatch warnings in image-board.c Simon Glass
2021-08-01 21:00 ` Simon Glass [this message]
2021-08-01 21:00 ` [PATCH v3 13/15] image: Create a function to do manual relocation Simon Glass
2021-08-01 21:00 ` [PATCH v3 14/15] image: Avoid #ifdefs for " Simon Glass
2021-08-01 21:00 ` [PATCH v3 15/15] image: Remove ifdefs around image_setup_linux() el at Simon Glass

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=20210801150024.v3.12.I11a7579429bf01e00fef3b1d9454f1e102236015@changeid \
    --to=sjg@chromium.org \
    --cc=bmeng.cn@gmail.com \
    --cc=joe.hershberger@ni.com \
    --cc=marex@denx.de \
    --cc=mr.nuke.me@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.