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, ...@@ -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_list *list = file->private_data;
struct evdev *evdev = list->evdev; struct evdev *evdev = list->evdev;
struct input_dev *dev = evdev->handle.dev; struct input_dev *dev = evdev->handle.dev;
int retval, t, u; int t, u;
if (!evdev->exist) return -ENODEV; if (!evdev->exist) return -ENODEV;
...@@ -243,20 +243,20 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -243,20 +243,20 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
return put_user(EV_VERSION, (int *) arg); return put_user(EV_VERSION, (int *) arg);
case EVIOCGID: 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: case EVIOCGREP:
if ((retval = put_user(dev->rep[0], ((int *) arg) + 0))) return retval; if (put_user(dev->rep[0], ((int *) arg) + 0)) return -EFAULT;
if ((retval = put_user(dev->rep[1], ((int *) arg) + 1))) return retval; if (put_user(dev->rep[1], ((int *) arg) + 1)) return -EFAULT;
return 0; return 0;
case EVIOCSREP: case EVIOCSREP:
if ((retval = get_user(dev->rep[0], ((int *) arg) + 0))) return retval; if (get_user(dev->rep[0], ((int *) arg) + 0)) return -EFAULT;
if ((retval = get_user(dev->rep[1], ((int *) arg) + 1))) return retval; if (get_user(dev->rep[1], ((int *) arg) + 1)) return -EFAULT;
return 0; return 0;
case EVIOCGKEYCODE: 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; if (t < 0 || t > dev->keycodemax) return -EINVAL;
switch (dev->keycodesize) { switch (dev->keycodesize) {
case 1: u = *(u8*)(dev->keycode + t); break; 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, ...@@ -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; case 4: u = *(u32*)(dev->keycode + t * 4); break;
default: return -EINVAL; default: return -EINVAL;
} }
if ((retval = put_user(u, ((int *) arg) + 1))) return retval; if (put_user(u, ((int *) arg) + 1)) return -EFAULT;
return 0; return 0;
case EVIOCSKEYCODE: 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 (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) { switch (dev->keycodesize) {
case 1: *(u8*)(dev->keycode + t) = u; break; case 1: *(u8*)(dev->keycode + t) = u; break;
case 2: *(u16*)(dev->keycode + t * 2) = 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, ...@@ -284,13 +284,11 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
struct ff_effect effect; struct ff_effect effect;
int err; int err;
if (copy_from_user((void*)(&effect), (void*)arg, sizeof(effect))) { if (copy_from_user((void*)(&effect), (void*)arg, sizeof(effect)))
return -EFAULT; return -EFAULT;
}
err = dev->upload_effect(dev, &effect); 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 -EFAULT;
}
return err; return err;
} }
else return -ENOSYS; else return -ENOSYS;
...@@ -302,8 +300,8 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -302,8 +300,8 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
else return -ENOSYS; else return -ENOSYS;
case EVIOCGEFFECTS: case EVIOCGEFFECTS:
if ((retval = put_user(dev->ff_effects_max, (int*) arg))) if (put_user(dev->ff_effects_max, (int*) arg))
return retval; return -EFAULT;
return 0; return 0;
default: default:
...@@ -380,11 +378,24 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -380,11 +378,24 @@ static int evdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
int t = _IOC_NR(cmd) & ABS_MAX; int t = _IOC_NR(cmd) & ABS_MAX;
if ((retval = put_user(dev->abs[t], ((int *) arg) + 0))) return retval; if (put_user(dev->abs[t], ((int *) arg) + 0)) return -EFAULT;
if ((retval = put_user(dev->absmin[t], ((int *) arg) + 1))) return retval; if (put_user(dev->absmin[t], ((int *) arg) + 1)) return -EFAULT;
if ((retval = put_user(dev->absmax[t], ((int *) arg) + 2))) return retval; if (put_user(dev->absmax[t], ((int *) arg) + 2)) return -EFAULT;
if ((retval = put_user(dev->absfuzz[t], ((int *) arg) + 3))) return retval; if (put_user(dev->absfuzz[t], ((int *) arg) + 3)) return -EFAULT;
if ((retval = put_user(dev->absflat[t], ((int *) arg) + 4))) return retval; 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; return 0;
} }
......
...@@ -357,7 +357,6 @@ struct file_operations uinput_fops = { ...@@ -357,7 +357,6 @@ struct file_operations uinput_fops = {
.read = uinput_read, .read = uinput_read,
.write = uinput_write, .write = uinput_write,
.poll = uinput_poll, .poll = uinput_poll,
// fasync: uinput_fasync,
.ioctl = uinput_ioctl, .ioctl = uinput_ioctl,
}; };
...@@ -369,16 +368,7 @@ static struct miscdevice uinput_misc = { ...@@ -369,16 +368,7 @@ static struct miscdevice uinput_misc = {
static int __init uinput_init(void) static int __init uinput_init(void)
{ {
int retval; return misc_register(&uinput_misc);
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;
} }
static void __exit uinput_exit(void) static void __exit uinput_exit(void)
......
...@@ -39,7 +39,7 @@ struct gameport { ...@@ -39,7 +39,7 @@ struct gameport {
char *name; char *name;
char *phys; char *phys;
struct input_devinfo id; struct input_id id;
int io; int io;
int speed; int speed;
......
...@@ -56,7 +56,7 @@ struct input_event { ...@@ -56,7 +56,7 @@ struct input_event {
* IOCTLs (0x00 - 0x7f) * IOCTLs (0x00 - 0x7f)
*/ */
struct input_devinfo { struct input_id {
__u16 bustype; __u16 bustype;
__u16 vendor; __u16 vendor;
__u16 product; __u16 product;
...@@ -64,7 +64,7 @@ struct input_devinfo { ...@@ -64,7 +64,7 @@ struct input_devinfo {
}; };
#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ #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 EVIOCGREP _IOR('E', 0x03, int[2]) /* get repeat settings */
#define EVIOCSREP _IOW('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 */ #define EVIOCGKEYCODE _IOR('E', 0x04, int[2]) /* get keycode */
...@@ -80,6 +80,7 @@ struct input_devinfo { ...@@ -80,6 +80,7 @@ struct input_devinfo {
#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ #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 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 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 */ #define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
...@@ -754,7 +755,7 @@ struct input_dev { ...@@ -754,7 +755,7 @@ struct input_dev {
char *name; char *name;
char *phys; char *phys;
char *uniq; char *uniq;
struct input_devinfo id; struct input_id id;
unsigned long evbit[NBITS(EV_MAX)]; unsigned long evbit[NBITS(EV_MAX)];
unsigned long keybit[NBITS(KEY_MAX)]; unsigned long keybit[NBITS(KEY_MAX)];
...@@ -829,7 +830,7 @@ struct input_device_id { ...@@ -829,7 +830,7 @@ struct input_device_id {
unsigned long flags; unsigned long flags;
struct input_devinfo id; struct input_id id;
unsigned long evbit[NBITS(EV_MAX)]; unsigned long evbit[NBITS(EV_MAX)];
unsigned long keybit[NBITS(KEY_MAX)]; unsigned long keybit[NBITS(KEY_MAX)];
......
...@@ -64,7 +64,7 @@ struct uinput_device { ...@@ -64,7 +64,7 @@ struct uinput_device {
#define UINPUT_MAX_NAME_SIZE 80 #define UINPUT_MAX_NAME_SIZE 80
struct uinput_user_dev { struct uinput_user_dev {
char name[UINPUT_MAX_NAME_SIZE]; char name[UINPUT_MAX_NAME_SIZE];
struct input_devinfo id; struct input_id id;
int ff_effects_max; int ff_effects_max;
int absmax[ABS_MAX + 1]; int absmax[ABS_MAX + 1];
int absmin[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