[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/20] mem: move nvdimm_device_list to utilities
From: |
David Gibson |
Subject: |
[PULL 05/20] mem: move nvdimm_device_list to utilities |
Date: |
Fri, 21 Feb 2020 14:36:35 +1100 |
From: Shivaprasad G Bhat <address@hidden>
nvdimm_device_list is required for parsing the list for devices
in subsequent patches. Move it to common utility area.
Signed-off-by: Shivaprasad G Bhat <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Reviewed-by: David Gibson <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/acpi/nvdimm.c | 28 +---------------------------
include/qemu/nvdimm-utils.h | 7 +++++++
util/Makefile.objs | 1 +
util/nvdimm-utils.c | 29 +++++++++++++++++++++++++++++
4 files changed, 38 insertions(+), 27 deletions(-)
create mode 100644 include/qemu/nvdimm-utils.h
create mode 100644 util/nvdimm-utils.c
diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c
index 9fdad6dc3f..5219dd0e2e 100644
--- a/hw/acpi/nvdimm.c
+++ b/hw/acpi/nvdimm.c
@@ -32,33 +32,7 @@
#include "hw/acpi/bios-linker-loader.h"
#include "hw/nvram/fw_cfg.h"
#include "hw/mem/nvdimm.h"
-
-static int nvdimm_device_list(Object *obj, void *opaque)
-{
- GSList **list = opaque;
-
- if (object_dynamic_cast(obj, TYPE_NVDIMM)) {
- *list = g_slist_append(*list, DEVICE(obj));
- }
-
- object_child_foreach(obj, nvdimm_device_list, opaque);
- return 0;
-}
-
-/*
- * inquire NVDIMM devices and link them into the list which is
- * returned to the caller.
- *
- * Note: it is the caller's responsibility to free the list to avoid
- * memory leak.
- */
-static GSList *nvdimm_get_device_list(void)
-{
- GSList *list = NULL;
-
- object_child_foreach(qdev_get_machine(), nvdimm_device_list, &list);
- return list;
-}
+#include "qemu/nvdimm-utils.h"
#define NVDIMM_UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
diff --git a/include/qemu/nvdimm-utils.h b/include/qemu/nvdimm-utils.h
new file mode 100644
index 0000000000..4b8b198ba7
--- /dev/null
+++ b/include/qemu/nvdimm-utils.h
@@ -0,0 +1,7 @@
+#ifndef NVDIMM_UTILS_H
+#define NVDIMM_UTILS_H
+
+#include "qemu/osdep.h"
+
+GSList *nvdimm_get_device_list(void);
+#endif
diff --git a/util/Makefile.objs b/util/Makefile.objs
index 11262aafaf..6b38b67cf1 100644
--- a/util/Makefile.objs
+++ b/util/Makefile.objs
@@ -20,6 +20,7 @@ util-obj-y += envlist.o path.o module.o
util-obj-y += host-utils.o
util-obj-y += bitmap.o bitops.o hbitmap.o
util-obj-y += fifo8.o
+util-obj-y += nvdimm-utils.o
util-obj-y += cacheinfo.o
util-obj-y += error.o qemu-error.o
util-obj-y += qemu-print.o
diff --git a/util/nvdimm-utils.c b/util/nvdimm-utils.c
new file mode 100644
index 0000000000..5cc768ca47
--- /dev/null
+++ b/util/nvdimm-utils.c
@@ -0,0 +1,29 @@
+#include "qemu/nvdimm-utils.h"
+#include "hw/mem/nvdimm.h"
+
+static int nvdimm_device_list(Object *obj, void *opaque)
+{
+ GSList **list = opaque;
+
+ if (object_dynamic_cast(obj, TYPE_NVDIMM)) {
+ *list = g_slist_append(*list, DEVICE(obj));
+ }
+
+ object_child_foreach(obj, nvdimm_device_list, opaque);
+ return 0;
+}
+
+/*
+ * inquire NVDIMM devices and link them into the list which is
+ * returned to the caller.
+ *
+ * Note: it is the caller's responsibility to free the list to avoid
+ * memory leak.
+ */
+GSList *nvdimm_get_device_list(void)
+{
+ GSList *list = NULL;
+
+ object_child_foreach(qdev_get_machine(), nvdimm_device_list, &list);
+ return list;
+}
--
2.24.1
- [PULL 00/20] ppc-for-5.0 queue 20200221, David Gibson, 2020/02/20
- [PULL 04/20] ppc: function to setup latest class options, David Gibson, 2020/02/20
- [PULL 01/20] spapr/rtas: Print message from "ibm,os-term", David Gibson, 2020/02/20
- [PULL 03/20] ppc/pnv: Fix PCI_EXPRESS dependency, David Gibson, 2020/02/20
- [PULL 02/20] qtest: Fix rtas dependencies, David Gibson, 2020/02/20
- [PULL 05/20] mem: move nvdimm_device_list to utilities,
David Gibson <=
- [PULL 08/20] spapr: Add Hcalls to support PAPR NVDIMM device, David Gibson, 2020/02/20
- [PULL 06/20] nvdimm: add uuid property to nvdimm, David Gibson, 2020/02/20
- [PULL 09/20] target/ppc/cpu.h: Remove duplicate includes, David Gibson, 2020/02/20
- [PULL 07/20] spapr: Add NVDIMM device support, David Gibson, 2020/02/20
- [PULL 12/20] pnv/phb3: Add missing break statement, David Gibson, 2020/02/20
- [PULL 10/20] pnv/phb3: Convert 1u to 1ull, David Gibson, 2020/02/20
- [PULL 16/20] target/ppc/cpu.h: Clean up comments in the struct CPUPPCState definition, David Gibson, 2020/02/20
- [PULL 17/20] ppc: free 'fdt' after reset the machine, David Gibson, 2020/02/20