All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: InputML <linux-input@atrey.karlin.mff.cuni.cz>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RCF/RFT] Fix race timer race in gameport-based joystick drivers
Date: Wed, 16 Feb 2005 00:45:59 -0500	[thread overview]
Message-ID: <200502160046.00311.dtor_core@ameritech.net> (raw)
In-Reply-To: <20050215150606.GA8560@ucw.cz>

Somehow missed sidewinder driver...

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

Input: fix timer handling race in sidewinder joystick driver by
       switching to gameport's polling facilities.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

===== drivers/input/joystick/sidewinder.c 1.19 vs edited =====
--- 1.19/drivers/input/joystick/sidewinder.c	2005-02-10 19:00:00 -05:00
+++ edited/drivers/input/joystick/sidewinder.c	2005-02-14 21:36:26 -05:00
@@ -58,7 +58,6 @@
 #define SW_BAD		2	/* Number of packet read errors to switch off 3d Pro optimization */
 #define SW_OK		64	/* Number of packet read successes to switch optimization back on */
 #define SW_LENGTH	512	/* Max number of bits in a packet */
-#define SW_REFRESH	HZ/50	/* Time to wait between updates of joystick data [20 ms] */
 
 #ifdef SW_DEBUG
 #define dbg(format, arg...) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg)
@@ -115,7 +114,6 @@
 
 struct sw {
 	struct gameport *gameport;
-	struct timer_list timer;
 	struct input_dev dev[4];
 	char name[64];
 	char phys[4][32];
@@ -127,7 +125,6 @@
 	int ok;
 	int reads;
 	int bads;
-	int used;
 };
 
 /*
@@ -496,22 +493,20 @@
 	return -1;
 }
 
-static void sw_timer(unsigned long private)
+static void sw_poll(struct gameport *gameport)
 {
-	struct sw *sw = (void *) private;
+	struct sw *sw = gameport_get_drvdata(gameport);
 
 	sw->reads++;
 	if (sw_read(sw))
 		sw->bads++;
-	mod_timer(&sw->timer, jiffies + SW_REFRESH);
 }
 
 static int sw_open(struct input_dev *dev)
 {
 	struct sw *sw = dev->private;
 
-	if (!sw->used++)
-		mod_timer(&sw->timer, jiffies + SW_REFRESH);
+	gameport_start_polling(sw->gameport);
 	return 0;
 }
 
@@ -519,8 +514,7 @@
 {
 	struct sw *sw = dev->private;
 
-	if (!--sw->used)
-		del_timer(&sw->timer);
+	gameport_stop_polling(sw->gameport);
 }
 
 /*
@@ -606,9 +600,6 @@
 	}
 
 	sw->gameport = gameport;
-	init_timer(&sw->timer);
-	sw->timer.data = (long) sw;
-	sw->timer.function = sw_timer;
 
 	gameport_set_drvdata(gameport, sw);
 
@@ -725,6 +716,9 @@
 	sw_print_packet("ID", j * 3, idbuf, 3);
 	sw_print_packet("Data", i * m, buf, m);
 #endif
+
+	gameport_set_poll_handler(gameport, sw_poll);
+	gameport_set_poll_interval(gameport, 20);
 
 	k = i;
 	l = j;

  reply	other threads:[~2005-02-16  5:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-15  5:42 [RCF/RFT] Fix race timer race in gameport-based joystick drivers Dmitry Torokhov
2005-02-15 14:05 ` Vojtech Pavlik
2005-02-15 14:51   ` Dmitry Torokhov
2005-02-15 15:06     ` Vojtech Pavlik
2005-02-16  5:45       ` Dmitry Torokhov [this message]
2005-02-16  8:35         ` Vojtech Pavlik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200502160046.00311.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vojtech@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.