| 69 | } |
| 70 | |
| 71 | error_t device_destruct(Device* device) { |
| 72 | lock_internal(device->internal); |
| 73 | |
| 74 | auto* internal = device->internal; |
| 75 | |
| 76 | if (internal->state.started || internal->state.added) { |
| 77 | unlock_internal(device->internal); |
| 78 | return ERROR_INVALID_STATE; |
| 79 | } |
| 80 | if (!internal->children.empty()) { |
| 81 | unlock_internal(device->internal); |
| 82 | return ERROR_INVALID_STATE; |
| 83 | } |
| 84 | LOG_D(TAG, "destruct %s", device->name); |
| 85 | |
| 86 | device->internal = nullptr; |
| 87 | mutex_unlock(&internal->mutex); |
| 88 | delete internal; |
| 89 | |
| 90 | return ERROR_NONE; |
| 91 | } |
| 92 | |
| 93 | /** Add a child to the list of children */ |
| 94 | static void device_add_child(struct Device* device, struct Device* child) { |
no test coverage detected