/*
- * $Id: evdev.c,v 1.42 2002/01/02 11:59:56 vojtech Exp $
+ * $Id: evdev.c,v 1.48 2002/05/26 14:28:26 jdeneux Exp $
*
* Copyright (c) 1999-2001 Vojtech Pavlik
*
struct evdev {
int exist;
int open;
- int open_for_write;
int minor;
char name[16];
struct input_handle handle;
static int evdev_flush(struct file * file)
{
- return input_flush_device(&((struct evdev_list*)file->private_data)->evdev->handle, file);
+ struct evdev_list *list = (struct evdev_list*)file->private_data;
+ if (!list->evdev->exist) return -ENODEV;
+ return input_flush_device(&list->evdev->handle, file);
}
static int evdev_release(struct inode * inode, struct file * file)
struct input_event event;
int retval = 0;
+ if (!list->evdev->exist) return -ENODEV;
+
while (retval < count) {
if (copy_from_user(&event, buffer + retval, sizeof(struct input_event)))
struct input_dev *dev = evdev->handle.dev;
int retval, t, u;
+ if (!evdev->exist) return -ENODEV;
+
switch (cmd) {
case EVIOCGVERSION:
int err;
if (copy_from_user((void*)(&effect), (void*)arg, sizeof(effect))) {
- return -EINVAL;
+ return -EFAULT;
}
err = dev->upload_effect(dev, &effect);
if (put_user(effect.id, &(((struct ff_effect*)arg)->id))) {
- return -EINVAL;
+ return -EFAULT;
}
return err;
}
else return -ENOSYS;
case EVIOCGEFFECTS:
- put_user(dev->ff_effects_max, (int*) arg);
+ if (retval = put_user(dev->ff_effects_max, (int*) arg))
+ return -EFAULT;
return 0;
default:
static struct input_handler *input_handler;
static struct input_handler *input_table[8];
static devfs_handle_t input_devfs_handle;
-static int input_number;
-static long input_devices[NBITS(INPUT_DEVICES)];
#ifdef CONFIG_PROC_FS
static struct proc_dir_entry *proc_bus_input_dir;
* Add the device.
*/
- if (input_number >= INPUT_DEVICES) {
- printk(KERN_WARNING "input: ran out of input device numbers!\n");
- dev->number = input_number;
- } else {
- dev->number = find_first_zero_bit(input_devices, INPUT_DEVICES);
- set_bit(dev->number, input_devices);
- }
-
dev->next = input_dev;
input_dev = dev;
- input_number++;
/*
* Notify handlers.
input_devices_state++;
wake_up(&input_devices_poll_wait);
#endif
-
}
void input_unregister_device(struct input_dev *dev)
if (dev->pm_dev)
pm_unregister(dev->pm_dev);
-
/*
* Kill any pending repeat timers.
*/
*/
input_find_and_remove(struct input_dev, input_dev, dev, next);
- input_number--;
/*
* Notify /proc.
*/
/*
- * $Id: joydev.c,v 1.38 2001/12/27 10:37:41 vojtech Exp $
+ * $Id: joydev.c,v 1.43 2002/04/09 23:59:01 jsimmons Exp $
*
* Copyright (c) 1999-2001 Vojtech Pavlik
* Copyright (c) 1999 Colin Van Dyke
MODULE_LICENSE("GPL");
#define JOYDEV_MINOR_BASE 0
-#define JOYDEV_MINORS 32
+#define JOYDEV_MINORS 16
#define JOYDEV_BUFFER_SIZE 64
#define MSECS(t) (1000 * ((t) / HZ) + 1000 * ((t) % HZ) / HZ)
while (list->head == list->tail) {
+ if (!joydev->exist) {
+ retval = -ENODEV;
+ break;
+ }
if (file->f_flags & O_NONBLOCK) {
retval = -EAGAIN;
break;
struct input_dev *dev = joydev->handle.dev;
int i;
+ if (!joydev->exist) return -ENODEV;
+
switch (cmd) {
case JS_SET_CAL:
/*
- * $Id: keybdev.c,v 1.16 2002/01/09 04:21:41 lethal Exp $
+ * $Id: keybdev.c,v 1.19 2002/03/13 10:09:20 vojtech Exp $
*
* Copyright (c) 1999-2001 Vojtech Pavlik
*
static unsigned long last_jiffie;
static char led;
/* Roughly 1/2s frequency. KDB uses about 1s. Make sure it is different. */
- if (jiffies - last_jiffie > HZ/2) {
+ if (time_after(jiffies, last_jiffie + HZ/2)) {
led ^= 0x01 | 0x04;
keybdev_ledfunc(led);
last_jiffie = jiffies;
/*
- * $Id: mousedev.c,v 1.38 2001/12/26 21:08:33 jsimmons Exp $
+ * $Id: mousedev.c,v 1.42 2002/04/09 20:51:26 jdeneux Exp $
*
* Copyright (c) 1999-2001 Vojtech Pavlik
*
#include <linux/config.h>
#include <linux/smp_lock.h>
#include <linux/random.h>
+#include <linux/major.h>
+#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
+#include <linux/miscdevice.h>
+#endif
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
static int mousedev_open(struct inode * inode, struct file * file)
{
struct mousedev_list *list;
- int i = minor(inode->i_rdev) - MOUSEDEV_MINOR_BASE;
+ int i;
+
+#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
+ if (major(inode->i_rdev) == MISC_MAJOR)
+ i = MOUSEDEV_MIX;
+ else
+#endif
+ i = minor(inode->i_rdev) - MOUSEDEV_MINOR_BASE;
if (i >= MOUSEDEV_MINORS || !mousedev_table[i])
return -ENODEV;
id_table: mousedev_ids,
};
+#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
+static struct miscdevice psaux_mouse = {
+ PSMOUSE_MINOR, "psaux", &mousedev_fops
+};
+#endif
+
static int __init mousedev_init(void)
{
input_register_handler(&mousedev_handler);
mousedev_mix.exist = 1;
mousedev_mix.minor = MOUSEDEV_MIX;
mousedev_mix.devfs = input_register_minor("mice", MOUSEDEV_MIX, MOUSEDEV_MINOR_BASE);
+#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
+ misc_register(&psaux_mouse);
+#endif
printk(KERN_INFO "mice: PS/2 mouse device common for all mice\n");
static void __exit mousedev_exit(void)
{
+#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
+ misc_deregister(&psaux_mouse);
+#endif
input_unregister_minor(mousedev_mix.devfs);
input_unregister_handler(&mousedev_handler);
}