summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2023-04-11 03:41:49 +0300
committerLinus Groh <mail@linusgroh.de>2023-04-14 19:27:56 +0200
commit9f011592beefd19705682c7caa3595637efb659b (patch)
treefa67f34eb13a88c0d9f1752ef6351135e33680b1
parentb02ee664e7f62e19c48657034e779c53d11325a9 (diff)
downloadserenity-9f011592beefd19705682c7caa3595637efb659b.zip
Kernel/Net: Convert initializers to return NonnullRefPtr<NetworkAdapter>
There's no need for using NonnullLockRefPtr here.
-rw-r--r--Kernel/Net/Intel/E1000ENetworkAdapter.cpp4
-rw-r--r--Kernel/Net/Intel/E1000ENetworkAdapter.h2
-rw-r--r--Kernel/Net/Intel/E1000NetworkAdapter.cpp4
-rw-r--r--Kernel/Net/Intel/E1000NetworkAdapter.h2
-rw-r--r--Kernel/Net/NetworkingManagement.cpp6
-rw-r--r--Kernel/Net/NetworkingManagement.h2
-rw-r--r--Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp4
-rw-r--r--Kernel/Net/Realtek/RTL8168NetworkAdapter.h2
8 files changed, 13 insertions, 13 deletions
diff --git a/Kernel/Net/Intel/E1000ENetworkAdapter.cpp b/Kernel/Net/Intel/E1000ENetworkAdapter.cpp
index 1c5519fef6..3b42f759fe 100644
--- a/Kernel/Net/Intel/E1000ENetworkAdapter.cpp
+++ b/Kernel/Net/Intel/E1000ENetworkAdapter.cpp
@@ -188,7 +188,7 @@ UNMAP_AFTER_INIT ErrorOr<bool> E1000ENetworkAdapter::probe(PCI::DeviceIdentifier
return is_valid_device_id(pci_device_identifier.hardware_id().device_id);
}
-UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<NetworkAdapter>> E1000ENetworkAdapter::create(PCI::DeviceIdentifier const& pci_device_identifier)
+UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<NetworkAdapter>> E1000ENetworkAdapter::create(PCI::DeviceIdentifier const& pci_device_identifier)
{
u8 irq = pci_device_identifier.interrupt_line().value();
auto interface_name = TRY(NetworkingManagement::generate_interface_name_from_pci_address(pci_device_identifier));
@@ -199,7 +199,7 @@ UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<NetworkAdapter>> E1000ENetworkAdapter
auto rx_descriptors_region = TRY(MM.allocate_contiguous_kernel_region(TRY(Memory::page_round_up(sizeof(e1000_rx_desc) * number_of_rx_descriptors)), "E1000 RX Descriptors"sv, Memory::Region::Access::ReadWrite));
auto tx_descriptors_region = TRY(MM.allocate_contiguous_kernel_region(TRY(Memory::page_round_up(sizeof(e1000_tx_desc) * number_of_tx_descriptors)), "E1000 TX Descriptors"sv, Memory::Region::Access::ReadWrite));
- return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) E1000ENetworkAdapter(pci_device_identifier,
+ return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) E1000ENetworkAdapter(pci_device_identifier,
irq, move(registers_io_window),
move(rx_buffer_region),
move(tx_buffer_region),
diff --git a/Kernel/Net/Intel/E1000ENetworkAdapter.h b/Kernel/Net/Intel/E1000ENetworkAdapter.h
index 92586e06fe..eec3a3d4bd 100644
--- a/Kernel/Net/Intel/E1000ENetworkAdapter.h
+++ b/Kernel/Net/Intel/E1000ENetworkAdapter.h
@@ -21,7 +21,7 @@ class E1000ENetworkAdapter final
: public E1000NetworkAdapter {
public:
static ErrorOr<bool> probe(PCI::DeviceIdentifier const&);
- static ErrorOr<NonnullLockRefPtr<NetworkAdapter>> create(PCI::DeviceIdentifier const&);
+ static ErrorOr<NonnullRefPtr<NetworkAdapter>> create(PCI::DeviceIdentifier const&);
virtual ErrorOr<void> initialize(Badge<NetworkingManagement>) override;
virtual ~E1000ENetworkAdapter() override;
diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.cpp b/Kernel/Net/Intel/E1000NetworkAdapter.cpp
index af3c830942..547fab5b00 100644
--- a/Kernel/Net/Intel/E1000NetworkAdapter.cpp
+++ b/Kernel/Net/Intel/E1000NetworkAdapter.cpp
@@ -166,7 +166,7 @@ UNMAP_AFTER_INIT ErrorOr<bool> E1000NetworkAdapter::probe(PCI::DeviceIdentifier
return is_valid_device_id(pci_device_identifier.hardware_id().device_id);
}
-UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<NetworkAdapter>> E1000NetworkAdapter::create(PCI::DeviceIdentifier const& pci_device_identifier)
+UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<NetworkAdapter>> E1000NetworkAdapter::create(PCI::DeviceIdentifier const& pci_device_identifier)
{
u8 irq = pci_device_identifier.interrupt_line().value();
auto interface_name = TRY(NetworkingManagement::generate_interface_name_from_pci_address(pci_device_identifier));
@@ -177,7 +177,7 @@ UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<NetworkAdapter>> E1000NetworkAdapter:
auto rx_descriptors_region = TRY(MM.allocate_contiguous_kernel_region(TRY(Memory::page_round_up(sizeof(e1000_rx_desc) * number_of_rx_descriptors)), "E1000 RX Descriptors"sv, Memory::Region::Access::ReadWrite));
auto tx_descriptors_region = TRY(MM.allocate_contiguous_kernel_region(TRY(Memory::page_round_up(sizeof(e1000_tx_desc) * number_of_tx_descriptors)), "E1000 TX Descriptors"sv, Memory::Region::Access::ReadWrite));
- return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) E1000NetworkAdapter(pci_device_identifier,
+ return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) E1000NetworkAdapter(pci_device_identifier,
irq, move(registers_io_window),
move(rx_buffer_region),
move(tx_buffer_region),
diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.h b/Kernel/Net/Intel/E1000NetworkAdapter.h
index 50055d6d8c..47ed34b6c8 100644
--- a/Kernel/Net/Intel/E1000NetworkAdapter.h
+++ b/Kernel/Net/Intel/E1000NetworkAdapter.h
@@ -21,7 +21,7 @@ class E1000NetworkAdapter : public NetworkAdapter
, public IRQHandler {
public:
static ErrorOr<bool> probe(PCI::DeviceIdentifier const&);
- static ErrorOr<NonnullLockRefPtr<NetworkAdapter>> create(PCI::DeviceIdentifier const&);
+ static ErrorOr<NonnullRefPtr<NetworkAdapter>> create(PCI::DeviceIdentifier const&);
virtual ErrorOr<void> initialize(Badge<NetworkingManagement>) override;
virtual ~E1000NetworkAdapter() override;
diff --git a/Kernel/Net/NetworkingManagement.cpp b/Kernel/Net/NetworkingManagement.cpp
index 0a80587ecf..c2fb037088 100644
--- a/Kernel/Net/NetworkingManagement.cpp
+++ b/Kernel/Net/NetworkingManagement.cpp
@@ -93,7 +93,7 @@ ErrorOr<NonnullOwnPtr<KString>> NetworkingManagement::generate_interface_name_fr
struct PCINetworkDriverInitializer {
ErrorOr<bool> (*probe)(PCI::DeviceIdentifier const&) = nullptr;
- ErrorOr<NonnullLockRefPtr<NetworkAdapter>> (*create)(PCI::DeviceIdentifier const&) = nullptr;
+ ErrorOr<NonnullRefPtr<NetworkAdapter>> (*create)(PCI::DeviceIdentifier const&) = nullptr;
};
static constexpr PCINetworkDriverInitializer s_initializers[] = {
@@ -102,7 +102,7 @@ static constexpr PCINetworkDriverInitializer s_initializers[] = {
{ E1000ENetworkAdapter::probe, E1000ENetworkAdapter::create },
};
-UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<NetworkAdapter>> NetworkingManagement::determine_network_device(PCI::DeviceIdentifier const& device_identifier) const
+UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<NetworkAdapter>> NetworkingManagement::determine_network_device(PCI::DeviceIdentifier const& device_identifier) const
{
for (auto& initializer : s_initializers) {
auto initializer_probe_found_driver_match_or_error = initializer.probe(device_identifier);
@@ -133,7 +133,7 @@ bool NetworkingManagement::initialize()
dmesgln("Failed to initialize network adapter ({} {}): {}", device_identifier.address(), device_identifier.hardware_id(), result.error());
return;
}
- m_adapters.with([&](auto& adapters) { adapters.append(result.release_value()); });
+ m_adapters.with([&](auto& adapters) { adapters.append(*result.release_value()); });
}));
}
auto loopback = LoopbackAdapter::try_create();
diff --git a/Kernel/Net/NetworkingManagement.h b/Kernel/Net/NetworkingManagement.h
index 60ecc2c926..587773030a 100644
--- a/Kernel/Net/NetworkingManagement.h
+++ b/Kernel/Net/NetworkingManagement.h
@@ -39,7 +39,7 @@ public:
NonnullLockRefPtr<NetworkAdapter> loopback_adapter() const;
private:
- ErrorOr<NonnullLockRefPtr<NetworkAdapter>> determine_network_device(PCI::DeviceIdentifier const&) const;
+ ErrorOr<NonnullRefPtr<NetworkAdapter>> determine_network_device(PCI::DeviceIdentifier const&) const;
SpinlockProtected<Vector<NonnullLockRefPtr<NetworkAdapter>>, LockRank::None> m_adapters {};
LockRefPtr<NetworkAdapter> m_loopback_adapter;
diff --git a/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp b/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp
index 6020d26d3e..f7b96fa41f 100644
--- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp
+++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp
@@ -191,12 +191,12 @@ UNMAP_AFTER_INIT ErrorOr<bool> RTL8168NetworkAdapter::probe(PCI::DeviceIdentifie
return true;
}
-UNMAP_AFTER_INIT ErrorOr<NonnullLockRefPtr<NetworkAdapter>> RTL8168NetworkAdapter::create(PCI::DeviceIdentifier const& pci_device_identifier)
+UNMAP_AFTER_INIT ErrorOr<NonnullRefPtr<NetworkAdapter>> RTL8168NetworkAdapter::create(PCI::DeviceIdentifier const& pci_device_identifier)
{
u8 irq = pci_device_identifier.interrupt_line().value();
auto interface_name = TRY(NetworkingManagement::generate_interface_name_from_pci_address(pci_device_identifier));
auto registers_io_window = TRY(IOWindow::create_for_pci_device_bar(pci_device_identifier, PCI::HeaderType0BaseRegister::BAR0));
- return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) RTL8168NetworkAdapter(pci_device_identifier, irq, move(registers_io_window), move(interface_name))));
+ return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) RTL8168NetworkAdapter(pci_device_identifier, irq, move(registers_io_window), move(interface_name))));
}
bool RTL8168NetworkAdapter::determine_supported_version() const
diff --git a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h
index 09e39d0f0f..13172ddb34 100644
--- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.h
+++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.h
@@ -22,7 +22,7 @@ class RTL8168NetworkAdapter final : public NetworkAdapter
, public IRQHandler {
public:
static ErrorOr<bool> probe(PCI::DeviceIdentifier const&);
- static ErrorOr<NonnullLockRefPtr<NetworkAdapter>> create(PCI::DeviceIdentifier const&);
+ static ErrorOr<NonnullRefPtr<NetworkAdapter>> create(PCI::DeviceIdentifier const&);
virtual ErrorOr<void> initialize(Badge<NetworkingManagement>) override;
virtual ~RTL8168NetworkAdapter() override;