Markus Armbruster | 4bd802b | 2020-11-13 07:12:16 +0100 | [diff] [blame] | 1 | #include "qemu/osdep.h" |
Shivaprasad G Bhat | 3f350f6 | 2020-02-09 22:56:02 -0600 | [diff] [blame] | 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 | } |