1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:18:12 +00:00

Kernel/PCI: Propagate usage of DeviceIdentifier everywhere

This allows us to remove a bunch of PCI API functions, and instead to
leverage the cached data from DeviceIdentifier object in many places.
This commit is contained in:
Liav A 2021-09-23 10:20:54 +03:00 committed by Andreas Kling
parent da327746a2
commit 057f5a12c2
40 changed files with 150 additions and 186 deletions

View file

@ -158,15 +158,14 @@ UNMAP_AFTER_INIT static bool is_valid_device_id(u16 device_id)
}
}
UNMAP_AFTER_INIT RefPtr<E1000NetworkAdapter> E1000NetworkAdapter::try_to_initialize(PCI::Address address)
UNMAP_AFTER_INIT RefPtr<E1000NetworkAdapter> E1000NetworkAdapter::try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier)
{
auto id = PCI::get_hardware_id(address);
if (id.vendor_id != PCI::VendorID::Intel)
if (pci_device_identifier.hardware_id().vendor_id != PCI::VendorID::Intel)
return {};
if (!is_valid_device_id(id.device_id))
if (!is_valid_device_id(pci_device_identifier.hardware_id().device_id))
return {};
u8 irq = PCI::get_interrupt_line(address);
auto adapter = adopt_ref_if_nonnull(new (nothrow) E1000NetworkAdapter(address, irq));
u8 irq = PCI::get_interrupt_line(pci_device_identifier.address());
auto adapter = adopt_ref_if_nonnull(new (nothrow) E1000NetworkAdapter(pci_device_identifier.address(), irq));
if (!adapter)
return {};
if (adapter->initialize())