UsbDk: Simplify and refactor filter attachment code
This is a refactoring commit, no functional changes introduced. Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit is contained in:
parent
0b7487ba56
commit
f01408384a
2 changed files with 15 additions and 23 deletions
|
|
@ -412,19 +412,19 @@ void CUsbDkHubFilterStrategy::ApplyRedirectionPolicy(CUsbDkChildDevice &Device)
|
|||
if (m_ControlDevice->ShouldRedirect(Device) ||
|
||||
m_ControlDevice->ShouldHide(Device.DeviceDescriptor()))
|
||||
{
|
||||
if (Device.MakeRedirected())
|
||||
if (Device.AttachToDeviceStack())
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Adding new PDO 0x%p as redirected initially", Device.PDO());
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Attached to device stack for 0x%p", Device.PDO());
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Failed to create redirector PDO for 0x%p", Device.PDO());
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Failed to attach to device stack for 0x%p", Device.PDO());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ControlDevice->NotifyRedirectionRemoved(Device);
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Adding new PDO 0x%p as non-redirected initially", Device.PDO());
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_FILTERDEVICE, "%!FUNC! Not attaching to device stack for 0x%p", Device.PDO());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -433,21 +433,18 @@ ULONG CUsbDkChildDevice::ParentID() const
|
|||
return m_ParentDevice.GetInstanceNumber();
|
||||
}
|
||||
|
||||
bool CUsbDkChildDevice::MakeRedirected()
|
||||
{
|
||||
m_Redirected = CreateRedirectorDevice();
|
||||
if (!m_Redirected)
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Failed to create redirector for child");
|
||||
}
|
||||
|
||||
return m_Redirected;
|
||||
}
|
||||
|
||||
bool CUsbDkChildDevice::CreateRedirectorDevice()
|
||||
bool CUsbDkChildDevice::AttachToDeviceStack()
|
||||
{
|
||||
auto DriverObj = m_ParentDevice.GetDriverObject();
|
||||
return NT_SUCCESS(DriverObj->DriverExtension->AddDevice(DriverObj, m_PDO));
|
||||
|
||||
auto Status = DriverObj->DriverExtension->AddDevice(DriverObj, m_PDO);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Failed to attach to device stack");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NTSTATUS CUsbDkFilterDevice::AttachToStack(WDFDRIVER Driver)
|
||||
|
|
|
|||
|
|
@ -76,8 +76,6 @@ public:
|
|||
{ return m_Speed; }
|
||||
const USB_DEVICE_DESCRIPTOR &DeviceDescriptor() const
|
||||
{ return m_DevDescriptor; }
|
||||
bool IsRedirected() const
|
||||
{ return m_Redirected; }
|
||||
PDEVICE_OBJECT PDO() const { return m_PDO; }
|
||||
|
||||
bool ConfigurationDescriptor(UCHAR Index, USB_CONFIGURATION_DESCRIPTOR &Buffer, size_t BufferLength)
|
||||
|
|
@ -96,7 +94,7 @@ public:
|
|||
bool Match(PDEVICE_OBJECT PDO) const
|
||||
{ return m_PDO == PDO; }
|
||||
|
||||
bool MakeRedirected();
|
||||
bool AttachToDeviceStack();
|
||||
|
||||
void Dump();
|
||||
|
||||
|
|
@ -109,9 +107,6 @@ private:
|
|||
TDescriptorsCache m_CfgDescriptors;
|
||||
PDEVICE_OBJECT m_PDO;
|
||||
const CUsbDkFilterDevice &m_ParentDevice;
|
||||
bool m_Redirected = false;
|
||||
|
||||
bool CreateRedirectorDevice();
|
||||
|
||||
CUsbDkChildDevice(const CUsbDkChildDevice&) = delete;
|
||||
CUsbDkChildDevice& operator= (const CUsbDkChildDevice&) = delete;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue