From e6d79751cd37f2cbe0d4bd721e59a4ca0d072a55 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 24 Jul 2026 01:12:48 +0200 Subject: kapi: let drivers choose their major number --- kapi/kapi/devices/device.hpp | 4 ++++ kapi/kapi/devices/driver.hpp | 3 ++- kapi/kapi/devices/interface_registry.hpp | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'kapi') diff --git a/kapi/kapi/devices/device.hpp b/kapi/kapi/devices/device.hpp index 70c5bd15..c26a4701 100644 --- a/kapi/kapi/devices/device.hpp +++ b/kapi/kapi/devices/device.hpp @@ -3,6 +3,7 @@ // IWYU pragma: private, include +#include #include #include @@ -74,6 +75,9 @@ namespace kapi::devices //! Set the lifecycle state of this device. auto set_state(enum state state) -> void; + //! Get the driver, if any, currently bound to this device. + [[nodiscard]] auto bound_driver() const noexcept -> driver *; + //! Bind this device to the given driver. auto bind_driver(kstd::weak_ptr driver) -> void; diff --git a/kapi/kapi/devices/driver.hpp b/kapi/kapi/devices/driver.hpp index 254f7977..837b47e4 100644 --- a/kapi/kapi/devices/driver.hpp +++ b/kapi/kapi/devices/driver.hpp @@ -3,7 +3,6 @@ // IWYU pragma: private, include -#include #include #include @@ -17,6 +16,8 @@ namespace kapi::devices //! @addtogroup kapi-devices-kernel-defined //! @{ + struct device; + //! The base type for all device drivers. //! //! Drivers model the behavior necessary to drive a device or bus. They are stateless logic and are thus never diff --git a/kapi/kapi/devices/interface_registry.hpp b/kapi/kapi/devices/interface_registry.hpp index 9fad91e6..ae8b5c1a 100644 --- a/kapi/kapi/devices/interface_registry.hpp +++ b/kapi/kapi/devices/interface_registry.hpp @@ -30,9 +30,9 @@ namespace kapi::devices , m_implementation{implementation} {} - [[nodiscard]] constexpr auto device() const noexcept -> kstd::weak_ptr + [[nodiscard]] constexpr auto device() const noexcept -> kstd::shared_ptr { - return m_device; + return m_device.lock(); } [[nodiscard]] constexpr auto name() const noexcept -> kstd::string const & -- cgit v1.2.3