patch-2.4.0-test2 linux/drivers/usb/input.c

Next file: linux/drivers/usb/joydev.c
Previous file: linux/drivers/usb/iforce.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test1/linux/drivers/usb/input.c linux/drivers/usb/input.c
@@ -1,7 +1,7 @@
 /*
- *  input.c  Version 0.1
+ * $Id: input.c,v 1.7 2000/05/28 17:31:36 vojtech Exp $
  *
- *  Copyright (c) 1999 Vojtech Pavlik
+ *  Copyright (c) 1999-2000 Vojtech Pavlik
  *
  *  The input layer module itself
  *
@@ -91,11 +91,27 @@
 		
 		case EV_ABS:
 
-			if (code > ABS_MAX || !test_bit(code, dev->absbit) || (value == dev->abs[code]))
+			if (code > ABS_MAX || !test_bit(code, dev->absbit))
 				return;
 
-			dev->abs[code] = value;
+			if (dev->absfuzz[code]) {
+				if ((value > dev->abs[code] - (dev->absfuzz[code] >> 1)) &&
+				    (value < dev->abs[code] + (dev->absfuzz[code] >> 1)))
+					return;
+
+				if ((value > dev->abs[code] - dev->absfuzz[code]) &&
+				    (value < dev->abs[code] + dev->absfuzz[code]))
+					value = (dev->abs[code] * 3 + value) >> 2;
+
+				if ((value > dev->abs[code] - (dev->absfuzz[code] << 1)) &&
+				    (value < dev->abs[code] + (dev->absfuzz[code] << 1)))
+					value = (dev->abs[code] + value) >> 1;
+			}
+
+			if (dev->abs[code] == value)
+				return;
 
+			dev->abs[code] = value;
 			break;
 
 		case EV_REL:
@@ -344,16 +360,25 @@
 static int input_open_file(struct inode *inode, struct file *file)
 {
 	struct input_handler *handler = input_table[MINOR(inode->i_rdev) >> 5];
+	struct file_operations *old_fops;
+	int err;
 
 	if (!handler || !handler->fops || !handler->fops->open)
 		return -ENODEV;
 
-	file->f_op = handler->fops;
-
-	return handler->fops->open(inode, file);
+	old_fops = file->f_op;
+	file->f_op = fops_get(handler->fops);
+	err = handler->fops->open(inode, file);
+	if (err) {
+		fops_put(file->f_op);
+		file->f_op = fops_get(old_fops);
+	}
+	fops_put(old_fops);
+	return err;
 }
 
 static struct file_operations input_fops = {
+	owner: THIS_MODULE,
 	open: input_open_file,
 };
 
@@ -361,8 +386,8 @@
 {
 	char devfs_name[16];
 	sprintf(devfs_name, name, minor);
-	return devfs_register(input_devfs_handle, devfs_name, 0, DEVFS_FL_DEFAULT, INPUT_MAJOR, minor + minor_base,
-		S_IFCHR | S_IRUGO | S_IWUSR, 0, 0, &input_fops, NULL);
+	return devfs_register(input_devfs_handle, devfs_name, DEVFS_FL_DEFAULT, INPUT_MAJOR, minor + minor_base,
+		S_IFCHR | S_IRUGO | S_IWUSR, &input_fops, NULL);
 }
 
 void input_unregister_minor(devfs_handle_t handle)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)