diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-07-25 13:47:01 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-07-25 13:47:01 +0200 |
| commit | 501b4f27c5f8e114cc56762e30105112e86b885c (patch) | |
| tree | aad41040df57e2980e6275396d2f7f6aa557000e | |
| parent | b8e2f74374f7ab8dc82f923eb7333e4226cc5fdb (diff) | |
| download | kernel-501b4f27c5f8e114cc56762e30105112e86b885c.tar.xz kernel-501b4f27c5f8e114cc56762e30105112e86b885c.zip | |
kapi: fix driver probing
Previously, a driver was only bound after probing was successful.
However, if the probing itself relies (directly or indirectly) on the
device having a bound driver, probing fails. This patchset introduces
a new device state to mark that we are currently probing and thus the
bound driver is not yet definitively bound to the device. This allows
us to bind early, without violating the perceived device state.
| -rw-r--r-- | kapi/kapi/devices/device.hpp | 1 | ||||
| -rw-r--r-- | kernel/kapi/devices/driver_registry.cpp | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/kapi/kapi/devices/device.hpp b/kapi/kapi/devices/device.hpp index c8b32b8b..3f8a52d7 100644 --- a/kapi/kapi/devices/device.hpp +++ b/kapi/kapi/devices/device.hpp @@ -19,6 +19,7 @@ namespace kapi::devices { uninitialized, present, + probing, bound, failed, removed, diff --git a/kernel/kapi/devices/driver_registry.cpp b/kernel/kapi/devices/driver_registry.cpp index 5784694a..2ba9a485 100644 --- a/kernel/kapi/devices/driver_registry.cpp +++ b/kernel/kapi/devices/driver_registry.cpp @@ -105,15 +105,19 @@ namespace kapi::devices for (auto const & candidate : candidates) { + device->bind_driver(candidate.driver_handle); + device->set_state(state::probing); + auto probed = candidate.driver_handle->probe(*device); if (probed) { - device->bind_driver(candidate.driver_handle); device->set_state(state::bound); kstd::println("[OS:DRV] Bound device {} (priority {})", device->name(), candidate.priority); return; } + device->bind_driver(kstd::weak_ptr<driver>{}); + kstd::println(kstd::print_sink::stderr, "[OS:DRV] probe() failed for device {} (priority {}): {}", device->name(), candidate.priority, probed.error().message()); } |
