summaryrefslogtreecommitdiffstats
path: root/drivers/char/atarimouse.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
committer <ralf@linux-mips.org>1997-04-29 21:13:14 +0000
commit19c9bba94152148523ba0f7ef7cffe3d45656b11 (patch)
tree40b1cb534496a7f1ca0f5c314a523c69f1fee464 /drivers/char/atarimouse.c
parent7206675c40394c78a90e74812bbdbf8cf3cca1be (diff)
Import of Linux/MIPS 2.1.36
Diffstat (limited to 'drivers/char/atarimouse.c')
-rw-r--r--drivers/char/atarimouse.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/drivers/char/atarimouse.c b/drivers/char/atarimouse.c
index d35fa5a49..18debb66b 100644
--- a/drivers/char/atarimouse.c
+++ b/drivers/char/atarimouse.c
@@ -19,14 +19,17 @@
#include <linux/miscdevice.h>
#include <linux/mm.h>
#include <linux/random.h>
+#include <linux/poll.h>
+#include <linux/init.h>
+#include <asm/setup.h>
#include <asm/atarikb.h>
#include <asm/atari_mouse.h>
#include <asm/uaccess.h>
-#include <asm/bootinfo.h>
static struct mouse_status mouse;
-static int atari_mouse_x_threshold = 2, atari_mouse_y_threshold = 2;
+static int mouse_threshold[2] = {2,2};
+MODULE_PARM(mouse_threshold, "2i");
extern int atari_mouse_buttons;
static void atari_mouse_interrupt(char *buf)
@@ -61,15 +64,16 @@ static int fasync_mouse(struct inode *inode, struct file *filp, int on)
return 0;
}
-static void release_mouse(struct inode *inode, struct file *file)
+static int release_mouse(struct inode *inode, struct file *file)
{
fasync_mouse(inode, file, 0);
if (--mouse.active)
- return;
+ return 0;
ikbd_mouse_disable();
atari_mouse_interrupt_hook = NULL;
MOD_DEC_USE_COUNT;
+ return 0;
}
static int open_mouse(struct inode *inode, struct file *file)
@@ -80,27 +84,26 @@ static int open_mouse(struct inode *inode, struct file *file)
mouse.dx = mouse.dy = 0;
atari_mouse_buttons = 0;
ikbd_mouse_y0_top ();
- ikbd_mouse_thresh (atari_mouse_x_threshold, atari_mouse_y_threshold);
+ ikbd_mouse_thresh (mouse_threshold[0], mouse_threshold[1]);
ikbd_mouse_rel_pos();
MOD_INC_USE_COUNT;
atari_mouse_interrupt_hook = atari_mouse_interrupt;
return 0;
}
-static int write_mouse(struct inode *inode, struct file *file, const char *buffer, int count)
+static long write_mouse(struct inode *inode, struct file *file,
+ const char *buffer, unsigned long count)
{
return -EINVAL;
}
-static int read_mouse(struct inode *inode, struct file *file, char *buffer, int count)
+static long read_mouse(struct inode *inode, struct file *file,
+ char *buffer, unsigned long count)
{
int dx, dy, buttons;
- int r;
if (count < 3)
return -EINVAL;
- if ((r = verify_area(VERIFY_WRITE, buffer, count)))
- return r;
if (!mouse.ready)
return -EAGAIN;
/* ikbd_mouse_disable */
@@ -120,21 +123,21 @@ static int read_mouse(struct inode *inode, struct file *file, char *buffer, int
if (mouse.dx == 0 && mouse.dy == 0)
mouse.ready = 0;
/* ikbd_mouse_rel_pos(); */
- put_user(buttons | 0x80, buffer);
- put_user((char) dx, buffer + 1);
- put_user((char) dy, buffer + 2);
- for (r = 3; r < count; r++)
- put_user (0, buffer + r);
- return r;
+ if (put_user(buttons | 0x80, buffer++) ||
+ put_user((char) dx, buffer++) ||
+ put_user((char) dy, buffer++))
+ return -EFAULT;
+ if (count > 3)
+ if (clear_user(buffer, count - 3))
+ return -EFAULT;
+ return count;
}
-static int mouse_select(struct inode *inode, struct file *file, int sel_type, select_table *wait)
+static unsigned int mouse_poll(struct file *file, poll_table *wait)
{
- if (sel_type == SEL_IN) {
- if (mouse.ready)
- return 1;
- select_wait(&mouse.wait, wait);
- }
+ poll_wait(&mouse.wait, wait);
+ if (mouse.ready)
+ return POLLIN | POLLRDNORM;
return 0;
}
@@ -143,7 +146,7 @@ struct file_operations atari_mouse_fops = {
read_mouse,
write_mouse,
NULL, /* mouse_readdir */
- mouse_select,
+ mouse_poll,
NULL, /* mouse_ioctl */
NULL, /* mouse_mmap */
open_mouse,
@@ -156,7 +159,7 @@ static struct miscdevice atari_mouse = {
ATARIMOUSE_MINOR, "atarimouse", &atari_mouse_fops
};
-int atari_mouse_init(void)
+__initfunc(int atari_mouse_init(void))
{
mouse.active = 0;
mouse.ready = 0;
@@ -186,20 +189,20 @@ void atari_mouse_setup( char *str, int *ints )
if (ints[1] < MIN_THRESHOLD || ints[1] > MAX_THRESHOLD)
printk( "atari_mouse_setup: bad threshold value (ignored)\n" );
else {
- atari_mouse_x_threshold = ints[1];
- atari_mouse_y_threshold = ints[1];
+ mouse_threshold[0] = ints[1];
+ mouse_threshold[1] = ints[1];
if (ints[0] > 1) {
if (ints[2] < MIN_THRESHOLD || ints[2] > MAX_THRESHOLD)
printk("atari_mouse_setup: bad threshold value (ignored)\n" );
else
- atari_mouse_y_threshold = ints[2];
+ mouse_threshold[1] = ints[2];
}
}
}
#ifdef MODULE
-#include <asm/bootinfo.h>
+#include <asm/setup.h>
int init_module(void)
{