mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:13:03 +00:00
[SCSIPORT]: Code formatting in the functions I'm going to touch next (in addition, add few "continue;" inside some loops so that I can reduce the indent level of code blocks).
svn path=/trunk/; revision=74594
This commit is contained in:
parent
5f36105c74
commit
b00727337e
1 changed files with 431 additions and 442 deletions
|
@ -3569,11 +3569,11 @@ SpiSendInquiry (IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
DeviceExtension = (PSCSI_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
DeviceExtension = (PSCSI_PORT_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
InquiryBuffer = ExAllocatePoolWithTag (NonPagedPool, INQUIRYDATABUFFERSIZE, TAG_SCSIPORT);
|
InquiryBuffer = ExAllocatePoolWithTag(NonPagedPool, INQUIRYDATABUFFERSIZE, TAG_SCSIPORT);
|
||||||
if (InquiryBuffer == NULL)
|
if (InquiryBuffer == NULL)
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
SenseBuffer = ExAllocatePoolWithTag (NonPagedPool, SENSE_BUFFER_SIZE, TAG_SCSIPORT);
|
SenseBuffer = ExAllocatePoolWithTag(NonPagedPool, SENSE_BUFFER_SIZE, TAG_SCSIPORT);
|
||||||
if (SenseBuffer == NULL)
|
if (SenseBuffer == NULL)
|
||||||
{
|
{
|
||||||
ExFreePool(InquiryBuffer);
|
ExFreePool(InquiryBuffer);
|
||||||
|
@ -3658,10 +3658,11 @@ SpiSendInquiry (IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
KeepTrying = FALSE;
|
KeepTrying = FALSE;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("Inquiry SRB failed with SrbStatus 0x%08X\n", Srb.SrbStatus);
|
DPRINT("Inquiry SRB failed with SrbStatus 0x%08X\n", Srb.SrbStatus);
|
||||||
|
|
||||||
/* Check if the queue is frozen */
|
/* Check if the queue is frozen */
|
||||||
if (Srb.SrbStatus & SRB_STATUS_QUEUE_FROZEN)
|
if (Srb.SrbStatus & SRB_STATUS_QUEUE_FROZEN)
|
||||||
{
|
{
|
||||||
|
@ -3693,6 +3694,7 @@ SpiSendInquiry (IN PDEVICE_OBJECT DeviceObject,
|
||||||
if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_DATA_OVERRUN)
|
if (SRB_STATUS(Srb.SrbStatus) == SRB_STATUS_DATA_OVERRUN)
|
||||||
{
|
{
|
||||||
DPRINT("Data overrun at TargetId %d\n", LunInfo->TargetId);
|
DPRINT("Data overrun at TargetId %d\n", LunInfo->TargetId);
|
||||||
|
|
||||||
/* Nothing dramatic, just copy data, but limiting the size */
|
/* Nothing dramatic, just copy data, but limiting the size */
|
||||||
RtlCopyMemory(LunInfo->InquiryData,
|
RtlCopyMemory(LunInfo->InquiryData,
|
||||||
InquiryBuffer,
|
InquiryBuffer,
|
||||||
|
@ -3739,7 +3741,6 @@ SpiSendInquiry (IN PDEVICE_OBJECT DeviceObject,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Free buffers */
|
/* Free buffers */
|
||||||
ExFreePool(InquiryBuffer);
|
ExFreePool(InquiryBuffer);
|
||||||
|
@ -3968,7 +3969,7 @@ SpiScanAdapter(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
SpiGetInquiryData(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
SpiGetInquiryData(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
ULONG InquiryDataSize;
|
ULONG InquiryDataSize;
|
||||||
PSCSI_LUN_INFO LunInfo;
|
PSCSI_LUN_INFO LunInfo;
|
||||||
|
@ -5270,8 +5271,8 @@ ScsiPortIoTimer(PDEVICE_OBJECT DeviceObject,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
SpiBuildDeviceMap(IN PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
PUNICODE_STRING RegistryPath)
|
IN PUNICODE_STRING RegistryPath)
|
||||||
{
|
{
|
||||||
PSCSI_PORT_LUN_EXTENSION LunExtension;
|
PSCSI_PORT_LUN_EXTENSION LunExtension;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
@ -5299,7 +5300,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
if (DeviceExtension == NULL || RegistryPath == NULL)
|
if (DeviceExtension == NULL || RegistryPath == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("Invalid parameter\n");
|
DPRINT1("Invalid parameter\n");
|
||||||
return(STATUS_INVALID_PARAMETER);
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open or create the 'Scsi' subkey */
|
/* Open or create the 'Scsi' subkey */
|
||||||
|
@ -5320,18 +5321,16 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("ZwCreateKey() failed (Status %lx)\n", Status);
|
DPRINT("ZwCreateKey() failed (Status %lx)\n", Status);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create new 'Scsi Port X' subkey */
|
/* Create new 'Scsi Port X' subkey */
|
||||||
DPRINT("Scsi Port %lu\n",
|
DPRINT("Scsi Port %lu\n", DeviceExtension->PortNumber);
|
||||||
DeviceExtension->PortNumber);
|
|
||||||
|
|
||||||
swprintf(NameBuffer,
|
swprintf(NameBuffer,
|
||||||
L"Scsi Port %lu",
|
L"Scsi Port %lu",
|
||||||
DeviceExtension->PortNumber);
|
DeviceExtension->PortNumber);
|
||||||
RtlInitUnicodeString(&KeyName,
|
RtlInitUnicodeString(&KeyName, NameBuffer);
|
||||||
NameBuffer);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&KeyName,
|
&KeyName,
|
||||||
OBJ_KERNEL_HANDLE,
|
OBJ_KERNEL_HANDLE,
|
||||||
|
@ -5348,7 +5347,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("ZwCreateKey() failed (Status %lx)\n", Status);
|
DPRINT("ZwCreateKey() failed (Status %lx)\n", Status);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5357,26 +5356,24 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
|
|
||||||
/* Set 'DMA Enabled' (REG_DWORD) value */
|
/* Set 'DMA Enabled' (REG_DWORD) value */
|
||||||
UlongData = (ULONG)!DeviceExtension->PortCapabilities.AdapterUsesPio;
|
UlongData = (ULONG)!DeviceExtension->PortCapabilities.AdapterUsesPio;
|
||||||
DPRINT(" DMA Enabled = %s\n", (UlongData) ? "TRUE" : "FALSE");
|
DPRINT(" DMA Enabled = %s\n", UlongData ? "TRUE" : "FALSE");
|
||||||
RtlInitUnicodeString(&ValueName,
|
RtlInitUnicodeString(&ValueName, L"DMA Enabled");
|
||||||
L"DMA Enabled");
|
|
||||||
Status = ZwSetValueKey(ScsiPortKey,
|
Status = ZwSetValueKey(ScsiPortKey,
|
||||||
&ValueName,
|
&ValueName,
|
||||||
0,
|
0,
|
||||||
REG_DWORD,
|
REG_DWORD,
|
||||||
&UlongData,
|
&UlongData,
|
||||||
sizeof(ULONG));
|
sizeof(UlongData));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("ZwSetValueKey('DMA Enabled') failed (Status %lx)\n", Status);
|
DPRINT("ZwSetValueKey('DMA Enabled') failed (Status %lx)\n", Status);
|
||||||
ZwClose(ScsiPortKey);
|
ZwClose(ScsiPortKey);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set 'Driver' (REG_SZ) value */
|
/* Set 'Driver' (REG_SZ) value */
|
||||||
DriverName = wcsrchr(RegistryPath->Buffer, L'\\') + 1;
|
DriverName = wcsrchr(RegistryPath->Buffer, L'\\') + 1;
|
||||||
RtlInitUnicodeString(&ValueName,
|
RtlInitUnicodeString(&ValueName, L"Driver");
|
||||||
L"Driver");
|
|
||||||
Status = ZwSetValueKey(ScsiPortKey,
|
Status = ZwSetValueKey(ScsiPortKey,
|
||||||
&ValueName,
|
&ValueName,
|
||||||
0,
|
0,
|
||||||
|
@ -5387,43 +5384,41 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
{
|
{
|
||||||
DPRINT("ZwSetValueKey('Driver') failed (Status %lx)\n", Status);
|
DPRINT("ZwSetValueKey('Driver') failed (Status %lx)\n", Status);
|
||||||
ZwClose(ScsiPortKey);
|
ZwClose(ScsiPortKey);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set 'Interrupt' (REG_DWORD) value (NT4 only) */
|
/* Set 'Interrupt' (REG_DWORD) value (NT4 only) */
|
||||||
UlongData = (ULONG)DeviceExtension->PortConfig->BusInterruptLevel;
|
UlongData = (ULONG)DeviceExtension->PortConfig->BusInterruptLevel;
|
||||||
DPRINT(" Interrupt = %lu\n", UlongData);
|
DPRINT(" Interrupt = %lu\n", UlongData);
|
||||||
RtlInitUnicodeString(&ValueName,
|
RtlInitUnicodeString(&ValueName, L"Interrupt");
|
||||||
L"Interrupt");
|
|
||||||
Status = ZwSetValueKey(ScsiPortKey,
|
Status = ZwSetValueKey(ScsiPortKey,
|
||||||
&ValueName,
|
&ValueName,
|
||||||
0,
|
0,
|
||||||
REG_DWORD,
|
REG_DWORD,
|
||||||
&UlongData,
|
&UlongData,
|
||||||
sizeof(ULONG));
|
sizeof(UlongData));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("ZwSetValueKey('Interrupt') failed (Status %lx)\n", Status);
|
DPRINT("ZwSetValueKey('Interrupt') failed (Status %lx)\n", Status);
|
||||||
ZwClose(ScsiPortKey);
|
ZwClose(ScsiPortKey);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set 'IOAddress' (REG_DWORD) value (NT4 only) */
|
/* Set 'IOAddress' (REG_DWORD) value (NT4 only) */
|
||||||
UlongData = ScsiPortConvertPhysicalAddressToUlong((*DeviceExtension->PortConfig->AccessRanges)[0].RangeStart);
|
UlongData = ScsiPortConvertPhysicalAddressToUlong((*DeviceExtension->PortConfig->AccessRanges)[0].RangeStart);
|
||||||
DPRINT(" IOAddress = %lx\n", UlongData);
|
DPRINT(" IOAddress = %lx\n", UlongData);
|
||||||
RtlInitUnicodeString(&ValueName,
|
RtlInitUnicodeString(&ValueName, L"IOAddress");
|
||||||
L"IOAddress");
|
|
||||||
Status = ZwSetValueKey(ScsiPortKey,
|
Status = ZwSetValueKey(ScsiPortKey,
|
||||||
&ValueName,
|
&ValueName,
|
||||||
0,
|
0,
|
||||||
REG_DWORD,
|
REG_DWORD,
|
||||||
&UlongData,
|
&UlongData,
|
||||||
sizeof(ULONG));
|
sizeof(UlongData));
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("ZwSetValueKey('IOAddress') failed (Status %lx)\n", Status);
|
DPRINT("ZwSetValueKey('IOAddress') failed (Status %lx)\n", Status);
|
||||||
ZwClose(ScsiPortKey);
|
ZwClose(ScsiPortKey);
|
||||||
return(Status);
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enumerate buses */
|
/* Enumerate buses */
|
||||||
|
@ -5434,8 +5429,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
swprintf(NameBuffer,
|
swprintf(NameBuffer,
|
||||||
L"Scsi Bus %lu",
|
L"Scsi Bus %lu",
|
||||||
BusNumber);
|
BusNumber);
|
||||||
RtlInitUnicodeString(&KeyName,
|
RtlInitUnicodeString(&KeyName, NameBuffer);
|
||||||
NameBuffer);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&KeyName,
|
&KeyName,
|
||||||
0,
|
0,
|
||||||
|
@ -5455,13 +5449,12 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create 'Initiator Id X' key */
|
/* Create 'Initiator Id X' key */
|
||||||
DPRINT(" Initiator Id %u\n",
|
DPRINT(" Initiator Id %lu\n",
|
||||||
DeviceExtension->PortConfig->InitiatorBusId[BusNumber]);
|
DeviceExtension->PortConfig->InitiatorBusId[BusNumber]);
|
||||||
swprintf(NameBuffer,
|
swprintf(NameBuffer,
|
||||||
L"Initiator Id %u",
|
L"Initiator Id %lu",
|
||||||
(unsigned int)(UCHAR)DeviceExtension->PortConfig->InitiatorBusId[BusNumber]);
|
(ULONG)(UCHAR)DeviceExtension->PortConfig->InitiatorBusId[BusNumber]);
|
||||||
RtlInitUnicodeString(&KeyName,
|
RtlInitUnicodeString(&KeyName, NameBuffer);
|
||||||
NameBuffer);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&KeyName,
|
&KeyName,
|
||||||
0,
|
0,
|
||||||
|
@ -5497,8 +5490,9 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
(UCHAR)BusNumber,
|
(UCHAR)BusNumber,
|
||||||
(UCHAR)Target,
|
(UCHAR)Target,
|
||||||
(UCHAR)Lun);
|
(UCHAR)Lun);
|
||||||
if (LunExtension != NULL)
|
if (LunExtension == NULL)
|
||||||
{
|
continue;
|
||||||
|
|
||||||
if (Target != CurrentTarget)
|
if (Target != CurrentTarget)
|
||||||
{
|
{
|
||||||
/* Close old target key */
|
/* Close old target key */
|
||||||
|
@ -5513,8 +5507,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
swprintf(NameBuffer,
|
swprintf(NameBuffer,
|
||||||
L"Target Id %lu",
|
L"Target Id %lu",
|
||||||
Target);
|
Target);
|
||||||
RtlInitUnicodeString(&KeyName,
|
RtlInitUnicodeString(&KeyName, NameBuffer);
|
||||||
NameBuffer);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&KeyName,
|
&KeyName,
|
||||||
0,
|
0,
|
||||||
|
@ -5541,8 +5534,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
swprintf(NameBuffer,
|
swprintf(NameBuffer,
|
||||||
L"Logical Unit Id %lu",
|
L"Logical Unit Id %lu",
|
||||||
Lun);
|
Lun);
|
||||||
RtlInitUnicodeString(&KeyName,
|
RtlInitUnicodeString(&KeyName, NameBuffer);
|
||||||
NameBuffer);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&KeyName,
|
&KeyName,
|
||||||
0,
|
0,
|
||||||
|
@ -5568,8 +5560,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
LunExtension->InquiryData.ProductId,
|
LunExtension->InquiryData.ProductId,
|
||||||
LunExtension->InquiryData.ProductRevisionLevel);
|
LunExtension->InquiryData.ProductRevisionLevel);
|
||||||
DPRINT(" Identifier = '%S'\n", NameBuffer);
|
DPRINT(" Identifier = '%S'\n", NameBuffer);
|
||||||
RtlInitUnicodeString(&ValueName,
|
RtlInitUnicodeString(&ValueName, L"Identifier");
|
||||||
L"Identifier");
|
|
||||||
Status = ZwSetValueKey(ScsiLunKey,
|
Status = ZwSetValueKey(ScsiLunKey,
|
||||||
&ValueName,
|
&ValueName,
|
||||||
0,
|
0,
|
||||||
|
@ -5617,8 +5608,7 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
DPRINT(" Type = '%S'\n", TypeName);
|
DPRINT(" Type = '%S'\n", TypeName);
|
||||||
RtlInitUnicodeString(&ValueName,
|
RtlInitUnicodeString(&ValueName, L"Type");
|
||||||
L"Type");
|
|
||||||
Status = ZwSetValueKey(ScsiLunKey,
|
Status = ZwSetValueKey(ScsiLunKey,
|
||||||
&ValueName,
|
&ValueName,
|
||||||
0,
|
0,
|
||||||
|
@ -5634,7 +5624,6 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
ZwClose(ScsiLunKey);
|
ZwClose(ScsiLunKey);
|
||||||
ScsiLunKey = NULL;
|
ScsiLunKey = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Close old target key */
|
/* Close old target key */
|
||||||
if (ScsiTargetKey != NULL)
|
if (ScsiTargetKey != NULL)
|
||||||
|
@ -5650,19 +5639,19 @@ SpiBuildDeviceMap (PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
|
||||||
|
|
||||||
ByeBye:
|
ByeBye:
|
||||||
if (ScsiLunKey != NULL)
|
if (ScsiLunKey != NULL)
|
||||||
ZwClose (ScsiLunKey);
|
ZwClose(ScsiLunKey);
|
||||||
|
|
||||||
if (ScsiInitiatorKey != NULL)
|
if (ScsiInitiatorKey != NULL)
|
||||||
ZwClose (ScsiInitiatorKey);
|
ZwClose(ScsiInitiatorKey);
|
||||||
|
|
||||||
if (ScsiTargetKey != NULL)
|
if (ScsiTargetKey != NULL)
|
||||||
ZwClose (ScsiTargetKey);
|
ZwClose(ScsiTargetKey);
|
||||||
|
|
||||||
if (ScsiBusKey != NULL)
|
if (ScsiBusKey != NULL)
|
||||||
ZwClose (ScsiBusKey);
|
ZwClose(ScsiBusKey);
|
||||||
|
|
||||||
if (ScsiPortKey != NULL)
|
if (ScsiPortKey != NULL)
|
||||||
ZwClose (ScsiPortKey);
|
ZwClose(ScsiPortKey);
|
||||||
|
|
||||||
DPRINT("SpiBuildDeviceMap() done\n");
|
DPRINT("SpiBuildDeviceMap() done\n");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue