mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
Kernel: Remove unused IterationDecision in enumerate_attached_devices
This commit is contained in:
parent
e350d3b2c6
commit
95aff1cf13
3 changed files with 14 additions and 22 deletions
|
@ -132,15 +132,13 @@ ErrorOr<void> Access::add_host_controller_and_scan_for_devices(NonnullOwnPtr<Hos
|
|||
// Note: We need to register the new controller as soon as possible, and
|
||||
// definitely before enumerating devices behind that.
|
||||
m_host_controllers.set(domain_number, move(controller));
|
||||
ErrorOr<void> error_or_void {};
|
||||
m_host_controllers.get(domain_number).value()->enumerate_attached_devices([&](EnumerableDeviceIdentifier const& device_identifier) -> IterationDecision {
|
||||
m_host_controllers.get(domain_number).value()->enumerate_attached_devices([&](EnumerableDeviceIdentifier const& device_identifier) {
|
||||
auto device_identifier_or_error = DeviceIdentifier::from_enumerable_identifier(device_identifier);
|
||||
if (device_identifier_or_error.is_error()) {
|
||||
error_or_void = device_identifier_or_error.release_error();
|
||||
return IterationDecision::Break;
|
||||
dmesgln("Failed during PCI Access::rescan_hardware due to {}", device_identifier_or_error.error());
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
m_device_identifiers.append(device_identifier_or_error.release_value());
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
return {};
|
||||
}
|
||||
|
@ -161,22 +159,16 @@ UNMAP_AFTER_INIT void Access::rescan_hardware()
|
|||
SpinlockLocker locker(m_access_lock);
|
||||
SpinlockLocker scan_locker(m_scan_lock);
|
||||
VERIFY(m_device_identifiers.is_empty());
|
||||
ErrorOr<void> error_or_void {};
|
||||
for (auto& [_, host_controller] : m_host_controllers) {
|
||||
host_controller->enumerate_attached_devices([this, &error_or_void](EnumerableDeviceIdentifier device_identifier) -> IterationDecision {
|
||||
host_controller->enumerate_attached_devices([this](EnumerableDeviceIdentifier device_identifier) {
|
||||
auto device_identifier_or_error = DeviceIdentifier::from_enumerable_identifier(device_identifier);
|
||||
if (device_identifier_or_error.is_error()) {
|
||||
error_or_void = device_identifier_or_error.release_error();
|
||||
return IterationDecision::Break;
|
||||
dmesgln("Failed during PCI Access::rescan_hardware due to {}", device_identifier_or_error.error());
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
m_device_identifiers.append(device_identifier_or_error.release_value());
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
if (error_or_void.is_error()) {
|
||||
dmesgln("Failed during PCI Access::rescan_hardware due to {}", error_or_void.error());
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> Access::fast_enumerate(Function<void(DeviceIdentifier const&)>& callback) const
|
||||
|
|
|
@ -54,7 +54,7 @@ u16 HostController::read16_field(BusNumber bus, DeviceNumber device, FunctionNum
|
|||
return read16_field(bus, device, function, to_underlying(field));
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void HostController::enumerate_functions(Function<IterationDecision(EnumerableDeviceIdentifier)> const& callback, BusNumber bus, DeviceNumber device, FunctionNumber function, bool recursive_search_into_bridges)
|
||||
UNMAP_AFTER_INIT void HostController::enumerate_functions(Function<void(EnumerableDeviceIdentifier)> const& callback, BusNumber bus, DeviceNumber device, FunctionNumber function, bool recursive_search_into_bridges)
|
||||
{
|
||||
dbgln_if(PCI_DEBUG, "PCI: Enumerating function, bus={}, device={}, function={}", bus, device, function);
|
||||
Address address(domain_number(), bus.value(), device.value(), function.value());
|
||||
|
@ -83,7 +83,7 @@ UNMAP_AFTER_INIT void HostController::enumerate_functions(Function<IterationDeci
|
|||
}
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void HostController::enumerate_device(Function<IterationDecision(EnumerableDeviceIdentifier)> const& callback, BusNumber bus, DeviceNumber device, bool recursive_search_into_bridges)
|
||||
UNMAP_AFTER_INIT void HostController::enumerate_device(Function<void(EnumerableDeviceIdentifier)> const& callback, BusNumber bus, DeviceNumber device, bool recursive_search_into_bridges)
|
||||
{
|
||||
dbgln_if(PCI_DEBUG, "PCI: Enumerating device in bus={}, device={}", bus, device);
|
||||
if (read16_field(bus, device, 0, PCI::RegisterOffset::VENDOR_ID) == PCI::none_value)
|
||||
|
@ -97,14 +97,14 @@ UNMAP_AFTER_INIT void HostController::enumerate_device(Function<IterationDecisio
|
|||
}
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void HostController::enumerate_bus(Function<IterationDecision(EnumerableDeviceIdentifier)> const& callback, BusNumber bus, bool recursive_search_into_bridges)
|
||||
UNMAP_AFTER_INIT void HostController::enumerate_bus(Function<void(EnumerableDeviceIdentifier)> const& callback, BusNumber bus, bool recursive_search_into_bridges)
|
||||
{
|
||||
dbgln_if(PCI_DEBUG, "PCI: Enumerating bus {}", bus);
|
||||
for (u8 device = 0; device < 32; ++device)
|
||||
enumerate_device(callback, bus, device, recursive_search_into_bridges);
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void HostController::enumerate_attached_devices(Function<IterationDecision(EnumerableDeviceIdentifier)> callback)
|
||||
UNMAP_AFTER_INIT void HostController::enumerate_attached_devices(Function<void(EnumerableDeviceIdentifier)> callback)
|
||||
{
|
||||
VERIFY(Access::the().access_lock().is_locked());
|
||||
VERIFY(Access::the().scan_lock().is_locked());
|
||||
|
|
|
@ -31,12 +31,12 @@ public:
|
|||
|
||||
u32 domain_number() const { return m_domain.domain_number(); }
|
||||
|
||||
void enumerate_attached_devices(Function<IterationDecision(EnumerableDeviceIdentifier)> callback);
|
||||
void enumerate_attached_devices(Function<void(EnumerableDeviceIdentifier)> callback);
|
||||
|
||||
private:
|
||||
void enumerate_bus(Function<IterationDecision(EnumerableDeviceIdentifier)> const& callback, BusNumber, bool recursive);
|
||||
void enumerate_functions(Function<IterationDecision(EnumerableDeviceIdentifier)> const& callback, BusNumber, DeviceNumber, FunctionNumber, bool recursive);
|
||||
void enumerate_device(Function<IterationDecision(EnumerableDeviceIdentifier)> const& callback, BusNumber bus, DeviceNumber device, bool recursive);
|
||||
void enumerate_bus(Function<void(EnumerableDeviceIdentifier)> const& callback, BusNumber, bool recursive);
|
||||
void enumerate_functions(Function<void(EnumerableDeviceIdentifier)> const& callback, BusNumber, DeviceNumber, FunctionNumber, bool recursive);
|
||||
void enumerate_device(Function<void(EnumerableDeviceIdentifier)> const& callback, BusNumber bus, DeviceNumber device, bool recursive);
|
||||
|
||||
u8 read8_field(BusNumber, DeviceNumber, FunctionNumber, RegisterOffset field);
|
||||
u16 read16_field(BusNumber, DeviceNumber, FunctionNumber, RegisterOffset field);
|
||||
|
|
Loading…
Reference in a new issue