Skip to content

Commit 15315be

Browse files
supercomputer7awesomekling
authored andcommitted
Kernel/Audio: Don't try to enumerate PCI adapters if PCI is disabled
1 parent 71de4f7 commit 15315be

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

Kernel/Devices/Audio/Management.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,23 @@ UNMAP_AFTER_INIT AudioManagement::AudioManagement()
3838

3939
UNMAP_AFTER_INIT void AudioManagement::enumerate_hardware_controllers()
4040
{
41-
PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
42-
// Note: Only consider PCI audio controllers
43-
if (device_identifier.class_code().value() != to_underlying(PCI::ClassID::Multimedia)
44-
|| device_identifier.subclass_code().value() != to_underlying(PCI::Multimedia::SubclassID::AudioController))
45-
return;
41+
if (!PCI::Access::is_disabled()) {
42+
PCI::enumerate([&](PCI::DeviceIdentifier const& device_identifier) {
43+
// Note: Only consider PCI audio controllers
44+
if (device_identifier.class_code().value() != to_underlying(PCI::ClassID::Multimedia)
45+
|| device_identifier.subclass_code().value() != to_underlying(PCI::Multimedia::SubclassID::AudioController))
46+
return;
4647

47-
dbgln("AC97: found audio controller at {}", device_identifier.address());
48-
auto ac97_device = AC97::try_create(device_identifier);
49-
if (ac97_device.is_error()) {
50-
// FIXME: Propagate errors properly
51-
dbgln("AudioManagement: failed to initialize AC97 device: {}", ac97_device.error());
52-
return;
53-
}
54-
m_controllers_list.append(ac97_device.release_value());
55-
});
48+
dbgln("AC97: found audio controller at {}", device_identifier.address());
49+
auto ac97_device = AC97::try_create(device_identifier);
50+
if (ac97_device.is_error()) {
51+
// FIXME: Propagate errors properly
52+
dbgln("AudioManagement: failed to initialize AC97 device: {}", ac97_device.error());
53+
return;
54+
}
55+
m_controllers_list.append(ac97_device.release_value());
56+
});
57+
}
5658
}
5759

5860
UNMAP_AFTER_INIT void AudioManagement::enumerate_hardware_audio_channels()

0 commit comments

Comments
 (0)