summaryrefslogtreecommitdiff
path: root/Kernel/Devices
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-04-23 00:26:36 +0300
committerAndreas Kling <kling@serenityos.org>2022-07-15 12:29:23 +0200
commit6733f19b3ce91537994fd4eddeff20a31d96c8ba (patch)
treeb4538c10e604f31bf06dba1c6a2c597e80ee6898 /Kernel/Devices
parentecc29bb52e6fcd8be14be38106c3061aacd21744 (diff)
downloadserenity-6733f19b3ce91537994fd4eddeff20a31d96c8ba.zip
Kernel/SysFS: Reduce the responsibilities of the Registry object
Instead, let the /sys/dev/block and /sys/dev/char directories to handle the registering part of SysFSDeviceComponents by themselves.
Diffstat (limited to 'Kernel/Devices')
-rw-r--r--Kernel/Devices/Device.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp
index 966325f6e7..34df75f350 100644
--- a/Kernel/Devices/Device.cpp
+++ b/Kernel/Devices/Device.cpp
@@ -9,6 +9,8 @@
#include <Kernel/Devices/DeviceManagement.h>
#include <Kernel/FileSystem/InodeMetadata.h>
#include <Kernel/FileSystem/SysFS.h>
+#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/BlockDevicesDirectory.h>
+#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/CharacterDevicesDirectory.h>
#include <Kernel/Sections.h>
namespace Kernel {
@@ -25,7 +27,14 @@ void Device::after_inserting()
VERIFY(!m_sysfs_component);
auto sys_fs_component = SysFSDeviceComponent::must_create(*this);
m_sysfs_component = sys_fs_component;
- SysFSComponentRegistry::the().devices_list().with_exclusive([&](auto& list) -> void {
+ if (is_block_device()) {
+ SysFSBlockDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
+ list.append(sys_fs_component);
+ });
+ return;
+ }
+ VERIFY(is_character_device());
+ SysFSCharacterDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
list.append(sys_fs_component);
});
}
@@ -33,9 +42,16 @@ void Device::after_inserting()
void Device::will_be_destroyed()
{
VERIFY(m_sysfs_component);
- SysFSComponentRegistry::the().devices_list().with_exclusive([&](auto& list) -> void {
- list.remove(*m_sysfs_component);
- });
+ if (is_block_device()) {
+ SysFSBlockDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
+ list.remove(*m_sysfs_component);
+ });
+ } else {
+ VERIFY(is_character_device());
+ SysFSCharacterDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
+ list.remove(*m_sysfs_component);
+ });
+ }
DeviceManagement::the().before_device_removal({}, *this);
m_state = State::BeingRemoved;
}