diff options
Diffstat (limited to 'Kernel/Bus/USB')
-rw-r--r-- | Kernel/Bus/USB/SysFSUSB.cpp | 10 | ||||
-rw-r--r-- | Kernel/Bus/USB/SysFSUSB.h | 6 |
2 files changed, 11 insertions, 5 deletions
diff --git a/Kernel/Bus/USB/SysFSUSB.cpp b/Kernel/Bus/USB/SysFSUSB.cpp index 67c8995744..e4fc0a67ef 100644 --- a/Kernel/Bus/USB/SysFSUSB.cpp +++ b/Kernel/Bus/USB/SysFSUSB.cpp @@ -13,9 +13,10 @@ namespace Kernel::USB { static SysFSUSBBusDirectory* s_procfs_usb_bus_directory; -SysFSUSBDeviceInformation::SysFSUSBDeviceInformation(USB::Device& device) - : SysFSComponent(String::number(device.address())) +SysFSUSBDeviceInformation::SysFSUSBDeviceInformation(NonnullOwnPtr<KString> device_name, USB::Device& device) + : SysFSComponent() , m_device(device) + , m_device_name(move(device_name)) { } @@ -150,7 +151,7 @@ SysFSUSBBusDirectory& SysFSUSBBusDirectory::the() } UNMAP_AFTER_INIT SysFSUSBBusDirectory::SysFSUSBBusDirectory(SysFSBusDirectory& buses_directory) - : SysFSDirectory("usb"sv, buses_directory) + : SysFSDirectory(buses_directory) { } @@ -163,7 +164,8 @@ UNMAP_AFTER_INIT void SysFSUSBBusDirectory::initialize() NonnullRefPtr<SysFSUSBDeviceInformation> SysFSUSBDeviceInformation::create(USB::Device& device) { - return adopt_ref(*new SysFSUSBDeviceInformation(device)); + auto device_name = KString::must_create(String::number(device.address())); + return adopt_ref(*new SysFSUSBDeviceInformation(move(device_name), device)); } } diff --git a/Kernel/Bus/USB/SysFSUSB.h b/Kernel/Bus/USB/SysFSUSB.h index 066254dcc9..87a5b8857e 100644 --- a/Kernel/Bus/USB/SysFSUSB.h +++ b/Kernel/Bus/USB/SysFSUSB.h @@ -20,11 +20,12 @@ public: virtual ~SysFSUSBDeviceInformation() override; static NonnullRefPtr<SysFSUSBDeviceInformation> create(USB::Device&); + virtual StringView name() const override { return m_device_name->view(); } RefPtr<USB::Device> device() const { return m_device; } protected: - explicit SysFSUSBDeviceInformation(USB::Device& device); + SysFSUSBDeviceInformation(NonnullOwnPtr<KString> device_name, USB::Device& device); virtual ErrorOr<size_t> read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; @@ -36,6 +37,7 @@ private: ErrorOr<void> try_generate(KBufferBuilder&); virtual ErrorOr<void> refresh_data(OpenFileDescription& description) const override; mutable Mutex m_lock { "SysFSUSBDeviceInformation" }; + NonnullOwnPtr<KString> m_device_name; }; class SysFSUSBBusDirectory final : public SysFSDirectory { @@ -43,6 +45,8 @@ public: static void initialize(); static SysFSUSBBusDirectory& the(); + virtual StringView name() const override { return "usb"sv; } + void plug(USB::Device&); void unplug(USB::Device&); |