static LIST_ENTRY ProvList;\r
static KGUARDED_MUTEX Lock;\r
\r
-static EVT_WDF_DRIVER_DEVICE_ADD WmIbDeviceAdd;\r
-static EVT_WDF_OBJECT_CONTEXT_CLEANUP WmIbDeviceCleanup;\r
-static EVT_WDF_DEVICE_D0_ENTRY WmPowerD0Entry;\r
static EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL WmIoDeviceControl;\r
static EVT_WDF_IO_QUEUE_IO_READ WmIoRead;\r
static EVT_WDF_IO_QUEUE_IO_WRITE WmIoWrite;\r
NTSTATUS status;\r
\r
dev = WmIbDeviceGetContext(Device);\r
+ RtlZeroMemory(dev, sizeof *dev);\r
+ dev->Ref = 1;\r
+ KeInitializeEvent(&dev->Event, NotificationEvent, FALSE);\r
+\r
status = WdfFdoQueryForInterface(Device, &GUID_RDMA_INTERFACE_VERBS,\r
(PINTERFACE) &dev->VerbsInterface,\r
sizeof(dev->VerbsInterface), VerbsVersion(2, 0),\r
return STATUS_SUCCESS;\r
}\r
\r
-static NTSTATUS WmIbDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)\r
-{\r
- WDF_OBJECT_ATTRIBUTES attr;\r
- WDF_PNPPOWER_EVENT_CALLBACKS power;\r
- WDFDEVICE dev;\r
- WM_IB_DEVICE *pdev;\r
- NTSTATUS status;\r
-\r
- WdfFdoInitSetFilter(DeviceInit);\r
-\r
- WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, WM_IB_DEVICE);\r
- attr.EvtCleanupCallback = WmIbDeviceCleanup;\r
-\r
- WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&power);\r
- power.EvtDeviceD0Entry = WmPowerD0Entry;\r
- WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &power);\r
-\r
- status = WdfDeviceCreate(&DeviceInit, &attr, &dev);\r
- if (!NT_SUCCESS(status)) {\r
- return status;\r
- }\r
-\r
- pdev = WmIbDeviceGetContext(dev);\r
- RtlZeroMemory(pdev, sizeof *pdev);\r
- pdev->Ref = 1;\r
- KeInitializeEvent(&pdev->Event, NotificationEvent, FALSE);\r
-\r
- return STATUS_SUCCESS;\r
-}\r
-\r
-static VOID WmIbDeviceCleanup(WDFDEVICE Device)\r
+static NTSTATUS WmPowerD0Exit(WDFDEVICE Device, WDF_POWER_DEVICE_STATE TargetState)\r
{\r
WM_PROVIDER *prov;\r
WM_IB_DEVICE *pdev;\r
BOOLEAN destroy;\r
WDFDEVICE ctrldev;\r
\r
- pdev = (WmIbDeviceGetContext(Device));\r
+ pdev = WmIbDeviceGetContext(Device);\r
\r
KeAcquireGuardedMutex(&Lock);\r
RemoveEntryList(&pdev->Entry);\r
if (destroy) {\r
WdfObjectDelete(ctrldev);\r
}\r
+\r
+ return STATUS_SUCCESS;\r
+}\r
+\r
+static NTSTATUS WmIbDeviceAdd(WDFDRIVER Driver, PWDFDEVICE_INIT DeviceInit)\r
+{\r
+ WDF_OBJECT_ATTRIBUTES attr;\r
+ WDF_PNPPOWER_EVENT_CALLBACKS power;\r
+ WDFDEVICE dev;\r
+ NTSTATUS status;\r
+\r
+ WdfFdoInitSetFilter(DeviceInit);\r
+\r
+ WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, WM_IB_DEVICE);\r
+ WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&power);\r
+ power.EvtDeviceD0Entry = WmPowerD0Entry;\r
+ power.EvtDeviceD0Exit = WmPowerD0Exit;\r
+ WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &power);\r
+\r
+ status = WdfDeviceCreate(&DeviceInit, &attr, &dev);\r
+ if (!NT_SUCCESS(status)) {\r
+ return status;\r
+ }\r
+\r
+ return STATUS_SUCCESS;\r
}\r
\r
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)\r
\r
len = outlen;\r
status = WmCopyRead(pProvider, wmad, pProvider->MadHead, &len);\r
- if (NT_SUCCESS(status)) {\r
+ if (status == STATUS_SUCCESS) {\r
reg = (WM_REGISTRATION *) pProvider->MadHead->send_context1;\r
reg->pDevice->IbInterface.put_mad(WmRemoveMad(pProvider));\r
}\r
}\r
\r
status = WmCopyRead(prov, wmad, pMad, &len);\r
- if (NT_SUCCESS(status)) {\r
+ if (status == STATUS_SUCCESS) {\r
reg = (WM_REGISTRATION *) pMad->send_context1;\r
reg->pDevice->IbInterface.put_mad(pMad);\r
} else {\r