blob: aa3d199f2d117616e8bacf8103e3760e8ba45a52 [file] [log] [blame]
Markus Armbruster4bd802b2020-11-13 07:12:16 +01001#include "qemu/osdep.h"
Shivaprasad G Bhat3f350f62020-02-09 22:56:02 -06002#include "qemu/nvdimm-utils.h"
3#include "hw/mem/nvdimm.h"
4
5static int nvdimm_device_list(Object *obj, void *opaque)
6{
7 GSList **list = opaque;
8
9 if (object_dynamic_cast(obj, TYPE_NVDIMM)) {
10 *list = g_slist_append(*list, DEVICE(obj));
11 }
12
13 object_child_foreach(obj, nvdimm_device_list, opaque);
14 return 0;
15}
16
17/*
18 * inquire NVDIMM devices and link them into the list which is
19 * returned to the caller.
20 *
21 * Note: it is the caller's responsibility to free the list to avoid
22 * memory leak.
23 */
24GSList *nvdimm_get_device_list(void)
25{
26 GSList *list = NULL;
27
28 object_child_foreach(qdev_get_machine(), nvdimm_device_list, &list);
29 return list;
30}