summaryrefslogtreecommitdiff
path: root/Kernel/Bus/USB
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-09-23 10:50:45 +0300
committerAndreas Kling <kling@serenityos.org>2021-09-29 11:24:33 +0200
commita411a44fda3ba713e139331d4c29ea32f70c99d8 (patch)
tree8f17520fc4f614a622cd2a30b591db9beff61ae6 /Kernel/Bus/USB
parent057f5a12c2c69b1bad1d8b778d3cb934b3a8f346 (diff)
downloadserenity-a411a44fda3ba713e139331d4c29ea32f70c99d8.zip
Kernel/PCI: Cache interrupt line and interrupt pin of a device
This allows us to remove the PCI::get_interrupt_line API function. As a result, this removes a bunch of not so great patterns that we used to cache PCI interrupt line in many IRQHandler derived classes instead of just using interrupt_number method of IRQHandler class.
Diffstat (limited to 'Kernel/Bus/USB')
-rw-r--r--Kernel/Bus/USB/UHCI/UHCIController.cpp10
-rw-r--r--Kernel/Bus/USB/UHCI/UHCIController.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/Kernel/Bus/USB/UHCI/UHCIController.cpp b/Kernel/Bus/USB/UHCI/UHCIController.cpp
index 6aec8877ff..b64f4791d0 100644
--- a/Kernel/Bus/USB/UHCI/UHCIController.cpp
+++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp
@@ -65,7 +65,7 @@ static constexpr u16 UHCI_NUMBER_OF_FRAMES = 1024;
KResultOr<NonnullRefPtr<UHCIController>> UHCIController::try_to_initialize(PCI::DeviceIdentifier const& pci_device_identifier)
{
// NOTE: This assumes that address is pointing to a valid UHCI controller.
- auto controller = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) UHCIController(pci_device_identifier.address())));
+ auto controller = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) UHCIController(pci_device_identifier)));
TRY(controller->initialize());
return controller;
}
@@ -74,7 +74,7 @@ KResult UHCIController::initialize()
{
dmesgln("UHCI: Controller found {} @ {}", PCI::get_hardware_id(pci_address()), pci_address());
dmesgln("UHCI: I/O base {}", m_io_base);
- dmesgln("UHCI: Interrupt line: {}", PCI::get_interrupt_line(pci_address()));
+ dmesgln("UHCI: Interrupt line: {}", interrupt_number());
spawn_port_proc();
@@ -82,9 +82,9 @@ KResult UHCIController::initialize()
return start();
}
-UNMAP_AFTER_INIT UHCIController::UHCIController(PCI::Address address)
- : PCI::Device(address)
- , IRQHandler(PCI::get_interrupt_line(address))
+UNMAP_AFTER_INIT UHCIController::UHCIController(PCI::DeviceIdentifier const& pci_device_identifier)
+ : PCI::Device(pci_device_identifier.address())
+ , IRQHandler(pci_device_identifier.interrupt_line().value())
, m_io_base(PCI::get_BAR4(pci_address()) & ~1)
{
}
diff --git a/Kernel/Bus/USB/UHCI/UHCIController.h b/Kernel/Bus/USB/UHCI/UHCIController.h
index b3ede96c3c..b018c3025b 100644
--- a/Kernel/Bus/USB/UHCI/UHCIController.h
+++ b/Kernel/Bus/USB/UHCI/UHCIController.h
@@ -53,7 +53,7 @@ public:
KResult clear_port_feature(Badge<UHCIRootHub>, u8, HubFeatureSelector);
private:
- explicit UHCIController(PCI::Address);
+ explicit UHCIController(PCI::DeviceIdentifier const& pci_device_identifier);
u16 read_usbcmd() { return m_io_base.offset(0).in<u16>(); }
u16 read_usbsts() { return m_io_base.offset(0x2).in<u16>(); }