xref: /openbmc/qemu/util/nvdimm-utils.c (revision 88cd34ee)
1 #include "qemu/nvdimm-utils.h"
2 #include "hw/mem/nvdimm.h"
3 
4 static int nvdimm_device_list(Object *obj, void *opaque)
5 {
6     GSList **list = opaque;
7 
8     if (object_dynamic_cast(obj, TYPE_NVDIMM)) {
9         *list = g_slist_append(*list, DEVICE(obj));
10     }
11 
12     object_child_foreach(obj, nvdimm_device_list, opaque);
13     return 0;
14 }
15 
16 /*
17  * inquire NVDIMM devices and link them into the list which is
18  * returned to the caller.
19  *
20  * Note: it is the caller's responsibility to free the list to avoid
21  * memory leak.
22  */
23 GSList *nvdimm_get_device_list(void)
24 {
25     GSList *list = NULL;
26 
27     object_child_foreach(qdev_get_machine(), nvdimm_device_list, &list);
28     return list;
29 }
30