summaryrefslogtreecommitdiffstats
path: root/drivers/usb/mouse.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-06-17 13:25:08 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-06-17 13:25:08 +0000
commit59223edaa18759982db0a8aced0e77457d10c68e (patch)
tree89354903b01fa0a447bffeefe00df3044495db2e /drivers/usb/mouse.c
parentdb7d4daea91e105e3859cf461d7e53b9b77454b2 (diff)
Merge with Linux 2.3.6. Sorry, this isn't tested on silicon, I don't
have a MIPS box at hand.
Diffstat (limited to 'drivers/usb/mouse.c')
-rw-r--r--drivers/usb/mouse.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/usb/mouse.c b/drivers/usb/mouse.c
index 4d346c41a..f094c0b0d 100644
--- a/drivers/usb/mouse.c
+++ b/drivers/usb/mouse.c
@@ -33,6 +33,8 @@
#include <linux/poll.h>
#include <linux/init.h>
#include <linux/malloc.h>
+#include <linux/config.h>
+#include <linux/module.h>
#include <asm/spinlock.h>
@@ -48,7 +50,7 @@ struct mouse_state {
int present; /* this mouse is plugged in */
int active; /* someone is has this mouse's device open */
int ready; /* the mouse has changed state since the last read */
- struct wait_queue *wait; /* for polling */
+ wait_queue_head_t wait; /* for polling */
struct fasync_struct *fasync;
/* later, add a list here to support multiple mice */
/* but we will also need a list of file pointers to identify it */
@@ -73,7 +75,7 @@ static int mouse_irq(int state, void *__buffer, void *dev_id)
mouse->buttons = data[0] & 0x07;
mouse->dx += data[1]; /* data[] is signed, so this works */
mouse->dy -= data[2]; /* y-axis is reversed */
- mouse->dz += data[3];
+ mouse->dz -= data[3];
mouse->ready = 1;
add_mouse_randomness((mouse->buttons << 24) + (mouse->dz << 16 ) +
@@ -172,6 +174,30 @@ static ssize_t read_mouse(struct file * file, char * buffer, size_t count, loff_
buffer++;
retval++;
state = 0;
+ if (!--count)
+ break;
+ }
+
+ /*
+ * SUBTLE:
+ *
+ * The only way to get here is to do a read() of
+ * more than 3 bytes: if you read a byte at a time
+ * you will just ever see states 0-2, for backwards
+ * compatibility.
+ *
+ * So you can think of this as a packet interface,
+ * where you have arbitrary-sized packets, and you
+ * only ever see the first three bytes when you read
+ * them in small chunks.
+ */
+ { /* fallthrough - dz */
+ int dz = mouse->dz;
+ mouse->dz = 0;
+ put_user(dz, buffer);
+ buffer++;
+ retval++;
+ state = 0;
}
break;
}
@@ -223,7 +249,7 @@ static int mouse_probe(struct usb_device *dev)
return -1;
/* Is it a mouse interface? */
- interface = &dev->config[0].interface[0];
+ interface = &dev->config[0].altsetting[0].interface[0];
if (interface->bInterfaceClass != 3)
return -1;
if (interface->bInterfaceSubClass != 1)
@@ -261,6 +287,7 @@ static void mouse_disconnect(struct usb_device *dev)
/* this might need work */
mouse->present = 0;
+ printk("Mouse disconnected\n");
}
static struct usb_driver mouse_driver = {
@@ -277,7 +304,7 @@ int usb_mouse_init(void)
misc_register(&usb_mouse);
mouse->present = mouse->active = 0;
- mouse->wait = NULL;
+ init_waitqueue_head(&mouse->wait);
mouse->fasync = NULL;
usb_register(&mouse_driver);
@@ -291,3 +318,15 @@ void usb_mouse_cleanup(void)
usb_deregister(&mouse_driver);
misc_deregister(&usb_mouse);
}
+
+#ifdef MODULE
+int init_module(void)
+{
+ return usb_mouse_init();
+}
+
+void cleanup_module(void)
+{
+ usb_mouse_cleanup();
+}
+#endif