From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/8] efi: move FDT handling to separate object file
Date: Mon, 11 May 2015 08:41:56 +0200 [thread overview]
Message-ID: <1431326520-17331-5-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org>
The EFI specific FDT handling is compiled conditionally, and is
logically independent of the rest of efi.o. So move it to a separate
file before making changes to it in subsequent patches.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
drivers/firmware/efi/Makefile | 1 +
drivers/firmware/efi/efi-fdt.c | 93 ++++++++++++++++++++++++++++++++++++++++++
drivers/firmware/efi/efi.c | 86 --------------------------------------
3 files changed, 94 insertions(+), 86 deletions(-)
create mode 100644 drivers/firmware/efi/efi-fdt.c
diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile
index d8be608a9f3b..9967dde52174 100644
--- a/drivers/firmware/efi/Makefile
+++ b/drivers/firmware/efi/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_UEFI_CPER) += cper.o
obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o
obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o
obj-$(CONFIG_EFI_STUB) += libstub/
+obj-$(CONFIG_EFI_PARAMS_FROM_FDT) += efi-fdt.o
diff --git a/drivers/firmware/efi/efi-fdt.c b/drivers/firmware/efi/efi-fdt.c
new file mode 100644
index 000000000000..f0e7ef2ae0e9
--- /dev/null
+++ b/drivers/firmware/efi/efi-fdt.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2013 - 2015 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/efi.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+
+#define UEFI_PARAM(name, prop, field) \
+ { \
+ { name }, \
+ { prop }, \
+ offsetof(struct efi_fdt_params, field), \
+ FIELD_SIZEOF(struct efi_fdt_params, field) \
+ }
+
+static __initdata struct {
+ const char name[32];
+ const char propname[32];
+ int offset;
+ int size;
+} dt_params[] = {
+ UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
+ UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
+ UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
+ UEFI_PARAM("MemMap Desc. Size", "linux,uefi-mmap-desc-size", desc_size),
+ UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
+};
+
+struct param_info {
+ int verbose;
+ int found;
+ void *params;
+};
+
+static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
+ int depth, void *data)
+{
+ struct param_info *info = data;
+ const void *prop;
+ void *dest;
+ u64 val;
+ int i, len;
+
+ if (depth != 1 || strcmp(uname, "chosen") != 0)
+ return 0;
+
+ for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
+ prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
+ if (!prop)
+ return 0;
+ dest = info->params + dt_params[i].offset;
+ info->found++;
+
+ val = of_read_number(prop, len / sizeof(u32));
+
+ if (dt_params[i].size == sizeof(u32))
+ *(u32 *)dest = val;
+ else
+ *(u64 *)dest = val;
+
+ if (info->verbose)
+ pr_info(" %s: 0x%0*llx\n", dt_params[i].name,
+ dt_params[i].size * 2, val);
+ }
+ return 1;
+}
+
+int __init efi_get_fdt_params(struct efi_fdt_params *params, int verbose)
+{
+ struct param_info info;
+ int ret;
+
+ pr_info("Getting EFI parameters from FDT:\n");
+
+ info.verbose = verbose;
+ info.found = 0;
+ info.params = params;
+
+ ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
+ if (!info.found)
+ pr_info("UEFI not found.\n");
+ else if (!ret)
+ pr_err("Can't find '%s' in device tree!\n",
+ dt_params[info.found].name);
+
+ return ret;
+}
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 3061bb8629dc..e546c3e4f127 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -20,8 +20,6 @@
#include <linux/init.h>
#include <linux/device.h>
#include <linux/efi.h>
-#include <linux/of.h>
-#include <linux/of_fdt.h>
#include <linux/io.h>
#include <linux/platform_device.h>
@@ -377,90 +375,6 @@ static int __init efi_load_efivars(void)
device_initcall(efi_load_efivars);
#endif
-#ifdef CONFIG_EFI_PARAMS_FROM_FDT
-
-#define UEFI_PARAM(name, prop, field) \
- { \
- { name }, \
- { prop }, \
- offsetof(struct efi_fdt_params, field), \
- FIELD_SIZEOF(struct efi_fdt_params, field) \
- }
-
-static __initdata struct {
- const char name[32];
- const char propname[32];
- int offset;
- int size;
-} dt_params[] = {
- UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
- UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
- UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
- UEFI_PARAM("MemMap Desc. Size", "linux,uefi-mmap-desc-size", desc_size),
- UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
-};
-
-struct param_info {
- int verbose;
- int found;
- void *params;
-};
-
-static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
- int depth, void *data)
-{
- struct param_info *info = data;
- const void *prop;
- void *dest;
- u64 val;
- int i, len;
-
- if (depth != 1 || strcmp(uname, "chosen") != 0)
- return 0;
-
- for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
- prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
- if (!prop)
- return 0;
- dest = info->params + dt_params[i].offset;
- info->found++;
-
- val = of_read_number(prop, len / sizeof(u32));
-
- if (dt_params[i].size == sizeof(u32))
- *(u32 *)dest = val;
- else
- *(u64 *)dest = val;
-
- if (info->verbose)
- pr_info(" %s: 0x%0*llx\n", dt_params[i].name,
- dt_params[i].size * 2, val);
- }
- return 1;
-}
-
-int __init efi_get_fdt_params(struct efi_fdt_params *params, int verbose)
-{
- struct param_info info;
- int ret;
-
- pr_info("Getting EFI parameters from FDT:\n");
-
- info.verbose = verbose;
- info.found = 0;
- info.params = params;
-
- ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
- if (!info.found)
- pr_info("UEFI not found.\n");
- else if (!ret)
- pr_err("Can't find '%s' in device tree!\n",
- dt_params[info.found].name);
-
- return ret;
-}
-#endif /* CONFIG_EFI_PARAMS_FROM_FDT */
-
static __initdata char memory_type_name[][20] = {
"Reserved",
"Loader Code",
--
1.9.1
next prev parent reply other threads:[~2015-05-11 6:41 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-11 6:41 [PATCH 0/8] arm64 UEFI early FDT handling Ard Biesheuvel
2015-05-11 6:41 ` [PATCH 1/8] of/fdt: split off FDT self reservation from memreserve processing Ard Biesheuvel
2015-05-22 10:35 ` Catalin Marinas
2015-06-01 7:56 ` Ard Biesheuvel
2015-06-01 9:56 ` Mark Rutland
2015-06-01 10:46 ` Ard Biesheuvel
2015-06-01 11:02 ` Mark Rutland
2015-06-01 11:14 ` Ard Biesheuvel
2015-06-01 11:18 ` Mark Rutland
2015-05-11 6:41 ` [PATCH 2/8] arm64: use fixmap region for permanent FDT mapping Ard Biesheuvel
2015-06-01 9:53 ` Mark Rutland
2015-06-01 9:55 ` Ard Biesheuvel
2015-05-11 6:41 ` [PATCH 3/8] arm64: override early_init_dt_add_memory_arch() Ard Biesheuvel
2015-05-11 6:41 ` Ard Biesheuvel [this message]
2015-05-26 18:15 ` [PATCH 4/8] efi: move FDT handling to separate object file Matt Fleming
2015-05-11 6:41 ` [PATCH 5/8] arm64/efi: move EFI init before early FDT processing Ard Biesheuvel
2015-05-11 6:41 ` [PATCH 6/8] arm64/efi: ignore DT memory nodes instead of removing them Ard Biesheuvel
2015-05-11 16:28 ` Ganapatrao Kulkarni
2015-05-12 14:31 ` Leif Lindholm
2015-05-12 15:01 ` Ard Biesheuvel
2015-05-11 6:41 ` [PATCH 7/8] arm64/efi: ignore DT memreserve entries " Ard Biesheuvel
2015-05-11 6:42 ` [PATCH 8/8] arm64/efi: adapt to relaxed FDT placement requirements Ard Biesheuvel
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=1431326520-17331-5-git-send-email-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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).