1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:58:11 +00:00

Kernel/USB: Detach devices from their driver when they are detached

This commit is contained in:
Hendiadyoin1 2023-09-15 19:13:44 +02:00 committed by Andrew Kaster
parent b4cd354bae
commit d168bfabc4
3 changed files with 15 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include <AK/OwnPtr.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <Kernel/Bus/USB/Drivers/USBDriver.h>
#include <Kernel/Bus/USB/USBConfiguration.h>
#include <Kernel/Bus/USB/USBPipe.h>
#include <Kernel/Locking/SpinlockProtected.h>
@ -58,6 +59,14 @@ public:
Vector<USBConfiguration> const& configurations() const { return m_configurations; }
void set_driver(Driver& driver) { m_driver = driver; }
void detach()
{
if (m_driver)
m_driver->detach(*this);
m_driver = nullptr;
}
SpinlockProtected<RefPtr<SysFSUSBDeviceInformation>, LockRank::None>& sysfs_device_info_node(Badge<USB::Hub>) { return m_sysfs_device_info_node; }
protected:
@ -76,6 +85,8 @@ protected:
NonnullLockRefPtr<USBController> m_controller;
NonnullOwnPtr<ControlPipe> m_default_pipe; // Default communication pipe (endpoint0) used during enumeration
LockRefPtr<Driver> m_driver;
private:
IntrusiveListNode<Device, NonnullLockRefPtr<Device>> m_hub_child_node;