https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e831f8530ba6fb0d4e7a12b036fc218041084b22

commit e831f8530ba6fb0d4e7a12b036fc218041084b22
Author:     Victor Perevertkin <[email protected]>
AuthorDate: Tue Jun 25 19:04:20 2019 +0300
Commit:     Victor Perevertkin <[email protected]>
CommitDate: Tue Jun 25 19:04:20 2019 +0300

    [USBSTOR] Do not print device descriptor by default.
    Add SrbGetCdb macro
---
 drivers/usb/usbstor/fdo.c     | 36 ++++++++++++++++++++----------------
 drivers/usb/usbstor/scsi.c    | 26 +++++++++++---------------
 drivers/usb/usbstor/usbstor.h |  4 ++++
 3 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/drivers/usb/usbstor/fdo.c b/drivers/usb/usbstor/fdo.c
index a8a1a4d37b3..7b5dfc04c9f 100644
--- a/drivers/usb/usbstor/fdo.c
+++ b/drivers/usb/usbstor/fdo.c
@@ -14,25 +14,28 @@
 #include <debug.h>
 
 
+#if DBG
+static
 VOID
 USBSTOR_DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
 {
-    DPRINT1("Dumping Device Descriptor %p\n", DeviceDescriptor);
-    DPRINT1("bLength %x\n", DeviceDescriptor->bLength);
-    DPRINT1("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
-    DPRINT1("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
-    DPRINT1("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
-    DPRINT1("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
-    DPRINT1("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
-    DPRINT1("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
-    DPRINT1("idVendor %x\n", DeviceDescriptor->idVendor);
-    DPRINT1("idProduct %x\n", DeviceDescriptor->idProduct);
-    DPRINT1("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
-    DPRINT1("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
-    DPRINT1("iProduct %x\n", DeviceDescriptor->iProduct);
-    DPRINT1("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
-    DPRINT1("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations);
+    DPRINT("Dumping Device Descriptor %p\n", DeviceDescriptor);
+    DPRINT("bLength %x\n", DeviceDescriptor->bLength);
+    DPRINT("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
+    DPRINT("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
+    DPRINT("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
+    DPRINT("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
+    DPRINT("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
+    DPRINT("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
+    DPRINT("idVendor %x\n", DeviceDescriptor->idVendor);
+    DPRINT("idProduct %x\n", DeviceDescriptor->idProduct);
+    DPRINT("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
+    DPRINT("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
+    DPRINT("iProduct %x\n", DeviceDescriptor->iProduct);
+    DPRINT("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
+    DPRINT("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations);
 }
+#endif
 
 NTSTATUS
 USBSTOR_FdoHandleDeviceRelations(
@@ -184,8 +187,9 @@ USBSTOR_FdoHandleStartDevice(
         return Status;
     }
 
+#if DBG
     USBSTOR_DumpDeviceDescriptor(DeviceExtension->DeviceDescriptor);
-
+#endif
 
     // Check that this device uses bulk transfers and is SCSI
 
diff --git a/drivers/usb/usbstor/scsi.c b/drivers/usb/usbstor/scsi.c
index f917e0345e0..be27921bd3a 100644
--- a/drivers/usb/usbstor/scsi.c
+++ b/drivers/usb/usbstor/scsi.c
@@ -81,17 +81,17 @@ USBSTOR_IssueBulkOrInterruptRequest(
     Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = TransferBuffer;
     Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = 
TransferBufferMDL;
 
-    NextStack = IoGetNextIrpStackLocation(Irp); 
-    NextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; 
-    NextStack->Parameters.DeviceIoControl.IoControlCode = 
IOCTL_INTERNAL_USB_SUBMIT_URB; 
-    NextStack->Parameters.Others.Argument1 = &Context->Urb; 
+    NextStack = IoGetNextIrpStackLocation(Irp);
+    NextStack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
+    NextStack->Parameters.DeviceIoControl.IoControlCode = 
IOCTL_INTERNAL_USB_SUBMIT_URB;
+    NextStack->Parameters.Others.Argument1 = &Context->Urb;
 
     IoSetCompletionRoutine(Irp,
                            CompletionRoutine,
                            Context,
                            TRUE,
                            TRUE,
-                           TRUE); 
+                           TRUE);
 
     return IoCallDriver(FDODeviceExtension->LowerDeviceObject, Irp);
 }
@@ -210,7 +210,7 @@ USBSTOR_CSWCompletionRoutine(
         DPRINT("USBSTOR_CSWCompletionRoutine: CSW_STATUS_COMMAND_FAILED\n");
 
         ASSERT(FDODeviceExtension->ActiveSrb == Request);
-        
+
         // setting a generic error status, additional information
         // should be read by higher-level driver from SenseInfoBuffer
         Request->SrbStatus = SRB_STATUS_ERROR;
@@ -410,7 +410,7 @@ USBSTOR_CBWCompletionRoutine(
                                 FALSE,
                                 FALSE,
                                 NULL);
-    
+
             if (Mdl)
             {
                 IoBuildPartialMdl(Irp->MdlAddress,
@@ -526,7 +526,6 @@ USBSTOR_IssueRequestSense(
     PIO_STACK_LOCATION IoStack;
     PSCSI_REQUEST_BLOCK CurrentSrb;
     PSCSI_REQUEST_BLOCK SenseSrb;
-    PCDB pCDB;
 
     DPRINT("USBSTOR_IssueRequestSense: \n");
 
@@ -551,9 +550,8 @@ USBSTOR_IssueRequestSense(
     SenseSrb->DataTransferLength = CurrentSrb->SenseInfoBufferLength;
     SenseSrb->DataBuffer = CurrentSrb->SenseInfoBuffer;
 
-    pCDB = (PCDB)SenseSrb->Cdb;
-    pCDB->CDB6GENERIC.OperationCode = SCSIOP_REQUEST_SENSE;
-    pCDB->AsByte[4] = CurrentSrb->SenseInfoBufferLength;
+    SrbGetCdb(SenseSrb)->CDB6GENERIC.OperationCode = SCSIOP_REQUEST_SENSE;
+    SrbGetCdb(SenseSrb)->AsByte[4] = CurrentSrb->SenseInfoBufferLength;
 
     return USBSTOR_SendCBWRequest(FDODeviceExtension, Irp, Context);
 }
@@ -563,7 +561,6 @@ USBSTOR_HandleExecuteSCSI(
     IN PDEVICE_OBJECT DeviceObject,
     IN PIRP Irp)
 {
-    PCDB pCDB;
     NTSTATUS Status;
     PIO_STACK_LOCATION IoStack;
     PSCSI_REQUEST_BLOCK Request;
@@ -575,12 +572,11 @@ USBSTOR_HandleExecuteSCSI(
 
     IoStack = IoGetCurrentIrpStackLocation(Irp);
     Request = IoStack->Parameters.Scsi.Srb;
-    pCDB = (PCDB)Request->Cdb;
 
-    DPRINT("USBSTOR_HandleExecuteSCSI Operation Code %x, Length %lu\n", 
pCDB->CDB10.OperationCode, Request->DataTransferLength);
+    DPRINT("USBSTOR_HandleExecuteSCSI Operation Code %x, Length %lu\n", 
SrbGetCdb(Request)->CDB10.OperationCode, Request->DataTransferLength);
 
     // check that we're sending to the right LUN
-    ASSERT(pCDB->CDB10.LogicalUnitNumber == (PDODeviceExtension->LUN & 
MAX_LUN));
+    ASSERT(SrbGetCdb(Request)->CDB10.LogicalUnitNumber == 
(PDODeviceExtension->LUN & MAX_LUN));
     Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(IRP_CONTEXT), 
USB_STOR_TAG);
 
     if (!Context)
diff --git a/drivers/usb/usbstor/usbstor.h b/drivers/usb/usbstor/usbstor.h
index 9fc3101ef2c..16bd314b56c 100644
--- a/drivers/usb/usbstor/usbstor.h
+++ b/drivers/usb/usbstor/usbstor.h
@@ -29,6 +29,10 @@
 #define BooleanFlagOn(Flags, SingleFlag) ((BOOLEAN)((((Flags) & (SingleFlag)) 
!= 0)))
 #endif
 
+#ifndef SrbGetCdb
+#define SrbGetCdb(srb) ((PCDB)(srb->Cdb))
+#endif
+
 #define USB_RECOVERABLE_ERRORS (USBD_STATUS_STALL_PID | 
USBD_STATUS_DEV_NOT_RESPONDING \
        | USBD_STATUS_ENDPOINT_HALTED | USBD_STATUS_NO_BANDWIDTH)
 

Reply via email to