[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH 3/8] Refactor - hide default Pnp/Power function pointers



Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvbd/driver.c | 32 +++++++++++++++++++++++++-------
 src/xenvbd/driver.h | 12 ++++++++++++
 src/xenvbd/fdo.c    | 14 +++++---------
 src/xenvbd/pdo.c    |  4 +---
 4 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/src/xenvbd/driver.c b/src/xenvbd/driver.c
index 2a41c8c..2f13ba6 100644
--- a/src/xenvbd/driver.c
+++ b/src/xenvbd/driver.c
@@ -208,10 +208,28 @@ __DriverParseParameterKey(
 }
 
 //=============================================================================
+static PDRIVER_DISPATCH     StorPortDispatchPnp;
+static PDRIVER_DISPATCH     StorPortDispatchPower;
+static PDRIVER_UNLOAD       StorPortDriverUnload;
+
+NTSTATUS
+DriverDispatchPnp(
+    IN  PDEVICE_OBJECT  DeviceObject,
+    IN  PIRP            Irp
+    )
+{
+    return StorPortDispatchPnp(DeviceObject, Irp);
+}
+
+NTSTATUS
+DriverDispatchPower(
+    IN  PDEVICE_OBJECT  DeviceObject,
+    IN  PIRP            Irp
+    )
+{
+    return StorPortDispatchPower(DeviceObject, Irp);
+}
 
-PDRIVER_DISPATCH     StorPortDispatchPnp;
-PDRIVER_DISPATCH     StorPortDispatchPower;
-PDRIVER_UNLOAD       StorPortDriverUnload;
 //=============================================================================
 // Fdo Device Extension management
 static PXENVBD_FDO              __XenvbdFdo;
@@ -298,7 +316,7 @@ DriverMapPdo(
         }
     }
     KeReleaseSpinLock(&__XenvbdLock, Irql);
-    Status = StorPortDispatchPnp(DeviceObject, Irp);
+    Status = DriverDispatchPnp(DeviceObject, Irp);
 
 done:
     return Status;
@@ -555,7 +573,7 @@ DispatchPnp(
     case IS_NULL:
     default:
         Warning("DeviceObject 0x%p is not FDO (0x%p) or a PDO\n", 
DeviceObject, __XenvbdFdo);
-        Status = StorPortDispatchPnp(DeviceObject, Irp);
+        Status = DriverDispatchPnp(DeviceObject, Irp);
         break;
     }
 
@@ -589,13 +607,13 @@ DispatchPower(
         if (Pdo) {
             PdoDereference(Pdo); // drops Pdo reference
         }
-        Status = StorPortDispatchPower(DeviceObject, Irp);
+        Status = DriverDispatchPower(DeviceObject, Irp);
         break;
 
     case IS_NULL:
     default:
         Warning("DeviceObject 0x%p is not FDO (0x%p) or a PDO\n", 
DeviceObject, __XenvbdFdo);
-        Status = StorPortDispatchPower(DeviceObject, Irp);
+        Status = DriverDispatchPower(DeviceObject, Irp);
         break;
     }
 
diff --git a/src/xenvbd/driver.h b/src/xenvbd/driver.h
index d59f053..560dd4e 100644
--- a/src/xenvbd/driver.h
+++ b/src/xenvbd/driver.h
@@ -59,6 +59,18 @@ extern XENVBD_PARAMETERS    DriverParameters;
 
 extern HANDLE               DriverStatusKey;
 
+extern NTSTATUS
+DriverDispatchPnp(
+    IN  PDEVICE_OBJECT  DeviceObject,
+    IN  PIRP            Irp
+    );
+
+extern NTSTATUS
+DriverDispatchPower(
+    IN  PDEVICE_OBJECT  DeviceObject,
+    IN  PIRP            Irp
+    );
+
 // Fdo Device Extension management
 extern VOID
 DriverLinkFdo(
diff --git a/src/xenvbd/fdo.c b/src/xenvbd/fdo.c
index 82b7fb6..724d8ea 100644
--- a/src/xenvbd/fdo.c
+++ b/src/xenvbd/fdo.c
@@ -98,8 +98,6 @@ struct _XENVBD_FDO {
     LONG                        TotalSrbs;
 };
 
-extern PDRIVER_DISPATCH StorPortDispatchPower;
-
 //=============================================================================
 static FORCEINLINE BOOLEAN
 __FdoSetDevicePowerState(
@@ -1215,7 +1213,7 @@ FdoDevicePower(
             break;
         }
         FdoDereference(Fdo);
-        Status = StorPortDispatchPower(Fdo->DeviceObject, Irp);
+        Status = DriverDispatchPower(Fdo->DeviceObject, Irp);
         if (!NT_SUCCESS(Status)) {
             Warning("StorPort failed PowerIRP with %08x\n", Status);
         }
@@ -1644,8 +1642,6 @@ FdoStartIo(
 
 //=============================================================================
 // PnP Handler
-extern PDRIVER_DISPATCH StorPortDispatchPnp;
-
 __checkReturn
 NTSTATUS
 FdoDispatchPnp(
@@ -1699,7 +1695,7 @@ FdoDispatchPnp(
         break;
     }
 
-    Status = StorPortDispatchPnp(DeviceObject, Irp);
+    Status = DriverDispatchPnp(DeviceObject, Irp);
     if (!NT_SUCCESS(Status)) {
         Verbose("%02x:%s -> %08x\n", Minor, PnpMinorFunctionName(Minor), 
Status);
     }
@@ -1847,7 +1843,7 @@ FdoMapDeviceObjectToPdo(
     ExFreePool(String);
 
 done:
-    Status = StorPortDispatchPnp(DeviceObject, Irp);;
+    Status = DriverDispatchPnp(DeviceObject, Irp);;
     if (!NT_SUCCESS(Status)) {
         Verbose("%02x:%s -> %08x\n", Minor, PnpMinorFunctionName(Minor), 
Status);
     }
@@ -1876,7 +1872,7 @@ FdoDispatchPower(
         if (Fdo->DevicePowerThread == NULL) {
             Verbose("DevicePower IRP before DevicePowerThread ready\n");
             FdoDereference(Fdo);
-            status = StorPortDispatchPower(DeviceObject, Irp);
+            status = DriverDispatchPower(DeviceObject, Irp);
             break;
         }
 
@@ -1894,7 +1890,7 @@ FdoDispatchPower(
     case SystemPowerState:
     default:
         FdoDereference(Fdo);
-        status = StorPortDispatchPower(DeviceObject, Irp);
+        status = DriverDispatchPower(DeviceObject, Irp);
         break;
     }
 
diff --git a/src/xenvbd/pdo.c b/src/xenvbd/pdo.c
index 9387742..c0447db 100644
--- a/src/xenvbd/pdo.c
+++ b/src/xenvbd/pdo.c
@@ -2239,8 +2239,6 @@ PdoSrbPnp(
 
 //=============================================================================
 // PnP Handler
-extern PDRIVER_DISPATCH StorPortDispatchPnp;
-
 static FORCEINLINE VOID
 __PdoDeviceUsageNotification(
     __in PXENVBD_PDO             Pdo,
@@ -2419,7 +2417,7 @@ PdoDispatchPnp(
         break;
     }
     PdoDereference(Pdo);
-    Status = StorPortDispatchPnp(DeviceObject, Irp);
+    Status = DriverDispatchPnp(DeviceObject, Irp);
     if (!NT_SUCCESS(Status)) {
         Verbose("Target[%d] : %02x:%s -> %08x\n", TargetId, Minor, 
PnpMinorFunctionName(Minor), Status);
     }
-- 
1.9.4.msysgit.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.