[PATCH 1/4] Cleanup of the ADI gameport packet reading routine.

From: Vojtech Pavlik
Date: Mon Sep 29 2003 - 12:51:41 EST


You can pull this changeset from:
bk://kernel.bkbits.net/vojtech/input

===================================================================

ChangeSet@xxxxxxxxxx, 2003-09-28 09:21:37+02:00, vojtech@xxxxxxx
input: Cleanup the ADI gameport packet reading routine a bit.
Thanks to a nice guy who wishes not to be named.


adi.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)

===================================================================

diff -Nru a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
--- a/drivers/input/joystick/adi.c Mon Sep 29 19:37:19 2003
+++ b/drivers/input/joystick/adi.c Mon Sep 29 19:37:19 2003
@@ -136,13 +136,18 @@

/*
* adi_read_packet() reads a Logitech ADI packet.
+ *
+ * A packet is sent in response to a gameport trigger command, and can arrive
+ * over one or both pairs of gameport button signals. If the top bit of the
+ * pair changes, it's a 1. If the bottom bit changes, it's a 0. The end of a
+ * packet is signalled by a timeout.
*/

static void adi_read_packet(struct adi_port *port)
{
struct adi *adi = port->adi;
struct gameport *gameport = port->gameport;
- unsigned char u, v, w, x, z;
+ unsigned char u, v, w;
int t[2], s[2], i;
unsigned long flags;

@@ -155,19 +160,19 @@
local_irq_save(flags);

gameport_trigger(gameport);
- v = z = gameport_read(gameport);
+ v = gameport_read(gameport);

do {
- u = v;
- w = u ^ (v = x = gameport_read(gameport));
- for (i = 0; i < 2; i++, w >>= 2, x >>= 2) {
+ w = v ^ (u = gameport_read(gameport));
+ v = u;
+ for (i = 0; i < 2; i++, w >>= 2, u >>= 2) {
t[i]--;
if ((w & 0x30) && s[i]) {
if ((w & 0x30) < 0x30 && adi[i].ret < ADI_MAX_LENGTH && t[i] > 0) {
adi[i].data[++adi[i].ret] = w;
t[i] = gameport_time(gameport, ADI_MAX_STROBE);
} else t[i] = 0;
- } else if (!(x & 0x30)) s[i] = 1;
+ } else if (!(u & 0x30)) s[i] = 1;
}
} while (t[0] > 0 || t[1] > 0);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/