summaryrefslogtreecommitdiff
path: root/Kernel/Graphics
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-07-16 10:39:57 +0300
committerLinus Groh <mail@linusgroh.de>2022-07-19 11:02:37 +0100
commit3af70cb0fcaddbf1d9888608496a474ab0f36c1b (patch)
tree61082fe9fdc78ebd398e329464905696a6aa12ef /Kernel/Graphics
parentda8d18b2633522ca8fdfa6d4bc80d49ceb1b22a5 (diff)
downloadserenity-3af70cb0fcaddbf1d9888608496a474ab0f36c1b.zip
Kernel/Devices: Abstract SysFS Device add/remove methods more properly
It is starting to get a little messy with how each device can try to add or remove itself to either /sys/dev/block or /sys/dev/char directories. To better do this, we introduce 4 virtual methods to take care of that, so until we ensure all nodes in /sys/dev/block and /sys/dev/char are actual symlinks, we allow the Device base class to call virtual methods upon insertion or before being destroying, so it add itself elegantly to either of these directories or remove itself when needed. For special cases where we need to create symlinks, we have two virtual methods to be called otherwise to do almost the same thing mentioned before, but to use symlinks instead.
Diffstat (limited to 'Kernel/Graphics')
-rw-r--r--Kernel/Graphics/DisplayConnector.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/Kernel/Graphics/DisplayConnector.cpp b/Kernel/Graphics/DisplayConnector.cpp
index 9cf8f327b8..4f117b8490 100644
--- a/Kernel/Graphics/DisplayConnector.cpp
+++ b/Kernel/Graphics/DisplayConnector.cpp
@@ -62,10 +62,8 @@ void DisplayConnector::will_be_destroyed()
GraphicsManagement::the().detach_display_connector({}, *this);
VERIFY(m_symlink_sysfs_component);
- VERIFY(!is_block_device());
- SysFSCharacterDevicesDirectory::the().m_child_components.with([&](auto& list) -> void {
- list.remove(*m_symlink_sysfs_component);
- });
+ before_will_be_destroyed_remove_symlink_from_device_identifier_directory();
+
m_symlink_sysfs_component.clear();
SysFSDisplayConnectorsDirectory::the().unplug({}, *m_sysfs_device_directory);
before_will_be_destroyed_remove_from_device_management();
@@ -80,10 +78,7 @@ void DisplayConnector::after_inserting()
VERIFY(!m_symlink_sysfs_component);
auto sys_fs_component = MUST(SysFSSymbolicLinkDeviceComponent::try_create(SysFSDeviceIdentifiersDirectory::the(), *this, *m_sysfs_device_directory));
m_symlink_sysfs_component = sys_fs_component;
- VERIFY(!is_block_device());
- SysFSCharacterDevicesDirectory::the().m_child_components.with([&](auto& list) -> void {
- list.append(*m_symlink_sysfs_component);
- });
+ after_inserting_add_symlink_to_device_identifier_directory();
auto rounded_size = MUST(Memory::page_round_up(m_framebuffer_resource_size));