aboutsummaryrefslogtreecommitdiff
path: root/kapi
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-07-24 01:12:48 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-07-24 01:12:48 +0200
commite6d79751cd37f2cbe0d4bd721e59a4ca0d072a55 (patch)
tree922f713c9dc45274dd4c32484584ff17a2dfdaa0 /kapi
parent7d241968ff4feb83bc23636df3a7ddb80f4bb4a9 (diff)
downloadkernel-e6d79751cd37f2cbe0d4bd721e59a4ca0d072a55.tar.xz
kernel-e6d79751cd37f2cbe0d4bd721e59a4ca0d072a55.zip
kapi: let drivers choose their major number
Diffstat (limited to 'kapi')
-rw-r--r--kapi/kapi/devices/device.hpp4
-rw-r--r--kapi/kapi/devices/driver.hpp3
-rw-r--r--kapi/kapi/devices/interface_registry.hpp4
3 files changed, 8 insertions, 3 deletions
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 <kapi/devices.hpp>
+#include <kapi/devices/driver.hpp>
#include <kapi/devices/interface.hpp>
#include <kstd/memory.hpp>
@@ -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<struct driver> 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 <kapi/devices.hpp>
-#include <kapi/devices/device.hpp>
#include <kapi/devices/interface.hpp>
#include <kstd/result.hpp>
@@ -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<device>
+ [[nodiscard]] constexpr auto device() const noexcept -> kstd::shared_ptr<device>
{
- return m_device;
+ return m_device.lock();
}
[[nodiscard]] constexpr auto name() const noexcept -> kstd::string const &