VOID UsbSamp_EvtReadWriteWorkItem( _In_ WDFWORKITEM WorkItem ) { PWORKITEM_CONTEXT pItemContext; NTSTATUS status; UsbSamp_DbgPrint(3, ("ReadWriteWorkItem called\n")); pItemContext = GetWorkItemContext(WorkItem); status = ResetPipe(pItemContext->Pipe); if (!NT_SUCCESS(status)) { UsbSamp_DbgPrint(1, ("ResetPipe failed 0x%x\n", status)); status = ResetDevice(pItemContext->Device); if (!NT_SUCCESS(status)){ UsbSamp_DbgPrint(1, ("ResetDevice failed 0x%x\n", status)); } } WdfObjectDelete(WorkItem); return; }
static NTSTATUS UsbChief_QueuePassiveLevelCallback(IN WDFDEVICE Device, IN WDFUSBPIPE Pipe) { NTSTATUS status = STATUS_SUCCESS; PWORKITEM_CONTEXT context; WDF_OBJECT_ATTRIBUTES attributes; WDF_WORKITEM_CONFIG workitemConfig; WDFWORKITEM hWorkItem; WDF_OBJECT_ATTRIBUTES_INIT(&attributes); WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&attributes, WORKITEM_CONTEXT); attributes.ParentObject = Device; WDF_WORKITEM_CONFIG_INIT(&workitemConfig, UsbChief_ReadWriteWorkItem); status = WdfWorkItemCreate( &workitemConfig, &attributes, &hWorkItem); if (!NT_SUCCESS(status)) return status; context = GetWorkItemContext(hWorkItem); context->Device = Device; context->Pipe = Pipe; WdfWorkItemEnqueue(hWorkItem); return STATUS_SUCCESS; }
NTSTATUS QueuePassiveLevelCallback( _In_ WDFDEVICE Device, _In_ WDFUSBPIPE Pipe ) /*++ Routine Description: This routine is used to queue workitems so that the callback functions can be executed at PASSIVE_LEVEL in the context of a system thread. Arguments: Return Value: --*/ { NTSTATUS status = STATUS_SUCCESS; PWORKITEM_CONTEXT context; WDF_OBJECT_ATTRIBUTES attributes; WDF_WORKITEM_CONFIG workitemConfig; WDFWORKITEM hWorkItem; WDF_OBJECT_ATTRIBUTES_INIT(&attributes); WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&attributes, WORKITEM_CONTEXT); attributes.ParentObject = Device; WDF_WORKITEM_CONFIG_INIT(&workitemConfig, Rio500_EvtReadWriteWorkItem); status = WdfWorkItemCreate( &workitemConfig, &attributes, &hWorkItem ); if (!NT_SUCCESS(status)) { return status; } context = GetWorkItemContext(hWorkItem); context->Device = Device; context->Pipe = Pipe; // // Execute this work item. // WdfWorkItemEnqueue(hWorkItem); return STATUS_SUCCESS; }
static VOID UsbChief_ReadWriteWorkItem(IN WDFWORKITEM WorkItem) { PWORKITEM_CONTEXT pItemContext; NTSTATUS status; UsbChief_DbgPrint(DEBUG_RW, ("called\n")); pItemContext = GetWorkItemContext(WorkItem); status = UsbChief_ResetPipe(pItemContext->Pipe); if (!NT_SUCCESS(status)) { status = UsbChief_ResetDevice(pItemContext->Device); if(!NT_SUCCESS(status)) UsbChief_DbgPrint(0, ("ResetDevice failed 0x%x\n", status)); } WdfObjectDelete(WorkItem); }