xref: /openbmc/qemu/util/nvdimm-utils.c (revision f0984d40)
1 #include "qemu/osdep.h"
2 #include "qemu/nvdimm-utils.h"
3 #include "hw/mem/nvdimm.h"
4 
5 static 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  */
24 GSList *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 }
31