everything below looks correct to me…
// Set some properties for the child device
WDF_DEVICE_PNP_CAPABILITIES_INIT(&pnp_capabilities);
//pnp_capabilities.Removable = WdfTrue;
//pnp_capabilities.EjectSupported = WdfTrue;
//pnp_capabilities.SurpriseRemovalOK = WdfTrue;
pnp_capabilities.Address = port_number;
pnp_capabilities.UINumber = port_number;
WdfDeviceSetPnpCapabilities(child_device, &pnp_capabilities);
// Create a custom interface so that other drivers can
// query (IRP_MN_QUERY_INTERFACE) and use our callbacks directly.
RtlZeroMemory(&mac_interface, sizeof(mac_interface));
mac_interface.InterfaceHeader.Size = sizeof(mac_interface);
mac_interface.InterfaceHeader.Version = 1;
mac_interface.InterfaceHeader.Context = (PVOID) child_device;
// Let the framework handle reference counting.
mac_interface.InterfaceHeader.InterfaceReference =
WdfDeviceInterfaceReferenceNoOp;
mac_interface.InterfaceHeader.InterfaceDereference =
WdfDeviceInterfaceDereferenceNoOp;
mac_interface.bus_get_port_number = bus_get_port_number;
mac_interface.bus_get_port_memory = bus_get_port_memory;
mac_interface.IsSafetyLockEnabled = Bus_IsSafetyLockEnabled;
WDF_QUERY_INTERFACE_CONFIG_INIT(
&query_interface_config,
(PINTERFACE) &mac_interface,
&GUID_TOASTER_INTERFACE_STANDARD,
NULL);
// If you need multiple interfaces, you can call WdfDeviceAddQueryInterface
// multiple times to add additional interfaces.
status = WdfDeviceAddQueryInterface(child_device, &query_interface_config);
if (!NT_SUCCESS(status))
{
goto CLEANUP;
}
// Add this device to the FDO’s collection of children.
// After the child device is added to the static collection successfully,
// driver must call WdfPdoMarkMissing to get the device deleted. It
// shouldn’t delete the child device directly by calling WdfObjectDelete.
status = WdfFdoAddStaticChild(device, child_device);
if (!NT_SUCCESS(status))
{
goto CLEANUP;
}