https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9c7c2deff9fc44010b922…
commit 9c7c2deff9fc44010b9223dfde19ce37b31afb68
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sat Feb 23 21:50:05 2019 +0100
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Tue Feb 26 09:20:37 2019 +0100
[HDAUDBUS] Split FDO/PDO PNP handling into separate functions.
---
drivers/wdm/audio/hdaudbus/hdaudbus.cpp | 225 ++++++++++++++++++--------------
1 file changed, 127 insertions(+), 98 deletions(-)
diff --git a/drivers/wdm/audio/hdaudbus/hdaudbus.cpp
b/drivers/wdm/audio/hdaudbus/hdaudbus.cpp
index bacc854ab1..350ec71231 100644
--- a/drivers/wdm/audio/hdaudbus/hdaudbus.cpp
+++ b/drivers/wdm/audio/hdaudbus/hdaudbus.cpp
@@ -86,125 +86,133 @@ HDA_SyncForwardIrp(
}
NTSTATUS
-NTAPI
-HDA_Pnp(
+HDA_FdoPnp(
_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp)
{
- NTSTATUS Status = STATUS_NOT_SUPPORTED;
+ NTSTATUS Status;
PIO_STACK_LOCATION IoStack;
- PDEVICE_RELATIONS DeviceRelation;
PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
- //PHDA_PDO_DEVICE_EXTENSION ChildDeviceExtension;
-
- FDODeviceExtension = (PHDA_FDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- //ChildDeviceExtension =
(PHDA_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+ FDODeviceExtension =
static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
IoStack = IoGetCurrentIrpStackLocation(Irp);
- if (FDODeviceExtension->IsFDO)
+
+ if (IoStack->MinorFunction == IRP_MN_START_DEVICE)
{
- if (IoStack->MinorFunction == IRP_MN_START_DEVICE)
+ Status = HDA_FDOStartDevice(DeviceObject, Irp);
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_DEVICE_RELATIONS)
+ {
+ /* handle bus device relations */
+ if (IoStack->Parameters.QueryDeviceRelations.Type == BusRelations)
{
- Status = HDA_FDOStartDevice(DeviceObject, Irp);
+ Status = HDA_FDOQueryBusRelations(DeviceObject, Irp);
}
- else if (IoStack->MinorFunction == IRP_MN_QUERY_DEVICE_RELATIONS)
- {
- /* handle bus device relations */
- if (IoStack->Parameters.QueryDeviceRelations.Type == BusRelations)
- {
- Status = HDA_FDOQueryBusRelations(DeviceObject, Irp);
- }
- else
- {
- Status = Irp->IoStatus.Status;
- }
- }
else
{
- /* get default status */
Status = Irp->IoStatus.Status;
}
}
else
{
- if (IoStack->MinorFunction == IRP_MN_START_DEVICE)
- {
- /* no op for pdo */
- Status = STATUS_SUCCESS;
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_BUS_INFORMATION)
- {
- /* query bus information */
- Status = HDA_PDOQueryBusInformation(Irp);
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_PNP_DEVICE_STATE)
- {
- /* query pnp state */
- Status = HDA_PDOQueryBusDevicePnpState(Irp);
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_DEVICE_RELATIONS)
+ /* get default status */
+ Status = Irp->IoStatus.Status;
+ }
+
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return Status;
+}
+
+NTSTATUS
+HDA_PdoPnp(
+ _In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ NTSTATUS Status;
+ PIO_STACK_LOCATION IoStack;
+ PDEVICE_RELATIONS DeviceRelation;
+
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ if (IoStack->MinorFunction == IRP_MN_START_DEVICE)
+ {
+ /* no op for pdo */
+ Status = STATUS_SUCCESS;
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_BUS_INFORMATION)
+ {
+ /* query bus information */
+ Status = HDA_PDOQueryBusInformation(Irp);
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_PNP_DEVICE_STATE)
+ {
+ /* query pnp state */
+ Status = HDA_PDOQueryBusDevicePnpState(Irp);
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_DEVICE_RELATIONS)
+ {
+ if (IoStack->Parameters.QueryDeviceRelations.Type == TargetDeviceRelation)
{
- if (IoStack->Parameters.QueryDeviceRelations.Type ==
TargetDeviceRelation)
+ /* handle target device relations */
+ ASSERT(IoStack->Parameters.QueryDeviceRelations.Type ==
TargetDeviceRelation);
+ ASSERT(Irp->IoStatus.Information == 0);
+
+ /* allocate device relation */
+ DeviceRelation = (PDEVICE_RELATIONS)AllocateItem(PagedPool,
sizeof(DEVICE_RELATIONS));
+ if (DeviceRelation)
{
- /* handle target device relations */
- ASSERT(IoStack->Parameters.QueryDeviceRelations.Type ==
TargetDeviceRelation);
- ASSERT(Irp->IoStatus.Information == 0);
-
- /* allocate device relation */
- DeviceRelation = (PDEVICE_RELATIONS)AllocateItem(PagedPool,
sizeof(DEVICE_RELATIONS));
- if (DeviceRelation)
- {
- DeviceRelation->Count = 1;
- DeviceRelation->Objects[0] = DeviceObject;
-
- /* reference self */
- ObReferenceObject(DeviceObject);
-
- /* store result */
- Irp->IoStatus.Information = (ULONG_PTR)DeviceRelation;
-
- /* done */
- Status = STATUS_SUCCESS;
- }
- else
- {
- /* no memory */
- Status = STATUS_INSUFFICIENT_RESOURCES;
- }
+ DeviceRelation->Count = 1;
+ DeviceRelation->Objects[0] = DeviceObject;
+
+ /* reference self */
+ ObReferenceObject(DeviceObject);
+
+ /* store result */
+ Irp->IoStatus.Information = (ULONG_PTR)DeviceRelation;
+
+ /* done */
+ Status = STATUS_SUCCESS;
+ }
+ else
+ {
+ /* no memory */
+ Status = STATUS_INSUFFICIENT_RESOURCES;
}
}
- else if (IoStack->MinorFunction == IRP_MN_QUERY_CAPABILITIES)
- {
- /* query capabilities */
- Status = HDA_PDOQueryBusDeviceCapabilities(Irp);
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_RESOURCE_REQUIREMENTS)
- {
- /* no op */
- Status = STATUS_SUCCESS;
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_RESOURCES)
- {
- /* no op */
- Status = STATUS_SUCCESS;
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_ID)
- {
- Status = HDA_PDOQueryId(DeviceObject, Irp);
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_DEVICE_TEXT)
- {
- Status = HDA_PDOHandleQueryDeviceText(Irp);
- }
- else if (IoStack->MinorFunction == IRP_MN_QUERY_INTERFACE)
- {
- Status = HDA_PDOHandleQueryInterface(DeviceObject, Irp);
- }
- else
- {
- /* get default status */
- Status = Irp->IoStatus.Status;
- }
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_CAPABILITIES)
+ {
+ /* query capabilities */
+ Status = HDA_PDOQueryBusDeviceCapabilities(Irp);
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_RESOURCE_REQUIREMENTS)
+ {
+ /* no op */
+ Status = STATUS_SUCCESS;
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_RESOURCES)
+ {
+ /* no op */
+ Status = STATUS_SUCCESS;
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_ID)
+ {
+ Status = HDA_PDOQueryId(DeviceObject, Irp);
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_DEVICE_TEXT)
+ {
+ Status = HDA_PDOHandleQueryDeviceText(Irp);
+ }
+ else if (IoStack->MinorFunction == IRP_MN_QUERY_INTERFACE)
+ {
+ Status = HDA_PDOHandleQueryInterface(DeviceObject, Irp);
+ }
+ else
+ {
+ /* get default status */
+ Status = Irp->IoStatus.Status;
}
Irp->IoStatus.Status = Status;
@@ -213,6 +221,27 @@ HDA_Pnp(
return Status;
}
+NTSTATUS
+NTAPI
+HDA_Pnp(
+ _In_ PDEVICE_OBJECT DeviceObject,
+ _Inout_ PIRP Irp)
+{
+ PHDA_FDO_DEVICE_EXTENSION FDODeviceExtension;
+
+ FDODeviceExtension =
static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
+
+ if (FDODeviceExtension->IsFDO)
+ {
+ return HDA_FdoPnp(DeviceObject, Irp);
+ }
+ else
+ {
+ return HDA_PdoPnp(DeviceObject, Irp);
+ }
+}
+
+
NTSTATUS
NTAPI
HDA_AddDevice(