| 188 | } |
| 189 | |
| 190 | error_t device_stop(struct Device* device) { |
| 191 | LOG_I(TAG, "stop %s", device->name); |
| 192 | if (!device->internal->state.added) { |
| 193 | return ERROR_INVALID_STATE; |
| 194 | } |
| 195 | |
| 196 | if (!device->internal->state.started) { |
| 197 | return ERROR_NONE; |
| 198 | } |
| 199 | |
| 200 | if (driver_unbind(device->internal->driver, device) != ERROR_NONE) { |
| 201 | return ERROR_RESOURCE; |
| 202 | } |
| 203 | |
| 204 | device->internal->state.started = false; |
| 205 | device->internal->state.start_result = 0; |
| 206 | return ERROR_NONE; |
| 207 | } |
| 208 | |
| 209 | error_t device_construct_add(struct Device* device, const char* compatible) { |
| 210 | struct Driver* driver = driver_find_compatible(compatible); |
no test coverage detected