| 236 | } |
| 237 | |
| 238 | error_t device_construct_add_start(struct Device* device, const char* compatible) { |
| 239 | error_t error = device_construct_add(device, compatible); |
| 240 | if (error != ERROR_NONE) { |
| 241 | goto on_construct_add_error; |
| 242 | } |
| 243 | |
| 244 | error = device_start(device); |
| 245 | if (error != ERROR_NONE) { |
| 246 | LOG_E(TAG, "Failed to start device %s: %s", device->name, error_to_string(error)); |
| 247 | goto on_start_error; |
| 248 | } |
| 249 | |
| 250 | return ERROR_NONE; |
| 251 | |
| 252 | on_start_error: |
| 253 | device_remove(device); |
| 254 | device_destruct(device); |
| 255 | on_construct_add_error: |
| 256 | return error; |
| 257 | } |
| 258 | |
| 259 | void device_set_parent(Device* device, Device* parent) { |
| 260 | assert(!device->internal->state.started); |
no test coverage detected