Kernel: Make PCI [Sub]ClassCode comparable to the corresponding ID enums

This commit is contained in:
Hendiadyoin1 2023-09-11 16:01:01 +02:00 committed by Andrew Kaster
parent 3273ef1e3f
commit 66647b58d4
Notes: sideshowbarker 2024-07-16 22:51:10 +09:00
5 changed files with 15 additions and 8 deletions

View File

@ -260,7 +260,14 @@ private:
};
AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, ClassCode);
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(ClassCode, ClassID)
AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, SubclassCode);
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, MassStorage::SubclassID);
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, Multimedia::SubclassID);
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, Bridge::SubclassID);
AK_MAKE_DISTINCT_NUMERIC_COMPARABLE_TO_ENUM(SubclassCode, Base::SubclassID);
AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, ProgrammingInterface);
AK_TYPEDEF_DISTINCT_ORDERED_ID(u8, RevisionID);
AK_TYPEDEF_DISTINCT_ORDERED_ID(u16, SubsystemID);

View File

@ -34,8 +34,8 @@ UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<AudioController>> AC97::create(PCI::Devic
UNMAP_AFTER_INIT ErrorOr<bool> AC97::probe(PCI::DeviceIdentifier const& device_identifier)
{
VERIFY(device_identifier.class_code().value() == to_underlying(PCI::ClassID::Multimedia));
return device_identifier.subclass_code().value() == to_underlying(PCI::Multimedia::SubclassID::AudioController);
VERIFY(device_identifier.class_code() == PCI::ClassID::Multimedia);
return device_identifier.subclass_code() == PCI::Multimedia::SubclassID::AudioController;
}
UNMAP_AFTER_INIT AC97::AC97(PCI::DeviceIdentifier const& pci_device_identifier, NonnullOwnPtr<AC97Channel> pcm_out_channel, NonnullOwnPtr<IOWindow> mixer_io_window, NonnullOwnPtr<IOWindow> bus_io_window)

View File

@ -19,8 +19,8 @@ namespace Kernel::Audio::IntelHDA {
UNMAP_AFTER_INIT ErrorOr<bool> Controller::probe(PCI::DeviceIdentifier const& device_identifier)
{
VERIFY(device_identifier.class_code().value() == to_underlying(PCI::ClassID::Multimedia));
return device_identifier.subclass_code().value() == to_underlying(PCI::Multimedia::SubclassID::HDACompatibleController);
VERIFY(device_identifier.class_code() == PCI::ClassID::Multimedia);
return device_identifier.subclass_code() == PCI::Multimedia::SubclassID::HDACompatibleController;
}
UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<AudioController>> Controller::create(PCI::DeviceIdentifier const& pci_device_identifier)

View File

@ -71,7 +71,7 @@ UNMAP_AFTER_INIT void AudioManagement::enumerate_hardware_controllers()
return;
MUST(PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
// Only consider PCI multimedia devices
if (device_identifier.class_code().value() != to_underlying(PCI::ClassID::Multimedia))
if (device_identifier.class_code() != PCI::ClassID::Multimedia)
return;
auto result = determine_audio_device(device_identifier);

View File

@ -152,10 +152,10 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_pci_controllers(bool force_pi
};
MUST(PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) -> void {
auto class_code = device_identifier.class_code().value();
if (class_code == to_underlying(PCI::ClassID::MassStorage)) {
auto class_code = device_identifier.class_code();
if (class_code == PCI::ClassID::MassStorage) {
handle_mass_storage_device(device_identifier);
} else if (class_code == to_underlying(PCI::ClassID::Base)) {
} else if (class_code == PCI::ClassID::Base) {
handle_base_device(device_identifier);
}
}));