mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel/USB: Add get_driver_by_name
helper in USBManagement
This commit is contained in:
parent
2aa17f619c
commit
3cfdc6e363
Notes:
sideshowbarker
2024-07-16 17:12:03 +09:00
Author: https://github.com/Quaker762 🔰 Commit: https://github.com/SerenityOS/serenity/commit/3cfdc6e363 Pull-request: https://github.com/SerenityOS/serenity/pull/21090 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/BertalanD Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/kleinesfilmroellchen ✅ Reviewed-by: https://github.com/supercomputer7 ✅
2 changed files with 7 additions and 0 deletions
|
@ -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());
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue