diff mbox

[U-Boot,v2,03/14] cmd: qfw: remove qemu_fwcfg_free_files()

Message ID 1463564400-34779-4-git-send-email-yanmiaobest@gmail.com
State Superseded
Delegated to: Bin Meng
Headers show

Commit Message

Miao Yan May 18, 2016, 9:39 a.m. UTC
This patch is part of the qfw refactor work.

The qemu_fwcfg_free_files() function is only used in error handling in
ACPI table generation, let's not make this a core function and move it
to the right place.

Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
---
 arch/x86/cpu/qemu/acpi_table.c | 13 +++++++++++--
 cmd/qemu_fw_cfg.c              | 12 ------------
 include/qemu_fw_cfg.h          |  1 -
 3 files changed, 11 insertions(+), 15 deletions(-)

Comments

Bin Meng May 19, 2016, 9:05 a.m. UTC | #1
On Wed, May 18, 2016 at 5:39 PM, Miao Yan <yanmiaobest@gmail.com> wrote:
> This patch is part of the qfw refactor work.
>
> The qemu_fwcfg_free_files() function is only used in error handling in
> ACPI table generation, let's not make this a core function and move it
> to the right place.
>
> Signed-off-by: Miao Yan <yanmiaobest@gmail.com>
> ---
>  arch/x86/cpu/qemu/acpi_table.c | 13 +++++++++++--
>  cmd/qemu_fw_cfg.c              | 12 ------------
>  include/qemu_fw_cfg.h          |  1 -
>  3 files changed, 11 insertions(+), 15 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
diff mbox

Patch

diff --git a/arch/x86/cpu/qemu/acpi_table.c b/arch/x86/cpu/qemu/acpi_table.c
index 49381ac..b17fa03 100644
--- a/arch/x86/cpu/qemu/acpi_table.c
+++ b/arch/x86/cpu/qemu/acpi_table.c
@@ -235,8 +235,17 @@  u32 write_acpi_tables(u32 addr)
 	}
 
 out:
-	if (ret)
-		qemu_fwcfg_free_files();
+	if (ret) {
+		struct fw_cfg_file_iter iter;
+		for (file = qemu_fwcfg_file_iter_init(&iter);
+		     !qemu_fwcfg_file_iter_end(&iter);
+		     file = qemu_fwcfg_file_iter_next(&iter)) {
+			if (file->addr) {
+				free((void *)file->addr);
+				file->addr = 0;
+			}
+		}
+	}
 
 	free(table_loader);
 	return addr;
diff --git a/cmd/qemu_fw_cfg.c b/cmd/qemu_fw_cfg.c
index 192b7d1..9f03ab6 100644
--- a/cmd/qemu_fw_cfg.c
+++ b/cmd/qemu_fw_cfg.c
@@ -217,18 +217,6 @@  struct fw_file *qemu_fwcfg_find_file(const char *name)
 	return NULL;
 }
 
-void qemu_fwcfg_free_files(void)
-{
-	struct fw_file *file;
-	struct list_head *list;
-
-	list_for_each(list, &fw_list) {
-		file = list_entry(list, struct fw_file, list);
-		if (file->addr)
-			free((void *)file->addr);
-	}
-}
-
 struct fw_file *qemu_fwcfg_file_iter_init(struct fw_cfg_file_iter *iter)
 {
 	iter->entry = fw_list.next;
diff --git a/include/qemu_fw_cfg.h b/include/qemu_fw_cfg.h
index 19d0ba0..986f4b2 100644
--- a/include/qemu_fw_cfg.h
+++ b/include/qemu_fw_cfg.h
@@ -154,7 +154,6 @@  void qemu_fwcfg_init(void);
 void qemu_fwcfg_read_entry(uint16_t entry, uint32_t length, void *address);
 int qemu_fwcfg_read_firmware_list(void);
 struct fw_file *qemu_fwcfg_find_file(const char *name);
-void qemu_fwcfg_free_files(void);
 
 /**
  * Get system cpu number