WdfIoTargetClose method

[Applies to KMDF and UMDF]

The WdfIoTargetClose method closes a specified remote I/O target.

Syntax


VOID WdfIoTargetClose(
  [in]  WDFIOTARGET IoTarget
);

Parameters

IoTarget [in]

A handle to an I/O target object that was obtained from a previous call to WdfIoTargetCreate.

Return value

None.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

After a driver has called WdfIoTargetClose, it can call WdfIoTargetOpen to reopen the remote I/O target.

Drivers that supply an EvtIoTargetRemoveComplete callback function must call WdfIoTargetClose from within that callback function.

Before the WdfIoTargetClose method returns, the framework cancels all of the target queue's I/O requests.

If a driver has finished using a remote I/O target and will not use the target again, and the target has no child request objects that are still pending, the driver can call WdfObjectDelete without first calling WdfIoTargetClose. The call to WdfObjectDelete will close the remote I/O target, cancel all of the target queue's I/O requests, and delete the I/O target object. (Note that if the remote I/O target's parent object is a device object, the framework closes the target and deletes the target object when it deletes the parent object.) If the target has any child request objects that are still pending, the driver must call WdfIoTargetClose before it can safely call WdfObjectDelete.

For more information about WdfIoTargetClose, see Controlling a General I/O Target's State.

For more information about I/O targets, see Using I/O Targets.

Examples

The following code example is an EvtIoTargetRemoveComplete callback function that removes a specified I/O target from a driver's collection of I/O targets and then closes the I/O target.


VOID
MyEvtIoTargetRemoveComplete(
    WDFIOTARGET IoTarget
)
{
    //
    // Get device information from the I/O target object's
    // context space.
    //
    targetDeviceInfo = GetTargetDeviceInfo(IoTarget);
    deviceExtension = targetDeviceInfo->DeviceExtension;

    //
    // Remove the target device from the collection.
    //
    WdfWaitLockAcquire(
                       deviceExtension->TargetDeviceCollectionLock,
                       NULL
                       );

    WdfCollectionRemove(
                        deviceExtension->TargetDeviceCollection,
                        IoTarget
                        );

    WdfWaitLockRelease(deviceExtension->TargetDeviceCollectionLock);

    //
    // Close the target.
    //
    WdfIoTargetClose(IoTarget);
}

Requirements

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfiotarget.h (include Wdf.h)

Library

Wdf01000.sys (KMDF);
WUDFx02000.dll (UMDF)

IRQL

PASSIVE_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

See also

EvtIoTargetRemoveComplete
WdfIoTargetCreate

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft