From 12002c540c9de2342d829c5b073c65cfb4549b35 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 27 Jul 2026 00:08:49 +0200 Subject: kapi: fix driver registry locking --- kapi/kapi/devices/device.hpp | 6 +++++- kapi/kapi/devices/driver_registry.hpp | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'kapi') 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 #include +#include #include #include @@ -119,7 +120,7 @@ namespace kapi::devices auto bind_driver(kstd::weak_ptr driver) -> void; //! Get the driver data associated with this device. - [[nodiscard]] auto driver_data() const -> kstd::shared_ptr const &; + [[nodiscard]] auto driver_data() const -> kstd::shared_ptr; //! Set the driver data for this device. auto set_driver_data(kstd::shared_ptr data) -> void; @@ -139,6 +140,9 @@ namespace kapi::devices auto set_parent(kstd::weak_ptr parent) -> void; kstd::string m_name; + + mutable tracked_mutex m_lock{}; + kstd::weak_ptr m_parent; devices::state m_state{state::uninitialized}; kstd::weak_ptr 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 #include +#include #include #include @@ -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 const & device) -> void; + mutable tracked_mutex m_lock{}; + kstd::vector> m_drivers{}; }; -- cgit v1.2.3