summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Devices/DeviceManagement.cpp9
-rw-r--r--Kernel/Devices/DeviceManagement.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/Kernel/Devices/DeviceManagement.cpp b/Kernel/Devices/DeviceManagement.cpp
index af82467454..134f67c847 100644
--- a/Kernel/Devices/DeviceManagement.cpp
+++ b/Kernel/Devices/DeviceManagement.cpp
@@ -109,6 +109,15 @@ void DeviceManagement::for_each(Function<void(Device&)> callback)
});
}
+ErrorOr<void> DeviceManagement::try_for_each(Function<ErrorOr<void>(Device&)> callback)
+{
+ return m_devices.with([&](auto& map) -> ErrorOr<void> {
+ for (auto& entry : map)
+ TRY(callback(*entry.value));
+ return {};
+ });
+}
+
NullDevice& DeviceManagement::null_device()
{
return *m_null_device;
diff --git a/Kernel/Devices/DeviceManagement.h b/Kernel/Devices/DeviceManagement.h
index e23f86ce92..0b4f57ee7b 100644
--- a/Kernel/Devices/DeviceManagement.h
+++ b/Kernel/Devices/DeviceManagement.h
@@ -44,6 +44,7 @@ public:
void before_device_removal(Badge<Device>, Device&);
void for_each(Function<void(Device&)>);
+ ErrorOr<void> try_for_each(Function<ErrorOr<void>(Device&)>);
Device* get_device(MajorNumber major, MinorNumber minor);
NullDevice const& null_device() const;