summaryrefslogtreecommitdiffstats
path: root/core/device.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/device.cpp')
-rw-r--r--core/device.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/core/device.cpp b/core/device.cpp
index 512d17d57..764531414 100644
--- a/core/device.cpp
+++ b/core/device.cpp
@@ -299,17 +299,24 @@ extern "C" void create_device_node(struct device_table *device_table, const char
}
/* Does not check for duplicates! */
-extern "C" void add_to_device_table(struct device_table *device_table, const struct device *dev)
+extern "C" int add_to_device_table(struct device_table *device_table, const struct device *dev)
{
auto it = std::lower_bound(device_table->devices.begin(), device_table->devices.end(), *dev);
+ int idx = it - device_table->devices.begin();
device_table->devices.insert(it, *dev);
+ return idx;
}
-extern "C" void remove_device(struct device_table *device_table, const struct device *dev)
+extern "C" int remove_device(struct device_table *device_table, const struct device *dev)
{
auto it = std::lower_bound(device_table->devices.begin(), device_table->devices.end(), *dev);
- if (it != device_table->devices.end() && same_device(*it, *dev))
+ if (it != device_table->devices.end() && same_device(*it, *dev)) {
+ int idx = it - device_table->devices.begin();
device_table->devices.erase(it);
+ return idx;
+ } else {
+ return -1;
+ }
}
extern "C" void clear_device_table(struct device_table *device_table)