| 167 | } |
| 168 | |
| 169 | error_t device_start(Device* device) { |
| 170 | LOG_I(TAG, "start %s", device->name); |
| 171 | if (!device->internal->state.added) { |
| 172 | return ERROR_INVALID_STATE; |
| 173 | } |
| 174 | |
| 175 | if (device->internal->driver == nullptr) { |
| 176 | return ERROR_INVALID_STATE; |
| 177 | } |
| 178 | |
| 179 | // Already started |
| 180 | if (device->internal->state.started) { |
| 181 | return ERROR_NONE; |
| 182 | } |
| 183 | |
| 184 | error_t bind_error = driver_bind(device->internal->driver, device); |
| 185 | device->internal->state.started = (bind_error == ERROR_NONE); |
| 186 | device->internal->state.start_result = bind_error; |
| 187 | return bind_error == ERROR_NONE ? ERROR_NONE : ERROR_RESOURCE; |
| 188 | } |
| 189 | |
| 190 | error_t device_stop(struct Device* device) { |
| 191 | LOG_I(TAG, "stop %s", device->name); |
no test coverage detected