Fail PS2 port commands when receiving a NAK.
authorKevin O'Connor <kevin@koconnor.net>
Thu, 3 Dec 2009 02:19:30 +0000 (21:19 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 3 Dec 2009 02:19:30 +0000 (21:19 -0500)
Fail the command on a nak - don't ignore it.

src/ps2port.c

index 87aa02ee11dbbf97534e512a2908dc3c97827c99..39ec65f8c101e1df45af180d78ce61689c41703d 100644 (file)
@@ -151,7 +151,7 @@ ps2_recvbyte(int aux, int needack, int timeout)
                 if (data == PS2_RET_ACK)
                     return data;
                 if (data == PS2_RET_NAK) {
-                    dprintf(1, "Got ps2 nak (status=%x); continuing\n", status);
+                    dprintf(1, "Got ps2 nak (status=%x)\n", status);
                     return data;
                 }
             }
@@ -184,6 +184,8 @@ ps2_sendbyte(int aux, u8 command, int timeout)
     ret = ps2_recvbyte(aux, 1, timeout);
     if (ret < 0)
         return ret;
+    if (ret != PS2_RET_ACK)
+        return -1;
 
     return 0;
 }