Commit 3fc985a6 authored by Vojtech Pavlik's avatar Vojtech Pavlik

Add EVIOCSABS() ioctl to change the abs* informative

values on input devices. This is something the X peoople
really wanted.
Rename input_devinfo to input_id, it's shorter and more 
to the point.
Remove superfluous printks in uinput.c
Clean up return values in evdev.c ioctl. 
parent 5731e6d7
......@@ -233,7 +233,7 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
struct evdev_list *list = file->private_data;
struct evdev *evdev = list->evdev;
struct input_dev *dev = evdev->handle.dev;
int retval, t, u;
int t, u;
if (!evdev->exist) return -ENODEV;
......@@ -243,20 +243,20 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
return put_user(EV_VERSION, (int *) arg);
case EVIOCGID:
return copy_to_user((void *) arg, &dev->id, sizeof(struct input_devinfo));
return copy_to_user((void *) arg, &dev->id, sizeof(struct input_id));
case EVIOCGREP:
if ((retval = put_user(dev->rep[0], ((int *) arg) + 0))) return retval;
if ((retval = put_user(dev->rep[1], ((int *) arg) + 1))) return retval;
if (put_user(dev->rep[0], ((int *) arg) + 0)) return -EFAULT;
if (put_user(dev->rep[1], ((int *) arg) + 1)) return -EFAULT;
return 0;
case EVIOCSREP:
if ((retval = get_user(dev->rep[0], ((int *) arg) + 0))) return retval;
if ((retval = get_user(dev->rep[1], ((int *) arg) + 1))) return retval;
if (get_user(dev->rep[0], ((int *) arg) + 0)) return -EFAULT;
if (get_user(dev->rep[1], ((int *) arg) + 1)) return -EFAULT;
return 0;
case EVIOCGKEYCODE:
if ((retval = get_user(t, ((int *) arg) + 0))) return retval;
if (get_user(t, ((int *) arg) + 0)) return -EFAULT;
if (t < 0 || t > dev->keycodemax) return -EINVAL;
switch (dev->keycodesize) {
case 1: u = *(u8*)(dev->keycode + t); break;
......@@ -264,13 +264,13 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
case 4: u = *(u32*)(dev->keycode + t * 4); break;
default: return -EINVAL;
}
if ((retval = put_user(u, ((int *) arg) + 1))) return retval;
if (put_user(u, ((int *) arg) + 1)) return -EFAULT;
return 0;
case EVIOCSKEYCODE:
if ((retval = get_user(t, ((int *) arg) + 0))) return retval;
if (get_user(t, ((int *) arg) + 0)) return -EFAULT;
if (t < 0 || t > dev->keycodemax) return -EINVAL;
if ((retval = get_user(u, ((int *) arg) + 1))) return retval;
if (get_user(u, ((int *) arg) + 1)) return -EFAULT;
switch (dev->keycodesize) {
case 1: *(u8*)(dev->keycode + t) = u; break;
case 2: *(u16*)(dev->keycode + t * 2) = u; break;
......@@ -284,13 +284,11 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
struct ff_effect effect;
int err;
if (copy_from_user((void*)(&effect), (void*)arg, sizeof(effect))) {
if (copy_from_user((void*)(&effect), (void*)arg, sizeof(effect)))
return -EFAULT;
}
err = dev->upload_effect(dev, &effect);
if (put_user(effect.id, &(((struct ff_effect*)arg)->id))) {
if (put_user(effect.id, &(((struct ff_effect*)arg)->id)))
return -EFAULT;
}
return err;
}
else return -ENOSYS;
......@@ -302,8 +300,8 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
else return -ENOSYS;
case EVIOCGEFFECTS:
if ((retval = put_user(dev->ff_effects_max, (int*) arg)))
return retval;
if (put_user(dev->ff_effects_max, (int*) arg))
return -EFAULT;
return 0;
default:
......@@ -380,11 +378,24 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
int t = _IOC_NR(cmd) & ABS_MAX;
if ((retval = put_user(dev->abs[t], ((int *) arg) + 0))) return retval;
if ((retval = put_user(dev->absmin[t], ((int *) arg) + 1))) return retval;
if ((retval = put_user(dev->absmax[t], ((int *) arg) + 2))) return retval;
if ((retval = put_user(dev->absfuzz[t], ((int *) arg) + 3))) return retval;
if ((retval = put_user(dev->absflat[t], ((int *) arg) + 4))) return retval;
if (put_user(dev->abs[t], ((int *) arg) + 0)) return -EFAULT;
if (put_user(dev->absmin[t], ((int *) arg) + 1)) return -EFAULT;
if (put_user(dev->absmax[t], ((int *) arg) + 2)) return -EFAULT;
if (put_user(dev->absfuzz[t], ((int *) arg) + 3)) return -EFAULT;
if (put_user(dev->absflat[t], ((int *) arg) + 4)) return -EFAULT;
return 0;
}
if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) {
int t = _IOC_NR(cmd) & ABS_MAX;
if (get_user(dev->abs[t], ((int *) arg) + 0)) return -EFAULT;
if (get_user(dev->absmin[t], ((int *) arg) + 1)) return -EFAULT;
if (get_user(dev->absmax[t], ((int *) arg) + 2)) return -EFAULT;
if (get_user(dev->absfuzz[t], ((int *) arg) + 3)) return -EFAULT;
if (get_user(dev->absflat[t], ((int *) arg) + 4)) return -EFAULT;
return 0;
}
......
......@@ -357,7 +357,6 @@ struct file_operations uinput_fops = {
.read = uinput_read,
.write = uinput_write,
.poll = uinput_poll,
// fasync: uinput_fasync,
.ioctl = uinput_ioctl,
};
......@@ -369,16 +368,7 @@ static struct miscdevice uinput_misc = {
static int __init uinput_init(void)
{
int retval;
retval = misc_register(&uinput_misc);
if (!retval) {
printk(KERN_INFO "%s: User level driver support for input subsystem loaded\n", UINPUT_NAME);
printk(KERN_INFO "%s: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>\n", UINPUT_NAME);
}
return retval;
return misc_register(&uinput_misc);
}
static void __exit uinput_exit(void)
......
......@@ -39,7 +39,7 @@ struct gameport {
char *name;
char *phys;
struct input_devinfo id;
struct input_id id;
int io;
int speed;
......
......@@ -56,7 +56,7 @@ struct input_event {
* IOCTLs (0x00 - 0x7f)
*/
struct input_devinfo {
struct input_id {
__u16 bustype;
__u16 vendor;
__u16 product;
......@@ -64,7 +64,7 @@ struct input_devinfo {
};
#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
#define EVIOCGID _IOR('E', 0x02, struct input_devinfo) /* get device ID */
#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */
#define EVIOCGREP _IOR('E', 0x03, int[2]) /* get repeat settings */
#define EVIOCSREP _IOW('E', 0x03, int[2]) /* get repeat settings */
#define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */
......@@ -80,6 +80,7 @@ struct input_devinfo {
#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */
#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, int[5]) /* get abs value/limits */
#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, int[5]) /* set abs value/limits */
#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */
#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
......@@ -754,7 +755,7 @@ struct input_dev {
char *name;
char *phys;
char *uniq;
struct input_devinfo id;
struct input_id id;
unsigned long evbit[NBITS(EV_MAX)];
unsigned long keybit[NBITS(KEY_MAX)];
......@@ -829,7 +830,7 @@ struct input_device_id {
unsigned long flags;
struct input_devinfo id;
struct input_id id;
unsigned long evbit[NBITS(EV_MAX)];
unsigned long keybit[NBITS(KEY_MAX)];
......
......@@ -64,7 +64,7 @@ struct uinput_device {
#define UINPUT_MAX_NAME_SIZE 80
struct uinput_user_dev {
char name[UINPUT_MAX_NAME_SIZE];
struct input_devinfo id;
struct input_id id;
int ff_effects_max;
int absmax[ABS_MAX + 1];
int absmin[ABS_MAX + 1];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment