Kernel/USB: Add get_driver_by_name helper in USBManagement

This commit is contained in:
Jesse Buhagiar 2022-10-21 17:18:27 +11:00 committed by Andrew Kaster
parent 2aa17f619c
commit 3cfdc6e363
Notes: sideshowbarker 2024-07-16 17:12:03 +09:00
2 changed files with 7 additions and 0 deletions

View file

@ -81,6 +81,12 @@ void USBManagement::register_driver(NonnullLockRefPtr<Driver> driver)
m_available_drivers.append(driver);
}
LockRefPtr<Driver> USBManagement::get_driver_by_name(StringView name)
{
auto it = m_available_drivers.find_if([name](auto driver) { return driver->name() == name; });
return it.is_end() ? nullptr : LockRefPtr { *it };
}
void USBManagement::unregister_driver(NonnullLockRefPtr<Driver> driver)
{
dbgln_if(USB_DEBUG, "Unregistering driver {}", driver->name());

View file

@ -22,6 +22,7 @@ public:
static USBManagement& the();
void register_driver(NonnullLockRefPtr<Driver> driver);
LockRefPtr<Driver> get_driver_by_name(StringView name);
void unregister_driver(NonnullLockRefPtr<Driver> driver);
Vector<NonnullLockRefPtr<Driver>>& available_drivers() { return m_available_drivers; }