mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
Kernel/Devices: Add two protected methods for DeviceManagement functions
These methods are essentially splitted from the after_inserting method and the will_be_destroyed method so later on we can allow Storage devices to override the after_inserting method and the will_be_destroyed method while still being able to use shared functionality as before, such as adding the device to and removing it from the device list.
This commit is contained in:
parent
9b49d9ee60
commit
22335e53e0
2 changed files with 16 additions and 3 deletions
|
@ -21,9 +21,20 @@ Device::Device(MajorNumber major, MinorNumber minor)
|
|||
{
|
||||
}
|
||||
|
||||
void Device::after_inserting()
|
||||
void Device::before_will_be_destroyed_remove_from_device_management()
|
||||
{
|
||||
DeviceManagement::the().before_device_removal({}, *this);
|
||||
m_state = State::BeingRemoved;
|
||||
}
|
||||
|
||||
void Device::after_inserting_add_to_device_management()
|
||||
{
|
||||
DeviceManagement::the().after_inserting_device({}, *this);
|
||||
}
|
||||
|
||||
void Device::after_inserting()
|
||||
{
|
||||
after_inserting_add_to_device_management();
|
||||
VERIFY(!m_sysfs_component);
|
||||
auto sys_fs_component = SysFSDeviceComponent::must_create(*this);
|
||||
m_sysfs_component = sys_fs_component;
|
||||
|
@ -52,8 +63,7 @@ void Device::will_be_destroyed()
|
|||
list.remove(*m_sysfs_component);
|
||||
});
|
||||
}
|
||||
DeviceManagement::the().before_device_removal({}, *this);
|
||||
m_state = State::BeingRemoved;
|
||||
before_will_be_destroyed_remove_from_device_management();
|
||||
}
|
||||
|
||||
Device::~Device()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue