summaryrefslogtreecommitdiff
path: root/Kernel/Devices/DeviceManagement.cpp
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-12-23 20:08:18 +0200
committerAndreas Kling <kling@serenityos.org>2021-12-23 23:02:39 +0100
commit9eb08bdb0f7460eb9874a5d16f6f3808f3d8a8f0 (patch)
tree79c20875f3cd0977fc809964f2e5f7a771ce1428 /Kernel/Devices/DeviceManagement.cpp
parent6d149400534643d2d4549853b257c136c3a8d47c (diff)
downloadserenity-9eb08bdb0f7460eb9874a5d16f6f3808f3d8a8f0.zip
Kernel: Make major and minor numbers to be DistinctNumerics
This helps avoid confusion in general, and make constructors, methods and code patterns much more clean and understandable.
Diffstat (limited to 'Kernel/Devices/DeviceManagement.cpp')
-rw-r--r--Kernel/Devices/DeviceManagement.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Kernel/Devices/DeviceManagement.cpp b/Kernel/Devices/DeviceManagement.cpp
index 1b0bd26a45..5f68d1cfb4 100644
--- a/Kernel/Devices/DeviceManagement.cpp
+++ b/Kernel/Devices/DeviceManagement.cpp
@@ -42,10 +42,10 @@ DeviceManagement& DeviceManagement::the()
return *s_the;
}
-Device* DeviceManagement::get_device(unsigned major, unsigned minor)
+Device* DeviceManagement::get_device(MajorNumber major, MinorNumber minor)
{
return m_devices.with_exclusive([&](auto& map) -> Device* {
- auto it = map.find(encoded_device(major, minor));
+ auto it = map.find(encoded_device(major.value(), minor.value()));
if (it == map.end())
return nullptr;
return it->value;
@@ -54,7 +54,7 @@ Device* DeviceManagement::get_device(unsigned major, unsigned minor)
void DeviceManagement::before_device_removal(Badge<Device>, Device& device)
{
- u32 device_id = encoded_device(device.major(), device.minor());
+ u64 device_id = encoded_device(device.major(), device.minor());
m_devices.with_exclusive([&](auto& map) -> void {
VERIFY(map.contains(device_id));
map.remove(encoded_device(device.major(), device.minor()));
@@ -63,7 +63,7 @@ void DeviceManagement::before_device_removal(Badge<Device>, Device& device)
void DeviceManagement::after_inserting_device(Badge<Device>, Device& device)
{
- u32 device_id = encoded_device(device.major(), device.minor());
+ u64 device_id = encoded_device(device.major(), device.minor());
m_devices.with_exclusive([&](auto& map) -> void {
if (map.contains(device_id)) {
dbgln("Already registered {},{}: {}", device.major(), device.minor(), device.class_name());