MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / device_construct_add

Function device_construct_add

TactilityKernel/source/device.cpp:209–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209error_t device_construct_add(struct Device* device, const char* compatible) {
210 struct Driver* driver = driver_find_compatible(compatible);
211 if (driver == nullptr) {
212 LOG_E(TAG, "Can't find driver '%s' for device '%s'", compatible, device->name);
213 return ERROR_RESOURCE;
214 }
215
216 error_t error = device_construct(device);
217 if (error != ERROR_NONE) {
218 LOG_E(TAG, "Failed to construct device %s: %s", device->name, error_to_string(error));
219 goto on_construct_error;
220 }
221
222 device_set_driver(device, driver);
223
224 error = device_add(device);
225 if (error != ERROR_NONE) {
226 LOG_E(TAG, "Failed to add device %s: %s", device->name, error_to_string(error));
227 goto on_add_error;
228 }
229
230 return ERROR_NONE;
231
232 on_add_error:
233 device_destruct(device);
234 on_construct_error:
235 return error;
236}
237
238error_t device_construct_add_start(struct Device* device, const char* compatible) {
239 error_t error = device_construct_add(device, compatible);

Callers 2

kernel_initFunction · 0.85

Calls 6

driver_find_compatibleFunction · 0.85
device_constructFunction · 0.85
error_to_stringFunction · 0.85
device_set_driverFunction · 0.85
device_addFunction · 0.85
device_destructFunction · 0.85

Tested by

no test coverage detected