aboutsummaryrefslogtreecommitdiff
path: root/kapi
diff options
context:
space:
mode:
Diffstat (limited to 'kapi')
-rw-r--r--kapi/kapi/devices/device.hpp6
-rw-r--r--kapi/kapi/devices/driver_registry.hpp3
2 files changed, 8 insertions, 1 deletions
diff --git a/kapi/kapi/devices/device.hpp b/kapi/kapi/devices/device.hpp
index 71856279..573cc0d0 100644
--- a/kapi/kapi/devices/device.hpp
+++ b/kapi/kapi/devices/device.hpp
@@ -5,6 +5,7 @@
#include <kapi/capabilities/facet_id.hpp>
#include <kapi/devices/driver.hpp>
+#include <kapi/tracked_mutex.hpp>
#include <kstd/memory.hpp>
#include <kstd/string.hpp>
@@ -119,7 +120,7 @@ namespace kapi::devices
auto bind_driver(kstd::weak_ptr<struct driver> driver) -> void;
//! Get the driver data associated with this device.
- [[nodiscard]] auto driver_data() const -> kstd::shared_ptr<void> const &;
+ [[nodiscard]] auto driver_data() const -> kstd::shared_ptr<void>;
//! Set the driver data for this device.
auto set_driver_data(kstd::shared_ptr<void> data) -> void;
@@ -139,6 +140,9 @@ namespace kapi::devices
auto set_parent(kstd::weak_ptr<struct bus> parent) -> void;
kstd::string m_name;
+
+ mutable tracked_mutex m_lock{};
+
kstd::weak_ptr<bus> m_parent;
devices::state m_state{state::uninitialized};
kstd::weak_ptr<struct driver> m_driver{};
diff --git a/kapi/kapi/devices/driver_registry.hpp b/kapi/kapi/devices/driver_registry.hpp
index 8a733c90..8af76b01 100644
--- a/kapi/kapi/devices/driver_registry.hpp
+++ b/kapi/kapi/devices/driver_registry.hpp
@@ -3,6 +3,7 @@
#include <kapi/devices/device.hpp>
#include <kapi/devices/driver.hpp>
+#include <kapi/tracked_mutex.hpp>
#include <kstd/memory.hpp>
#include <kstd/vector.hpp>
@@ -41,6 +42,8 @@ namespace kapi::devices
//! Driver matching will occur in driver registration order. The highest priority driver will win.
auto try_bind(kstd::shared_ptr<device> const & device) -> void;
+ mutable tracked_mutex m_lock{};
+
kstd::vector<kstd::shared_ptr<driver>> m_drivers{};
};