summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Fleytman <dfleytma@redhat.com>2016-06-29 16:57:26 +0300
committerDmitry Fleytman <dfleytma@redhat.com>2016-06-29 17:32:09 +0300
commitf01408384a55b3ec85fa97a956c20c86ca60e930 (patch)
treefda0f532c3e90d6ed340ac994f06033178fe9d58
parent0b7487ba56675427843642b90551c0afc9a6d077 (diff)
UsbDk: Simplify and refactor filter attachment codev1.00-13
This is a refactoring commit, no functional changes introduced. Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
-rw-r--r--UsbDk/FilterDevice.cpp27
-rw-r--r--UsbDk/FilterDevice.h7
2 files changed, 13 insertions, 21 deletions
diff --git a/UsbDk/FilterDevice.cpp b/UsbDk/FilterDevice.cpp
index 0c082e6..1457cb6 100644
--- a/UsbDk/FilterDevice.cpp
+++ b/UsbDk/FilterDevice.cpp
@@ -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()
+bool CUsbDkChildDevice::AttachToDeviceStack()
{
- m_Redirected = CreateRedirectorDevice();
- if (!m_Redirected)
+ auto DriverObj = m_ParentDevice.GetDriverObject();
+
+ auto Status = DriverObj->DriverExtension->AddDevice(DriverObj, m_PDO);
+ if (!NT_SUCCESS(Status))
{
- TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Failed to create redirector for child");
+ TraceEvents(TRACE_LEVEL_ERROR, TRACE_FILTERDEVICE, "%!FUNC! Failed to attach to device stack");
+ return false;
}
- return m_Redirected;
-}
-
-bool CUsbDkChildDevice::CreateRedirectorDevice()
-{
- auto DriverObj = m_ParentDevice.GetDriverObject();
- return NT_SUCCESS(DriverObj->DriverExtension->AddDevice(DriverObj, m_PDO));
+ return true;
}
NTSTATUS CUsbDkFilterDevice::AttachToStack(WDFDRIVER Driver)
diff --git a/UsbDk/FilterDevice.h b/UsbDk/FilterDevice.h
index 644f1b2..2ea93ef 100644
--- a/UsbDk/FilterDevice.h
+++ b/UsbDk/FilterDevice.h
@@ -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;