Process working counter of phy_* commands.
authorFlorian Pose <fp@igh-essen.com>
Wed, 08 Apr 2009 10:27:48 +0000
changeset 1385 241a7511eee9
parent 1384 21b5343910c2
child 1386 95ec1e9bcb53
Process working counter of phy_* commands.
master/fsm_master.c
--- a/master/fsm_master.c	Wed Apr 08 10:15:28 2009 +0000
+++ b/master/fsm_master.c	Wed Apr 08 10:27:48 2009 +0000
@@ -1031,22 +1031,27 @@
         return;
     }
     
-    if (request->dir == EC_DIR_INPUT) { // read request
-        if (request->data)
-            kfree(request->data);
-        request->data = kmalloc(request->length, GFP_KERNEL);
-        if (!request->data) {
-            EC_ERR("Failed to allocate %u bytes of memory for phy request.\n",
-                    request->length);
-            request->state = EC_INT_REQUEST_FAILURE;
-            wake_up(&master->phy_queue);
-            ec_fsm_master_restart(fsm);
-            return;
+    if (datagram->working_counter == 1) {
+        if (request->dir == EC_DIR_INPUT) { // read request
+            if (request->data)
+                kfree(request->data);
+            request->data = kmalloc(request->length, GFP_KERNEL);
+            if (!request->data) {
+                EC_ERR("Failed to allocate %u bytes of memory for phy request.\n",
+                        request->length);
+                request->state = EC_INT_REQUEST_FAILURE;
+                wake_up(&master->phy_queue);
+                ec_fsm_master_restart(fsm);
+                return;
+            }
+            memcpy(request->data, datagram->data, request->length);
         }
-        memcpy(request->data, datagram->data, request->length);
-    }
-
-    request->state = EC_INT_REQUEST_SUCCESS;
+
+        request->state = EC_INT_REQUEST_SUCCESS;
+    } else {
+        request->state = EC_INT_REQUEST_FAILURE;
+    }
+
     wake_up(&master->phy_queue);
 
     // check for another PHY request