[HIDCLASS]

- Fix some whitespace

svn path=/trunk/; revision=59003
This commit is contained in:
Thomas Faber 2013-05-12 15:23:34 +00:00
parent e0936866ae
commit df2001250f
4 changed files with 131 additions and 115 deletions

View file

@ -7,6 +7,7 @@
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
*/
#include "precomp.h"
NTSTATUS
@ -221,7 +222,7 @@ HidClassFDO_GetDescriptors(
ASSERT(FDODeviceExtension->Common.IsFDO);
//
// lets allocate irp
// let's allocate irp
//
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
if (!Irp)
@ -262,7 +263,7 @@ HidClassFDO_GetDescriptors(
}
//
// lets get device attributes
// let's get device attributes
//
IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_HID_GET_DEVICE_ATTRIBUTES;
IoStack->Parameters.DeviceIoControl.OutputBufferLength = sizeof(HID_DEVICE_ATTRIBUTES);
@ -290,7 +291,6 @@ HidClassFDO_GetDescriptors(
ASSERT(FDODeviceExtension->HidDescriptor.DescriptorList[0].wReportLength > 0);
ASSERT(FDODeviceExtension->HidDescriptor.DescriptorList[0].bReportType == HID_REPORT_DESCRIPTOR_TYPE);
//
// now allocate space for the report descriptor
//
@ -359,7 +359,7 @@ HidClassFDO_StartDevice(
}
//
// lets start the lower device too
// let's start the lower device too
//
IoSkipCurrentIrpStackLocation(Irp);
Status = HidClassFDO_DispatchRequestSynchronous(DeviceObject, Irp);
@ -372,7 +372,7 @@ HidClassFDO_StartDevice(
}
//
// lets get the descriptors
// let's get the descriptors
//
Status = HidClassFDO_GetDescriptors(DeviceObject);
if (!NT_SUCCESS(Status))
@ -457,7 +457,7 @@ HidClassFDO_CopyDeviceRelations(
//
// copy device objects
//
for(Index = 0; Index < FDODeviceExtension->DeviceRelations->Count; Index++)
for (Index = 0; Index < FDODeviceExtension->DeviceRelations->Count; Index++)
{
//
// reference pdo
@ -573,7 +573,7 @@ HidClassFDO_PnP(
// get current irp stack location
//
IoStack = IoGetCurrentIrpStackLocation(Irp);
switch(IoStack->MinorFunction)
switch (IoStack->MinorFunction)
{
case IRP_MN_START_DEVICE:
{
@ -596,7 +596,7 @@ HidClassFDO_PnP(
// set status to success and fall through
//
Irp->IoStatus.Status = STATUS_SUCCESS;
}
}
default:
{
//

View file

@ -41,7 +41,6 @@ HidClassAddDevice(
ULONG DeviceExtensionSize;
PHIDCLASS_DRIVER_EXTENSION DriverExtension;
/* increment device number */
InterlockedIncrement((PLONG)&HidClassDeviceNumber);
@ -313,7 +312,7 @@ HidClass_Close(
//
// now free all irps
//
while(!IsListEmpty(&IrpContext->IrpCompletedListHead))
while (!IsListEmpty(&IrpContext->IrpCompletedListHead))
{
//
// remove head irp
@ -336,9 +335,6 @@ HidClass_Close(
//
KeReleaseSpinLock(&IrpContext->Lock, OldLevel);
//
// remove context
//
@ -429,13 +425,15 @@ HidClass_ReadCompleteIrp(
//
// get collection description
//
CollectionDescription = HidClassPDO_GetCollectionDescription(&IrpContext->FileOp->DeviceExtension->Common.DeviceDescription, IrpContext->FileOp->DeviceExtension->CollectionNumber);
CollectionDescription = HidClassPDO_GetCollectionDescription(&IrpContext->FileOp->DeviceExtension->Common.DeviceDescription,
IrpContext->FileOp->DeviceExtension->CollectionNumber);
ASSERT(CollectionDescription);
//
// get report description
//
ReportDescription = HidClassPDO_GetReportDescription(&IrpContext->FileOp->DeviceExtension->Common.DeviceDescription, IrpContext->FileOp->DeviceExtension->CollectionNumber);
ReportDescription = HidClassPDO_GetReportDescription(&IrpContext->FileOp->DeviceExtension->Common.DeviceDescription,
IrpContext->FileOp->DeviceExtension->CollectionNumber);
ASSERT(ReportDescription);
if (CollectionDescription && ReportDescription)
@ -638,13 +636,15 @@ HidClass_BuildIrp(
//
// get collection description
//
CollectionDescription = HidClassPDO_GetCollectionDescription(&IrpContext->FileOp->DeviceExtension->Common.DeviceDescription, IrpContext->FileOp->DeviceExtension->CollectionNumber);
CollectionDescription = HidClassPDO_GetCollectionDescription(&IrpContext->FileOp->DeviceExtension->Common.DeviceDescription,
IrpContext->FileOp->DeviceExtension->CollectionNumber);
ASSERT(CollectionDescription);
//
// get report description
//
ReportDescription = HidClassPDO_GetReportDescription(&IrpContext->FileOp->DeviceExtension->Common.DeviceDescription, IrpContext->FileOp->DeviceExtension->CollectionNumber);
ReportDescription = HidClassPDO_GetReportDescription(&IrpContext->FileOp->DeviceExtension->Common.DeviceDescription,
IrpContext->FileOp->DeviceExtension->CollectionNumber);
ASSERT(ReportDescription);
//
@ -664,7 +664,6 @@ HidClass_BuildIrp(
}
//
// store report length
//
@ -712,7 +711,6 @@ HidClass_BuildIrp(
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
HidClass_Read(
@ -757,21 +755,25 @@ HidClass_Read(
if (Context->StopInProgress)
{
//
// stop in progress
//
DPRINT1("[HIDCLASS] Stop In Progress\n");
Irp->IoStatus.Status = STATUS_CANCELLED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_CANCELLED;
//
// stop in progress
//
DPRINT1("[HIDCLASS] Stop In Progress\n");
Irp->IoStatus.Status = STATUS_CANCELLED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_CANCELLED;
}
//
// build irp request
//
Status = HidClass_BuildIrp(DeviceObject, Irp, Context, IOCTL_HID_READ_REPORT, IoStack->Parameters.Read.Length, &NewIrp, &NewIrpContext);
Status = HidClass_BuildIrp(DeviceObject,
Irp,
Context,
IOCTL_HID_READ_REPORT,
IoStack->Parameters.Read.Length,
&NewIrp,
&NewIrpContext);
if (!NT_SUCCESS(Status))
{
//
@ -814,7 +816,7 @@ HidClass_Read(
IoMarkIrpPending(Irp);
//
// lets dispatch the request
// let's dispatch the request
//
ASSERT(Context->DeviceExtension);
Status = Context->DeviceExtension->Common.DriverExtension->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL](Context->DeviceExtension->FDODeviceObject, NewIrp);
@ -881,7 +883,7 @@ HidClass_DeviceControl(
//
IoStack = IoGetCurrentIrpStackLocation(Irp);
switch(IoStack->Parameters.DeviceIoControl.IoControlCode)
switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_HID_GET_COLLECTION_INFORMATION:
{
@ -907,7 +909,8 @@ HidClass_DeviceControl(
//
// get collection description
//
CollectionDescription = HidClassPDO_GetCollectionDescription(&CommonDeviceExtension->DeviceDescription, PDODeviceExtension->CollectionNumber);
CollectionDescription = HidClassPDO_GetCollectionDescription(&CommonDeviceExtension->DeviceDescription,
PDODeviceExtension->CollectionNumber);
ASSERT(CollectionDescription);
//
@ -932,7 +935,8 @@ HidClass_DeviceControl(
//
// get collection description
//
CollectionDescription = HidClassPDO_GetCollectionDescription(&CommonDeviceExtension->DeviceDescription, PDODeviceExtension->CollectionNumber);
CollectionDescription = HidClassPDO_GetCollectionDescription(&CommonDeviceExtension->DeviceDescription,
PDODeviceExtension->CollectionNumber);
ASSERT(CollectionDescription);
//
@ -985,7 +989,6 @@ HidClass_InternalDeviceControl(
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
NTAPI
HidClass_Power(
@ -1075,7 +1078,7 @@ HidClassDispatch(
//
// dispatch request based on major function
//
switch(IoStack->MajorFunction)
switch (IoStack->MajorFunction)
{
case IRP_MJ_CREATE:
return HidClass_Create(DeviceObject, Irp);
@ -1134,7 +1137,9 @@ HidRegisterMinidriver(
DriverExtension->DriverUnload = MinidriverRegistration->DriverObject->DriverUnload;
/* copy driver dispatch routines */
RtlCopyMemory(DriverExtension->MajorFunction, MinidriverRegistration->DriverObject->MajorFunction, sizeof(PDRIVER_DISPATCH) * (IRP_MJ_MAXIMUM_FUNCTION+1));
RtlCopyMemory(DriverExtension->MajorFunction,
MinidriverRegistration->DriverObject->MajorFunction,
sizeof(PDRIVER_DISPATCH) * (IRP_MJ_MAXIMUM_FUNCTION+1));
/* initialize lock */
KeInitializeSpinLock(&DriverExtension->Lock);

View file

@ -7,6 +7,7 @@
* Michael Martin (michael.martin@reactos.org)
* Johannes Anderwald (johannes.anderwald@reactos.org)
*/
#include "precomp.h"
PHIDP_COLLECTION_DESC
@ -42,7 +43,7 @@ HidClassPDO_GetReportDescription(
{
ULONG Index;
for(Index = 0; Index < DeviceDescription->ReportIDsLength; Index++)
for (Index = 0; Index < DeviceDescription->ReportIDsLength; Index++)
{
if (DeviceDescription->ReportIDs[Index].CollectionNumber == CollectionNumber)
{
@ -151,8 +152,8 @@ HidClassPDO_HandleQueryHardwareId(
//
// get device extension
//
PDODeviceExtension = (PHIDCLASS_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(PDODeviceExtension->Common.IsFDO == FALSE);
PDODeviceExtension = (PHIDCLASS_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(PDODeviceExtension->Common.IsFDO == FALSE);
//
// copy current stack location
@ -196,7 +197,7 @@ HidClassPDO_HandleQueryHardwareId(
if (CollectionDescription->UsagePage == HID_USAGE_PAGE_GENERIC)
{
switch(CollectionDescription->Usage)
switch (CollectionDescription->Usage)
{
case HID_USAGE_GENERIC_POINTER:
case HID_USAGE_GENERIC_MOUSE:
@ -253,7 +254,7 @@ HidClassPDO_HandleQueryHardwareId(
//
// allocate buffer
//
Ptr = (LPWSTR)ExAllocatePool(NonPagedPool, (Offset +1)* sizeof(WCHAR));
Ptr = (LPWSTR)ExAllocatePool(NonPagedPool, (Offset + 1) * sizeof(WCHAR));
if (!Ptr)
{
//
@ -287,9 +288,8 @@ HidClassPDO_HandleQueryInstanceId(
//
// get device extension
//
PDODeviceExtension = (PHIDCLASS_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(PDODeviceExtension->Common.IsFDO == FALSE);
PDODeviceExtension = (PHIDCLASS_PDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
ASSERT(PDODeviceExtension->Common.IsFDO == FALSE);
//
// allocate buffer
@ -370,47 +370,47 @@ HidClassPDO_PnP(
//
// handle request
//
switch(IoStack->MinorFunction)
switch (IoStack->MinorFunction)
{
case IRP_MN_QUERY_ID:
{
if (IoStack->Parameters.QueryId.IdType == BusQueryDeviceID)
{
//
// handle query device id
//
Status = HidClassPDO_HandleQueryDeviceId(DeviceObject, Irp);
break;
}
else if (IoStack->Parameters.QueryId.IdType == BusQueryHardwareIDs)
{
//
// handle instance id
//
Status = HidClassPDO_HandleQueryHardwareId(DeviceObject, Irp);
break;
}
else if (IoStack->Parameters.QueryId.IdType == BusQueryInstanceID)
{
//
// handle instance id
//
Status = HidClassPDO_HandleQueryInstanceId(DeviceObject, Irp);
break;
}
else if (IoStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
{
//
// handle instance id
//
Status = HidClassPDO_HandleQueryCompatibleId(DeviceObject, Irp);
break;
}
DPRINT1("[HIDCLASS]: IRP_MN_QUERY_ID IdType %x unimplemented\n", IoStack->Parameters.QueryId.IdType);
Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0;
break;
if (IoStack->Parameters.QueryId.IdType == BusQueryDeviceID)
{
//
// handle query device id
//
Status = HidClassPDO_HandleQueryDeviceId(DeviceObject, Irp);
break;
}
else if (IoStack->Parameters.QueryId.IdType == BusQueryHardwareIDs)
{
//
// handle instance id
//
Status = HidClassPDO_HandleQueryHardwareId(DeviceObject, Irp);
break;
}
else if (IoStack->Parameters.QueryId.IdType == BusQueryInstanceID)
{
//
// handle instance id
//
Status = HidClassPDO_HandleQueryInstanceId(DeviceObject, Irp);
break;
}
else if (IoStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
{
//
// handle instance id
//
Status = HidClassPDO_HandleQueryCompatibleId(DeviceObject, Irp);
break;
}
DPRINT1("[HIDCLASS]: IRP_MN_QUERY_ID IdType %x unimplemented\n", IoStack->Parameters.QueryId.IdType);
Status = STATUS_NOT_SUPPORTED;
Irp->IoStatus.Information = 0;
break;
}
case IRP_MN_QUERY_CAPABILITIES:
{
@ -426,7 +426,9 @@ HidClassPDO_PnP(
//
// copy capabilities
//
RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities, &PDODeviceExtension->Capabilities, sizeof(DEVICE_CAPABILITIES));
RtlCopyMemory(IoStack->Parameters.DeviceCapabilities.Capabilities,
&PDODeviceExtension->Capabilities,
sizeof(DEVICE_CAPABILITIES));
Status = STATUS_SUCCESS;
break;
}
@ -436,7 +438,7 @@ HidClassPDO_PnP(
//
//
BusInformation = (PPNP_BUS_INFORMATION)ExAllocatePool(NonPagedPool, sizeof(PNP_BUS_INFORMATION));
//
// fill in result
//
@ -510,7 +512,10 @@ HidClassPDO_PnP(
//
// now register the device interface
//
Status = IoRegisterDeviceInterface(PDODeviceExtension->Common.HidDeviceExtension.PhysicalDeviceObject, &GUID_DEVINTERFACE_HID, NULL, &PDODeviceExtension->DeviceInterface);
Status = IoRegisterDeviceInterface(PDODeviceExtension->Common.HidDeviceExtension.PhysicalDeviceObject,
&GUID_DEVINTERFACE_HID,
NULL,
&PDODeviceExtension->DeviceInterface);
DPRINT("[HIDCLASS] IoRegisterDeviceInterfaceState Status %x\n", Status);
if (NT_SUCCESS(Status))
{
@ -533,22 +538,22 @@ HidClassPDO_PnP(
if (PDODeviceExtension->DeviceInterface.Length != 0)
IoSetDeviceInterfaceState(&PDODeviceExtension->DeviceInterface, FALSE);
//
// remove us from the fdo's pdo list
//
bFound = FALSE;
for(Index = 0; Index < PDODeviceExtension->FDODeviceExtension->DeviceRelations->Count; Index++)
{
if (PDODeviceExtension->FDODeviceExtension->DeviceRelations->Objects[Index] == DeviceObject)
{
//
// remove us
//
bFound = TRUE;
PDODeviceExtension->FDODeviceExtension->DeviceRelations->Objects[Index] = NULL;
break;
}
}
//
// remove us from the fdo's pdo list
//
bFound = FALSE;
for (Index = 0; Index < PDODeviceExtension->FDODeviceExtension->DeviceRelations->Count; Index++)
{
if (PDODeviceExtension->FDODeviceExtension->DeviceRelations->Objects[Index] == DeviceObject)
{
//
// remove us
//
bFound = TRUE;
PDODeviceExtension->FDODeviceExtension->DeviceRelations->Objects[Index] = NULL;
break;
}
}
/* Complete the IRP */
Irp->IoStatus.Status = STATUS_SUCCESS;
@ -659,15 +664,21 @@ HidClassPDO_CreatePDO(
RtlZeroMemory(DeviceRelations, Length);
//
// lets create a PDO for top level collection
// let's create a PDO for top level collection
//
Index = 0;
do
{
//
// lets create the device object
// let's create the device object
//
Status = IoCreateDevice(FDODeviceExtension->Common.DriverExtension->DriverObject, sizeof(HIDCLASS_PDO_DEVICE_EXTENSION), NULL, FILE_DEVICE_UNKNOWN, FILE_AUTOGENERATED_DEVICE_NAME, FALSE, &PDODeviceObject);
Status = IoCreateDevice(FDODeviceExtension->Common.DriverExtension->DriverObject,
sizeof(HIDCLASS_PDO_DEVICE_EXTENSION),
NULL,
FILE_DEVICE_UNKNOWN,
FILE_AUTOGENERATED_DEVICE_NAME,
FALSE,
&PDODeviceObject);
if (!NT_SUCCESS(Status))
{
//
@ -724,10 +735,10 @@ HidClassPDO_CreatePDO(
//
// move to next
//
//
Index++;
}while(Index < FDODeviceExtension->Common.DeviceDescription.CollectionDescLength);
} while(Index < FDODeviceExtension->Common.DeviceDescription.CollectionDescLength);
//
@ -738,7 +749,7 @@ HidClassPDO_CreatePDO(
//
// failed
//
for(Index = 0; Index < DeviceRelations->Count; Index++)
for (Index = 0; Index < DeviceRelations->Count; Index++)
{
//
// delete device
@ -762,4 +773,4 @@ HidClassPDO_CreatePDO(
// done
//
return STATUS_SUCCESS;
}
}

View file

@ -20,7 +20,7 @@ typedef struct
PDRIVER_UNLOAD DriverUnload;
KSPIN_LOCK Lock;
}HIDCLASS_DRIVER_EXTENSION, *PHIDCLASS_DRIVER_EXTENSION;
} HIDCLASS_DRIVER_EXTENSION, *PHIDCLASS_DRIVER_EXTENSION;
typedef struct
{
@ -49,7 +49,7 @@ typedef struct
//
HID_DEVICE_ATTRIBUTES Attributes;
}HIDCLASS_COMMON_DEVICE_EXTENSION, *PHIDCLASS_COMMON_DEVICE_EXTENSION;
} HIDCLASS_COMMON_DEVICE_EXTENSION, *PHIDCLASS_COMMON_DEVICE_EXTENSION;
typedef struct
{
@ -78,7 +78,7 @@ typedef struct
//
PDEVICE_RELATIONS DeviceRelations;
}HIDCLASS_FDO_EXTENSION, *PHIDCLASS_FDO_EXTENSION;
} HIDCLASS_FDO_EXTENSION, *PHIDCLASS_FDO_EXTENSION;
typedef struct
{
@ -98,7 +98,7 @@ typedef struct
ULONG CollectionNumber;
//
// device interface
// device interface
//
UNICODE_STRING DeviceInterface;
@ -112,7 +112,7 @@ typedef struct
//
PHIDCLASS_FDO_EXTENSION FDODeviceExtension;
}HIDCLASS_PDO_DEVICE_EXTENSION, *PHIDCLASS_PDO_DEVICE_EXTENSION;
} HIDCLASS_PDO_DEVICE_EXTENSION, *PHIDCLASS_PDO_DEVICE_EXTENSION;
typedef struct __HIDCLASS_FILEOP_CONTEXT__
{
@ -146,7 +146,7 @@ typedef struct __HIDCLASS_FILEOP_CONTEXT__
//
KEVENT IrpReadComplete;
}HIDCLASS_FILEOP_CONTEXT, *PHIDCLASS_FILEOP_CONTEXT;
} HIDCLASS_FILEOP_CONTEXT, *PHIDCLASS_FILEOP_CONTEXT;
typedef struct
{
@ -175,7 +175,7 @@ typedef struct
//
PIO_WORKITEM CompletionWorkItem;
}HIDCLASS_IRP_CONTEXT, *PHIDCLASS_IRP_CONTEXT;
} HIDCLASS_IRP_CONTEXT, *PHIDCLASS_IRP_CONTEXT;
/* fdo.c */
NTSTATUS