[device] Don't use winvblock__def_enum for device__state
authorShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Sat, 11 Dec 2010 19:08:12 +0000 (14:08 -0500)
committerShao Miller <Shao.Miller@yrdsb.edu.on.ca>
Sat, 11 Dec 2010 19:09:10 +0000 (14:09 -0500)
And rename its values.

src/include/device.h
src/winvblock/bus/pnp.c
src/winvblock/disk/pnp.c
src/winvblock/driver.c

index a1652ff..4de5d79 100644 (file)
 
 #include "portable.h"
 
-enum _device__state {
-    NotStarted,
-    Started,
-    StopPending,
-    Stopped,
-    RemovePending,
-    SurpriseRemovePending,
-    Deleted
+enum device__state {
+    device__state_not_started,
+    device__state_started,
+    device__state_stop_pending,
+    device__state_stopped,
+    device__state_remove_pending,
+    device__state_surprise_remove_pending,
+    device__state_deleted
   };
-winvblock__def_enum(device__state);
 
 /* Forward declaration. */
 winvblock__def_struct(device__type);
@@ -149,8 +148,8 @@ struct _device__type
   PDEVICE_OBJECT Self;
   PDEVICE_OBJECT Parent;
   PDRIVER_OBJECT DriverObject;
-  device__state State;
-  device__state OldState;
+  enum device__state state;
+  enum device__state old_state;
   irp__handler_chain irp_handler_chain;
   device__type_ptr next_sibling_ptr;
   device__ops ops;
index a2d00d4..bb64b55 100644 (file)
@@ -79,8 +79,8 @@ NTSTATUS STDCALL bus_pnp__start_dev(
     }
   if ( NT_SUCCESS ( status = Irp->IoStatus.Status ) )
     {
-      dev_ptr->OldState = dev_ptr->State;
-      dev_ptr->State = Started;
+      dev_ptr->old_state = dev_ptr->state;
+      dev_ptr->state = device__state_started;
     }
   status = STATUS_SUCCESS;
   Irp->IoStatus.Status = status;
@@ -103,8 +103,8 @@ NTSTATUS STDCALL bus_pnp__remove_dev(
    next;
   PDEVICE_OBJECT lower;
 
-  dev_ptr->OldState = dev_ptr->State;
-  dev_ptr->State = Deleted;
+  dev_ptr->old_state = dev_ptr->state;
+  dev_ptr->state = device__state_deleted;
   Irp->IoStatus.Information = 0;
   Irp->IoStatus.Status = STATUS_SUCCESS;
   IoSkipCurrentIrpStackLocation ( Irp );
@@ -224,31 +224,31 @@ NTSTATUS STDCALL bus_pnp__simple(
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_QUERY_STOP_DEVICE:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = StopPending;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_stop_pending;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_CANCEL_STOP_DEVICE:
-       dev_ptr->State = dev_ptr->OldState;
+       dev_ptr->state = dev_ptr->old_state;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_STOP_DEVICE:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = Stopped;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_stopped;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_QUERY_REMOVE_DEVICE:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = RemovePending;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_remove_pending;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_CANCEL_REMOVE_DEVICE:
-       dev_ptr->State = dev_ptr->OldState;
+       dev_ptr->state = dev_ptr->old_state;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_SURPRISE_REMOVAL:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = SurpriseRemovePending;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_surprise_remove_pending;
        status = STATUS_SUCCESS;
        break;
       default:
index 07745d9..10a082c 100644 (file)
@@ -366,32 +366,32 @@ NTSTATUS STDCALL disk_pnp__simple(
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_START_DEVICE:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = Started;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_started;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_QUERY_STOP_DEVICE:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = StopPending;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_stop_pending;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_CANCEL_STOP_DEVICE:
-       dev_ptr->State = dev_ptr->OldState;
+       dev_ptr->state = dev_ptr->old_state;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_STOP_DEVICE:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = Stopped;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_stopped;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_QUERY_REMOVE_DEVICE:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = RemovePending;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_remove_pending;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_REMOVE_DEVICE:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = NotStarted;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_not_started;
        if ( disk_ptr->Unmount )
          {
            device__close ( dev_ptr );
@@ -405,12 +405,12 @@ NTSTATUS STDCALL disk_pnp__simple(
          }
        break;
       case IRP_MN_CANCEL_REMOVE_DEVICE:
-       dev_ptr->State = dev_ptr->OldState;
+       dev_ptr->state = dev_ptr->old_state;
        status = STATUS_SUCCESS;
        break;
       case IRP_MN_SURPRISE_REMOVAL:
-       dev_ptr->OldState = dev_ptr->State;
-       dev_ptr->State = SurpriseRemovePending;
+       dev_ptr->old_state = dev_ptr->state;
+       dev_ptr->state = device__state_surprise_remove_pending;
        status = STATUS_SUCCESS;
        break;
       default:
index d998342..34348bb 100644 (file)
@@ -393,7 +393,7 @@ static NTSTATUS STDCALL driver__dispatch_(
     dev_ptr = device__get(DeviceObject);
 
     /* We handle IRP_MJ_POWER as an exception. */
-    if (dev_ptr->State == Deleted) {
+    if (dev_ptr->state == device__state_deleted) {
         if (IoGetCurrentIrpStackLocation(Irp)->MajorFunction == IRP_MJ_POWER)
           PoStartNextPowerIrp(Irp);
         Irp->IoStatus.Information = 0;