xref: /openbmc/qemu/util/nvdimm-utils.c (revision b785d25e)
1*4bd802b2SMarkus Armbruster #include "qemu/osdep.h"
23f350f6bSShivaprasad G Bhat #include "qemu/nvdimm-utils.h"
33f350f6bSShivaprasad G Bhat #include "hw/mem/nvdimm.h"
43f350f6bSShivaprasad G Bhat 
nvdimm_device_list(Object * obj,void * opaque)53f350f6bSShivaprasad G Bhat static int nvdimm_device_list(Object *obj, void *opaque)
63f350f6bSShivaprasad G Bhat {
73f350f6bSShivaprasad G Bhat     GSList **list = opaque;
83f350f6bSShivaprasad G Bhat 
93f350f6bSShivaprasad G Bhat     if (object_dynamic_cast(obj, TYPE_NVDIMM)) {
103f350f6bSShivaprasad G Bhat         *list = g_slist_append(*list, DEVICE(obj));
113f350f6bSShivaprasad G Bhat     }
123f350f6bSShivaprasad G Bhat 
133f350f6bSShivaprasad G Bhat     object_child_foreach(obj, nvdimm_device_list, opaque);
143f350f6bSShivaprasad G Bhat     return 0;
153f350f6bSShivaprasad G Bhat }
163f350f6bSShivaprasad G Bhat 
173f350f6bSShivaprasad G Bhat /*
183f350f6bSShivaprasad G Bhat  * inquire NVDIMM devices and link them into the list which is
193f350f6bSShivaprasad G Bhat  * returned to the caller.
203f350f6bSShivaprasad G Bhat  *
213f350f6bSShivaprasad G Bhat  * Note: it is the caller's responsibility to free the list to avoid
223f350f6bSShivaprasad G Bhat  * memory leak.
233f350f6bSShivaprasad G Bhat  */
nvdimm_get_device_list(void)243f350f6bSShivaprasad G Bhat GSList *nvdimm_get_device_list(void)
253f350f6bSShivaprasad G Bhat {
263f350f6bSShivaprasad G Bhat     GSList *list = NULL;
273f350f6bSShivaprasad G Bhat 
283f350f6bSShivaprasad G Bhat     object_child_foreach(qdev_get_machine(), nvdimm_device_list, &list);
293f350f6bSShivaprasad G Bhat     return list;
303f350f6bSShivaprasad G Bhat }
31