From patchwork Fri Nov 1 08:11:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 178261 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp142840ill; Fri, 1 Nov 2019 01:13:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqytKMr2lCzG3gec6RZvjDG3iBry200wQIYzKvUkWO89QI7QJPJRlnPDoFvF9yRP/xGsMtH6 X-Received: by 2002:a05:6402:1acd:: with SMTP id ba13mr10848822edb.141.1572596029216; Fri, 01 Nov 2019 01:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572596029; cv=none; d=google.com; s=arc-20160816; b=rGDDxvOIO4dSwAenhKPFMI5BK0aq9GvwiSdvwjpqgQ0mrTeMS+UOzztkQ4uaSFJKQG fJDIgGwJ0BleAiK9etrHHqjXdATU/tJmVYb6z73PaHbDMogXw359jcxWP9+7ftU+Ldkk TBaG+AOBDSs6EiNQkZjb4BJ+0ZcqgrUaPK3GK8OJlevGPNSruUqy8JblslcIWBMVTTuq rXA3Gei9sPJatapBzRbjDbeILLT1BsAuYc4r7kdlbRZ9+bMTppLtdDZvi1/kWHTGNKkg itgUBWSW0bkpVo0fR3aGA0Ti9Xe2BgAYNB3boO9wmnoTvu3ym4/xN5Chn1FA1bxhKyqz 2y6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=DKT4oSakV7/N8zOuTi41t5buaEiHmVd7tLzjZjmza/c=; b=AIw2T4UkNp5jD8uibRDJxzdkdJGMj2IxsYPIqSvWaEfKRcWXXgE3Cpm4bxf95mRRO4 wPOgMhU2fhKu3m2OatMq4Ycc8Z7APsAomByNOqh8g3kGV3CYfom0vflwMZE76vOHu/yf 0lnSFzVZ2oMNZxZV8TKPMJB2uqVrRx8V+zuL/FOrDHSdqKDWjJNB+iehOj+zpI9xZnb9 5Bl9aLKKVXv457tMzBI/dSis/hroCisIKOUSPdSq/Wm9zD+mpt4ByExmtHGMj+Gc5OHv kUa3mmxVOxEHRoS22R0gKOZ7uVG/0V/8C9JDMPfZldBBzCN+M9mRwFX8F42J9E9JMF0q x7Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=p+lZLhCI; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f29si5955342edb.337.2019.11.01.01.13.49; Fri, 01 Nov 2019 01:13:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=p+lZLhCI; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729975AbfKAINs (ORCPT + 8 others); Fri, 1 Nov 2019 04:13:48 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:32036 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730157AbfKAINs (ORCPT ); Fri, 1 Nov 2019 04:13:48 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id xA18BsBP023869; Fri, 1 Nov 2019 17:11:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xA18BsBP023869 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1572595919; bh=DKT4oSakV7/N8zOuTi41t5buaEiHmVd7tLzjZjmza/c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+lZLhCIGNRrhqAVFCd4/+xWCG0VsMH/8bnzDKcUTnmj9pdpm+/pphxn+sgtHJ4Po kXgppL5ksqa87WfyKlm6sHsuZDMmC28gCCT+xrzoIqF/sCw+cw5dmxDg7sO/eI6kJk Whv9Mo/sJ3q1SenXgmW8EmgGfZ/E0kURYOCDRWWx22erdYJa/U/Ygp9cTYE2+EWh57 sWY+Y0zds89mWG2sD5TEN1qc11Lj6OqYHlyArtQ856eBhpaVs8aXoUrsBbAKzeAY13 xDlIFDW+uE76tkZSVgWCX0WlT+BbIqNZwKXhbhIjpv/X80bvh04p63u3nspYZJqXRs hkKfNiugxQbsw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: devicetree@vger.kernel.org, Rob Herring , Frank Rowand Cc: linux-arm-kernel@lists.infradead.org, David Gibson , linuxppc-dev@lists.ozlabs.org, Masahiro Yamada , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] ARM: decompressor: simplify libfdt builds Date: Fri, 1 Nov 2019 17:11:47 +0900 Message-Id: <20191101081148.23274-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101081148.23274-1-yamada.masahiro@socionext.com> References: <20191101081148.23274-1-yamada.masahiro@socionext.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Copying source files during the build time may not end up with as clean code as you expect. lib/fdt*.c simply wrap scripts/dtc/libfdt/fdt*.c, and it works nicely. Let's follow that approach for the arm decompressor, too. Add four wrappers, arch/arm/boot/compressed/fdt*.c and remove the Makefile messes. Another nice thing is we no longer need to maintain the separate libfdt_env.h since we can include , and the -- 2.17.1 diff stat also looks nice. Signed-off-by: Masahiro Yamada --- Changes in v2: None arch/arm/boot/compressed/.gitignore | 9 ------- arch/arm/boot/compressed/Makefile | 33 +++++++------------------ arch/arm/boot/compressed/atags_to_fdt.c | 1 + arch/arm/boot/compressed/fdt.c | 2 ++ arch/arm/boot/compressed/fdt_ro.c | 2 ++ arch/arm/boot/compressed/fdt_rw.c | 2 ++ arch/arm/boot/compressed/fdt_wip.c | 2 ++ arch/arm/boot/compressed/libfdt_env.h | 22 ----------------- 8 files changed, 18 insertions(+), 55 deletions(-) create mode 100644 arch/arm/boot/compressed/fdt.c create mode 100644 arch/arm/boot/compressed/fdt_ro.c create mode 100644 arch/arm/boot/compressed/fdt_rw.c create mode 100644 arch/arm/boot/compressed/fdt_wip.c delete mode 100644 arch/arm/boot/compressed/libfdt_env.h diff --git a/arch/arm/boot/compressed/.gitignore b/arch/arm/boot/compressed/.gitignore index 86b2f5d28240..2fdb4885846b 100644 --- a/arch/arm/boot/compressed/.gitignore +++ b/arch/arm/boot/compressed/.gitignore @@ -6,12 +6,3 @@ hyp-stub.S piggy_data vmlinux vmlinux.lds - -# borrowed libfdt files -fdt.c -fdt.h -fdt_ro.c -fdt_rw.c -fdt_wip.c -libfdt.h -libfdt_internal.h diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 9219389bbe61..a0d645c66980 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -76,29 +76,23 @@ compress-$(CONFIG_KERNEL_LZMA) = lzma compress-$(CONFIG_KERNEL_XZ) = xzkern compress-$(CONFIG_KERNEL_LZ4) = lz4 -# Borrowed libfdt files for the ATAG compatibility mode - -libfdt := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c -libfdt_hdrs := fdt.h libfdt.h libfdt_internal.h - -libfdt_objs := $(addsuffix .o, $(basename $(libfdt))) - -$(addprefix $(obj)/,$(libfdt) $(libfdt_hdrs)): $(obj)/%: $(srctree)/scripts/dtc/libfdt/% - $(call cmd,shipped) +ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) +libfdt_objs = fdt_rw.o fdt_ro.o fdt_wip.o fdt.o atags_to_fdt.o -$(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \ - $(addprefix $(obj)/,$(libfdt_hdrs)) +OBJS += $(libfdt_objs) -ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y) -OBJS += $(libfdt_objs) atags_to_fdt.o +# -fstack-protector-strong triggers protection checks in this code, +# but it is being used too early to link to meaningful stack_chk logic. +nossp_flags := $(call cc-option, -fno-stack-protector) +$(foreach o, $(libfdt_objs), \ + $(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt) $(nossp_flags)) endif targets := vmlinux vmlinux.lds piggy_data piggy.o \ lib1funcs.o ashldi3.o bswapsdi2.o \ head.o $(OBJS) -clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S \ - $(libfdt) $(libfdt_hdrs) hyp-stub.S +clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING KBUILD_CFLAGS += $(DISABLE_ARM_SSP_PER_TASK_PLUGIN) @@ -108,15 +102,6 @@ ORIG_CFLAGS := $(KBUILD_CFLAGS) KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS)) endif -# -fstack-protector-strong triggers protection checks in this code, -# but it is being used too early to link to meaningful stack_chk logic. -nossp_flags := $(call cc-option, -fno-stack-protector) -CFLAGS_atags_to_fdt.o := $(nossp_flags) -CFLAGS_fdt.o := $(nossp_flags) -CFLAGS_fdt_ro.o := $(nossp_flags) -CFLAGS_fdt_rw.o := $(nossp_flags) -CFLAGS_fdt_wip.o := $(nossp_flags) - ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin -I$(obj) asflags-y := -DZIMAGE diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c index 330cd3c2eae5..53a60ba066a1 100644 --- a/arch/arm/boot/compressed/atags_to_fdt.c +++ b/arch/arm/boot/compressed/atags_to_fdt.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include diff --git a/arch/arm/boot/compressed/fdt.c b/arch/arm/boot/compressed/fdt.c new file mode 100644 index 000000000000..f8ea7a201ab1 --- /dev/null +++ b/arch/arm/boot/compressed/fdt.c @@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../../../lib/fdt.c" diff --git a/arch/arm/boot/compressed/fdt_ro.c b/arch/arm/boot/compressed/fdt_ro.c new file mode 100644 index 000000000000..93970a4ad5ae --- /dev/null +++ b/arch/arm/boot/compressed/fdt_ro.c @@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../../../lib/fdt_ro.c" diff --git a/arch/arm/boot/compressed/fdt_rw.c b/arch/arm/boot/compressed/fdt_rw.c new file mode 100644 index 000000000000..f7c6b8b7e01c --- /dev/null +++ b/arch/arm/boot/compressed/fdt_rw.c @@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../../../lib/fdt_rw.c" diff --git a/arch/arm/boot/compressed/fdt_wip.c b/arch/arm/boot/compressed/fdt_wip.c new file mode 100644 index 000000000000..048d2c7a088d --- /dev/null +++ b/arch/arm/boot/compressed/fdt_wip.c @@ -0,0 +1,2 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "../../../../lib/fdt_wip.c" diff --git a/arch/arm/boot/compressed/libfdt_env.h b/arch/arm/boot/compressed/libfdt_env.h deleted file mode 100644 index b36c0289a308..000000000000 --- a/arch/arm/boot/compressed/libfdt_env.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ARM_LIBFDT_ENV_H -#define _ARM_LIBFDT_ENV_H - -#include -#include -#include - -#define INT_MAX ((int)(~0U>>1)) - -typedef __be16 fdt16_t; -typedef __be32 fdt32_t; -typedef __be64 fdt64_t; - -#define fdt16_to_cpu(x) be16_to_cpu(x) -#define cpu_to_fdt16(x) cpu_to_be16(x) -#define fdt32_to_cpu(x) be32_to_cpu(x) -#define cpu_to_fdt32(x) cpu_to_be32(x) -#define fdt64_to_cpu(x) be64_to_cpu(x) -#define cpu_to_fdt64(x) cpu_to_be64(x) - -#endif