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

Function device_remove

TactilityKernel/source/device.cpp:134–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134error_t device_remove(Device* device) {
135 LOG_D(TAG, "remove %s", device->name);
136
137 if (device->internal->state.started || !device->internal->state.added) {
138 return ERROR_INVALID_STATE;
139 }
140
141 // Remove self from parent's children list
142 auto* parent = device->parent;
143 if (parent != nullptr) {
144 device_remove_child(parent, device);
145 }
146
147 ledger_lock();
148 const auto iterator = std::ranges::find(ledger.devices, device);
149 if (iterator == ledger.devices.end()) {
150 ledger_unlock();
151 goto failed_ledger_lookup;
152 }
153 ledger.devices.erase(iterator);
154 ledger_unlock();
155
156 device->internal->state.added = false;
157 return ERROR_NONE;
158
159failed_ledger_lookup:
160
161 // Re-add to parent
162 if (parent != nullptr) {
163 device_add_child(parent, device);
164 }
165
166 return ERROR_NOT_FOUND;
167}
168
169error_t device_start(Device* device) {
170 LOG_I(TAG, "start %s", device->name);

Callers 6

DeviceTest.cppFile · 0.85
stop_childFunction · 0.85
destroy_child_deviceFunction · 0.85

Calls 2

device_remove_childFunction · 0.85
device_add_childFunction · 0.85

Tested by

no test coverage detected