diff --git a/reactos/drivers/input/kbdclass/kbdclass.c b/reactos/drivers/input/kbdclass/kbdclass.c index 30621e3b1ad..c52509527dc 100644 --- a/reactos/drivers/input/kbdclass/kbdclass.c +++ b/reactos/drivers/input/kbdclass/kbdclass.c @@ -126,7 +126,7 @@ ClassDeviceControl( PLIST_ENTRY Head = &((PCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->ListHead; if (Head->Flink != Head) { - /* We have at least one keyboard */ + /* We have at least one device */ PPORT_DEVICE_EXTENSION DevExt = CONTAINING_RECORD(Head->Flink, PORT_DEVICE_EXTENSION, ListEntry); IoGetCurrentIrpStackLocation(Irp)->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; IoSkipCurrentIrpStackLocation(Irp); @@ -553,6 +553,9 @@ ConnectPortDriver( CONNECT_DATA ConnectData; NTSTATUS Status; + DPRINT("Connecting PortDO %p [%wZ] to ClassDO %p\n", + PortDO, &PortDO->DriverObject->DriverName, ClassDO); + KeInitializeEvent(&Event, NotificationEvent, FALSE); ConnectData.ClassDeviceObject = ClassDO; @@ -590,6 +593,18 @@ ConnectPortDriver( return IoStatus.Status; } +/* Send IOCTL_INTERNAL_*_DISCONNECT to port */ +static NTSTATUS +DisconnectPortDriver( + IN PDEVICE_OBJECT PortDO) +{ + DPRINT("Disconnecting PortDO %p [%wZ]\n", + PortDO, &PortDO->DriverObject->DriverName); + + DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n"); + return STATUS_NOT_IMPLEMENTED; +} + static NTSTATUS NTAPI ClassAddDevice( IN PDRIVER_OBJECT DriverObject, @@ -686,16 +701,17 @@ ClassAddDevice( cleanup: if (!(Fdo->Flags & DO_DEVICE_INITIALIZING)) - DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n"); + DisconnectPortDriver(Fdo); if (DeviceExtension) { if (DeviceExtension->LowerDevice) IoDetachDevice(DeviceExtension->LowerDevice); - if (DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO) + if (!DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO) { PCLASS_DEVICE_EXTENSION ClassDeviceExtension; ClassDeviceExtension = (PCLASS_DEVICE_EXTENSION)DeviceExtension->ClassDO->DeviceExtension; ExFreePool(ClassDeviceExtension->PortData); + IoDeleteDevice(DeviceExtension->ClassDO); } } if (Fdo) diff --git a/reactos/drivers/input/mouclass/mouclass.c b/reactos/drivers/input/mouclass/mouclass.c index 1493ca8e769..338ba7b826f 100644 --- a/reactos/drivers/input/mouclass/mouclass.c +++ b/reactos/drivers/input/mouclass/mouclass.c @@ -123,7 +123,7 @@ ClassDeviceControl( PLIST_ENTRY Head = &((PCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->ListHead; if (Head->Flink != Head) { - /* We have at least one mouse */ + /* We have at least one device */ PPORT_DEVICE_EXTENSION DevExt = CONTAINING_RECORD(Head->Flink, PORT_DEVICE_EXTENSION, ListEntry); IoGetCurrentIrpStackLocation(Irp)->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; IoSkipCurrentIrpStackLocation(Irp); @@ -529,6 +529,9 @@ ConnectPortDriver( CONNECT_DATA ConnectData; NTSTATUS Status; + DPRINT("Connecting PortDO %p [%wZ] to ClassDO %p\n", + PortDO, &PortDO->DriverObject->DriverName, ClassDO); + KeInitializeEvent(&Event, NotificationEvent, FALSE); ConnectData.ClassDeviceObject = ClassDO; @@ -566,6 +569,18 @@ ConnectPortDriver( return IoStatus.Status; } +/* Send IOCTL_INTERNAL_*_DISCONNECT to port */ +static NTSTATUS +DisconnectPortDriver( + IN PDEVICE_OBJECT PortDO) +{ + DPRINT("Disconnecting PortDO %p [%wZ]\n", + PortDO, &PortDO->DriverObject->DriverName); + + DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n"); + return STATUS_NOT_IMPLEMENTED; +} + static NTSTATUS NTAPI ClassAddDevice( IN PDRIVER_OBJECT DriverObject, @@ -662,16 +677,17 @@ ClassAddDevice( cleanup: if (!(Fdo->Flags & DO_DEVICE_INITIALIZING)) - DPRINT1("FIXME: Need to send IOCTL_INTERNAL_*_DISCONNECT\n"); + DisconnectPortDriver(Fdo); if (DeviceExtension) { if (DeviceExtension->LowerDevice) IoDetachDevice(DeviceExtension->LowerDevice); - if (DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO) + if (!DriverExtension->ConnectMultiplePorts && DeviceExtension->ClassDO) { PCLASS_DEVICE_EXTENSION ClassDeviceExtension; ClassDeviceExtension = (PCLASS_DEVICE_EXTENSION)DeviceExtension->ClassDO->DeviceExtension; ExFreePool(ClassDeviceExtension->PortData); + IoDeleteDevice(DeviceExtension->ClassDO); } } if (Fdo)