Joystick patch

Brian Gerst (bgerst@quark.vpplus.com)
Tue, 04 Nov 1997 01:05:39 -0500


This is a multi-part message in MIME format.
--------------21C1E935C55AA1F1BF700F28
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Here is an updated patch which fixes two problems with the joystick
driver: the change in the VFS to *_read, and a broken while loop which
caused the driver to always loop JS_DEF_TIMEOUT times, regardless if all
axes had finished. I am also planning on giving the driver a complete
rewrite to allow for using other types of joysticks, such as digital
joysticks. I am currently working on code for the MS Sidewinder 3dPro.

-- 

Brian Gerst --------------21C1E935C55AA1F1BF700F28 Content-Type: text/plain; charset=us-ascii; name="joystick.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="joystick.diff"

--- linux-2.1.62/drivers/char/joystick.c Wed Jul 16 22:22:50 1997 +++ linux/drivers/char/joystick.c Tue Nov 4 00:51:43 1997 @@ -47,6 +47,9 @@ compatibility. Better ioctl names. Kept binary compatibility. Removed 'save_busy'. Just set busy to 1. +11/03/97 Brian Gerst 0.9.1: Fixed bug which caused driver to always time out + but never report a timeout (broken while loop). + Fixed js_read for new VFS code. */ #include <linux/module.h> @@ -227,20 +230,21 @@ * one shots to clear. */ -static long js_read (struct inode *inode, struct file *file, char *buf, unsigned long count) +static ssize_t js_read (struct file *file, char *buf, + size_t count, loff_t *ppos) { int j, chk, jsmask; int t0, t_x0, t_y0, t_x1, t_y1; - unsigned int minor, minor2; + unsigned int minor; int buttons; - + struct inode *inode=file->f_dentry->d_inode; + if (count != JS_RETURN) return -EINVAL; - minor = MINOR (inode->i_rdev); + minor = MINOR (inode->i_rdev); inode->i_atime = CURRENT_TIME; if (jiffies >= js_data[minor].js_expiretime) { - minor2 = minor << 1; j = js_data[minor].js_timeout; for (; (js_exist & inb (JS_PORT)) && j; j--); if (j == 0) @@ -262,8 +266,8 @@ /*get init timestamp*/ t_x0 = t_y0 = t_x1 = t_y1 = t0 = get_timer0 (); /*wait for an axis' bit to clear or timeout*/ - while (j-- && (chk = (inb (JS_PORT) & js_exist ) | jsmask)) - { + do { + chk = (inb (JS_PORT) & js_exist) | jsmask; if (!(chk & JS_X_0)) { t_x0 = get_timer0(); jsmask |= JS_X_0; @@ -280,7 +284,7 @@ t_y1 = get_timer0(); jsmask |= JS_Y_1; } - } + } while (--j && jsmask != js_exist); sti(); /* allow interrupts */ js_read_semaphore = 0; /* allow other reads to progress */

--------------21C1E935C55AA1F1BF700F28--