* Sync up to trunk head (r65353).
[reactos.git] / drivers / storage / classpnp / utils.c
index 43dd049..de4cc04 100644 (file)
@@ -22,9 +22,6 @@ Revision History:
 --*/
 
 #include "classp.h"
-#include "debug.h"
-
-
 
 #ifdef ALLOC_PRAGMA
     #pragma alloc_text(PAGE, ClassGetDeviceParameter)
@@ -32,10 +29,8 @@ Revision History:
     #pragma alloc_text(PAGE, ClassSetDeviceParameter)
 #endif
 
-
-
 // custom string match -- careful!
-BOOLEAN ClasspMyStringMatches(IN PCHAR StringToMatch OPTIONAL, IN PCHAR TargetString)
+BOOLEAN NTAPI ClasspMyStringMatches(IN PCSTR StringToMatch OPTIONAL, IN PCSTR TargetString)
 {
     ULONG length;  // strlen returns an int, not size_t (!)
     PAGED_CODE();
@@ -54,8 +49,7 @@ BOOLEAN ClasspMyStringMatches(IN PCHAR StringToMatch OPTIONAL, IN PCHAR TargetSt
     return (strncmp(StringToMatch, TargetString, length) == 0);
 }
 
-
-VOID ClassGetDeviceParameter(
+VOID NTAPI ClassGetDeviceParameter(
     IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
     IN PWSTR SubkeyName OPTIONAL,
     IN PWSTR ParameterName,
@@ -139,8 +133,7 @@ VOID ClassGetDeviceParameter(
 
 } // end ClassGetDeviceParameter()
 
-
-NTSTATUS ClassSetDeviceParameter(
+NTSTATUS NTAPI ClassSetDeviceParameter(
     IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
     IN PWSTR SubkeyName OPTIONAL,
     IN PWSTR ParameterName,
@@ -210,7 +203,6 @@ NTSTATUS ClassSetDeviceParameter(
 
 } // end ClassSetDeviceParameter()
 
-
 /*
  *  ClassScanForSpecial
  *
@@ -218,17 +210,17 @@ NTSTATUS ClassSetDeviceParameter(
  *      hardware based upon id strings.  it does not check the registry.
  */
 
-VOID ClassScanForSpecial(
+VOID NTAPI ClassScanForSpecial(
     IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
     IN CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList[],
     IN PCLASS_SCAN_FOR_SPECIAL_HANDLER Function)
 {
     PSTORAGE_DEVICE_DESCRIPTOR deviceDescriptor;
-    PUCHAR vendorId;
-    PUCHAR productId;
-    PUCHAR productRevision;
-    UCHAR nullString[] = "";
-    ULONG j;
+    PCSTR vendorId;
+    PCSTR productId;
+    PCSTR productRevision;
+    CHAR nullString[] = "";
+    //ULONG j;
 
     PAGED_CODE();
     ASSERT(DeviceList);
@@ -249,21 +241,21 @@ VOID ClassScanForSpecial(
 
     if (deviceDescriptor->VendorIdOffset != 0 &&
         deviceDescriptor->VendorIdOffset != -1) {
-        vendorId = ((PUCHAR)deviceDescriptor);
+        vendorId = ((PCSTR)deviceDescriptor);
         vendorId += deviceDescriptor->VendorIdOffset;
     } else {
         vendorId = nullString;
     }
     if (deviceDescriptor->ProductIdOffset != 0 &&
         deviceDescriptor->ProductIdOffset != -1) {
-        productId = ((PUCHAR)deviceDescriptor);
+        productId = ((PCSTR)deviceDescriptor);
         productId += deviceDescriptor->ProductIdOffset;
     } else {
         productId = nullString;
     }
     if (deviceDescriptor->VendorIdOffset != 0 &&
         deviceDescriptor->VendorIdOffset != -1) {
-        productRevision = ((PUCHAR)deviceDescriptor);
+        productRevision = ((PCSTR)deviceDescriptor);
         productRevision += deviceDescriptor->ProductRevisionOffset;
     } else {
         productRevision = nullString;
@@ -312,7 +304,6 @@ VOID ClassScanForSpecial(
 
 } // end ClasspScanForSpecialByInquiry()
 
-
 //
 // In order to provide better performance without the need to reboot,
 // we need to implement a self-adjusting method to set and clear the
@@ -338,6 +329,7 @@ VOID ClassScanForSpecial(
 //
 
 VOID
+NTAPI
 ClasspPerfIncrementErrorCount(
     IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
     )
@@ -349,7 +341,7 @@ ClasspPerfIncrementErrorCount(
     KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
 
     fdoData->Perf.SuccessfulIO = 0; // implicit interlock
-    errors = InterlockedIncrement(&FdoExtension->ErrorCount);
+    errors = InterlockedIncrement((PLONG)&FdoExtension->ErrorCount);
 
     if (errors >= CLASS_ERROR_LEVEL_1) {
 
@@ -389,6 +381,7 @@ ClasspPerfIncrementErrorCount(
 }
 
 VOID
+NTAPI
 ClasspPerfIncrementSuccessfulIo(
     IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
     )
@@ -411,7 +404,7 @@ ClasspPerfIncrementSuccessfulIo(
         return;
     }
 
-    succeeded = InterlockedIncrement(&fdoData->Perf.SuccessfulIO);
+    succeeded = InterlockedIncrement((PLONG)&fdoData->Perf.SuccessfulIO);
     if (succeeded < fdoData->Perf.ReEnableThreshhold) {
         return;
     }
@@ -439,7 +432,7 @@ ClasspPerfIncrementSuccessfulIo(
         fdoData->Perf.SuccessfulIO = 0; // implicit interlock
 
         ASSERT(FdoExtension->ErrorCount > 0);
-        errors = InterlockedDecrement(&FdoExtension->ErrorCount);
+        errors = InterlockedDecrement((PLONG)&FdoExtension->ErrorCount);
 
         //
         // note: do in reverse order of the sets "just in case"
@@ -484,8 +477,7 @@ ClasspPerfIncrementSuccessfulIo(
     return;
 }
 
-
-PMDL BuildDeviceInputMdl(PVOID Buffer, ULONG BufferLen)
+PMDL NTAPI BuildDeviceInputMdl(PVOID Buffer, ULONG BufferLen)
 {
     PMDL mdl;
 
@@ -514,14 +506,12 @@ PMDL BuildDeviceInputMdl(PVOID Buffer, ULONG BufferLen)
     return mdl;
 }
 
-
-VOID FreeDeviceInputMdl(PMDL Mdl)
+VOID NTAPI FreeDeviceInputMdl(PMDL Mdl)
 {
     MmUnlockPages(Mdl);
     IoFreeMdl(Mdl);
 }
 
-
 #if 0
     VOID
     ClasspPerfResetCounters(
@@ -561,5 +551,3 @@ VOID FreeDeviceInputMdl(PMDL Mdl)
         return;
     }
 #endif
-
-