mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:17:45 +00:00
Kernel: Get rid of *LockRefPtr in the SysFS filesystem code
To do this we also need to get rid of LockRefPtrs in the USB code as well. Most of the SysFS nodes are statically generated during boot and are not mutated afterwards. The same goes for general device code - once we generate the appropriate SysFS nodes, we almost never mutate the node pointers afterwards, making locking unnecessary.
This commit is contained in:
parent
dd7633c5f4
commit
b02ee664e7
114 changed files with 230 additions and 218 deletions
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
|
||||
UNMAP_AFTER_INIT void PCIBusSysFSDirectory::initialize()
|
||||
{
|
||||
auto pci_directory = adopt_lock_ref(*new (nothrow) PCIBusSysFSDirectory());
|
||||
auto pci_directory = adopt_ref(*new (nothrow) PCIBusSysFSDirectory());
|
||||
SysFSComponentRegistry::the().register_new_bus_directory(pci_directory);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ StringView PCIDeviceAttributeSysFSComponent::name() const
|
|||
}
|
||||
}
|
||||
|
||||
NonnullLockRefPtr<PCIDeviceAttributeSysFSComponent> PCIDeviceAttributeSysFSComponent::create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
NonnullRefPtr<PCIDeviceAttributeSysFSComponent> PCIDeviceAttributeSysFSComponent::create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
{
|
||||
return adopt_lock_ref(*new (nothrow) PCIDeviceAttributeSysFSComponent(device, offset, field_bytes_width));
|
||||
return adopt_ref(*new (nothrow) PCIDeviceAttributeSysFSComponent(device, offset, field_bytes_width));
|
||||
}
|
||||
|
||||
PCIDeviceAttributeSysFSComponent::PCIDeviceAttributeSysFSComponent(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
|
||||
class PCIDeviceAttributeSysFSComponent : public SysFSComponent {
|
||||
public:
|
||||
static NonnullLockRefPtr<PCIDeviceAttributeSysFSComponent> create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
static NonnullRefPtr<PCIDeviceAttributeSysFSComponent> create(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
virtual ~PCIDeviceAttributeSysFSComponent() {};
|
||||
|
@ -25,7 +25,7 @@ public:
|
|||
protected:
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer() const;
|
||||
PCIDeviceAttributeSysFSComponent(PCIDeviceSysFSDirectory const& device, PCI::RegisterOffset offset, size_t field_bytes_width);
|
||||
NonnullLockRefPtr<PCIDeviceSysFSDirectory> m_device;
|
||||
NonnullRefPtr<PCIDeviceSysFSDirectory> m_device;
|
||||
PCI::RegisterOffset m_offset;
|
||||
size_t m_field_bytes_width;
|
||||
};
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
UNMAP_AFTER_INIT NonnullLockRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(SysFSDirectory const& parent_directory, PCI::DeviceIdentifier const& device_identifier)
|
||||
UNMAP_AFTER_INIT NonnullRefPtr<PCIDeviceSysFSDirectory> PCIDeviceSysFSDirectory::create(SysFSDirectory const& parent_directory, PCI::DeviceIdentifier const& device_identifier)
|
||||
{
|
||||
// FIXME: Handle allocation failure gracefully
|
||||
auto& address = device_identifier.address();
|
||||
auto device_name = MUST(KString::formatted("{:04x}:{:02x}:{:02x}.{}", address.domain(), address.bus(), address.device(), address.function()));
|
||||
auto directory = adopt_lock_ref(*new (nothrow) PCIDeviceSysFSDirectory(move(device_name), parent_directory, device_identifier));
|
||||
auto directory = adopt_ref(*new (nothrow) PCIDeviceSysFSDirectory(move(device_name), parent_directory, device_identifier));
|
||||
MUST(directory->m_child_components.with([&](auto& list) -> ErrorOr<void> {
|
||||
list.append(PCIDeviceAttributeSysFSComponent::create(*directory, PCI::RegisterOffset::VENDOR_ID, 2));
|
||||
list.append(PCIDeviceAttributeSysFSComponent::create(*directory, PCI::RegisterOffset::DEVICE_ID, 2));
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
|
||||
class PCIDeviceSysFSDirectory final : public SysFSDirectory {
|
||||
public:
|
||||
static NonnullLockRefPtr<PCIDeviceSysFSDirectory> create(SysFSDirectory const&, PCI::DeviceIdentifier const&);
|
||||
static NonnullRefPtr<PCIDeviceSysFSDirectory> create(SysFSDirectory const&, PCI::DeviceIdentifier const&);
|
||||
PCI::DeviceIdentifier const& device_identifier() const { return *m_device_identifier; }
|
||||
|
||||
virtual StringView name() const override { return m_device_directory_name->view(); }
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullLockRefPtr<PCIDeviceExpansionROMSysFSComponent> PCIDeviceExpansionROMSysFSComponent::create(PCIDeviceSysFSDirectory const& device)
|
||||
NonnullRefPtr<PCIDeviceExpansionROMSysFSComponent> PCIDeviceExpansionROMSysFSComponent::create(PCIDeviceSysFSDirectory const& device)
|
||||
{
|
||||
auto option_rom_size = PCI::get_expansion_rom_space_size(device.device_identifier());
|
||||
return adopt_lock_ref(*new (nothrow) PCIDeviceExpansionROMSysFSComponent(device, option_rom_size));
|
||||
return adopt_ref(*new (nothrow) PCIDeviceExpansionROMSysFSComponent(device, option_rom_size));
|
||||
}
|
||||
|
||||
PCIDeviceExpansionROMSysFSComponent::PCIDeviceExpansionROMSysFSComponent(PCIDeviceSysFSDirectory const& device, size_t option_rom_size)
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Kernel {
|
|||
|
||||
class PCIDeviceExpansionROMSysFSComponent : public SysFSComponent {
|
||||
public:
|
||||
static NonnullLockRefPtr<PCIDeviceExpansionROMSysFSComponent> create(PCIDeviceSysFSDirectory const& device);
|
||||
static NonnullRefPtr<PCIDeviceExpansionROMSysFSComponent> create(PCIDeviceSysFSDirectory const& device);
|
||||
|
||||
virtual ErrorOr<size_t> read_bytes(off_t, size_t, UserOrKernelBuffer&, OpenFileDescription*) const override;
|
||||
virtual ~PCIDeviceExpansionROMSysFSComponent() {};
|
||||
|
@ -25,7 +25,7 @@ public:
|
|||
protected:
|
||||
ErrorOr<NonnullOwnPtr<KBuffer>> try_to_generate_buffer(size_t offset_in_rom, size_t count) const;
|
||||
PCIDeviceExpansionROMSysFSComponent(PCIDeviceSysFSDirectory const& device, size_t option_rom_size);
|
||||
NonnullLockRefPtr<PCIDeviceSysFSDirectory> m_device;
|
||||
NonnullRefPtr<PCIDeviceSysFSDirectory> m_device;
|
||||
size_t const m_option_rom_size { 0 };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue